mirror of
https://github.com/nektos/act.git
synced 2026-04-26 09:25:54 +03:00
[GH-ISSUE #416] Handling of "env" variables is not correct sometimes #291
Labels
No labels
area/action
area/cli
area/docs
area/image
area/runner
area/workflow
backlog
confirmed/not-planned
kind/bug
kind/discussion
kind/external
kind/feature-request
kind/question
meta/duplicate
meta/invalid
meta/need-more-info
meta/resolved
meta/wontfix
meta/workaround
needs-work
pull-request
review/not-planned
size/M
size/XL
size/XXL
stale
stale-exempt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/act#291
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @winksaville on GitHub (Nov 11, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/416
I've created act-failing-python-cache with additional details.
This was tested with act master branch as of 11/10/2020:
On a linux computer:
I was trying to use
actions/setup-python@v2andactions/cache@v2:And
Python cachestep fails becasue path is empty and "not supplied":The full log:
As it so happens while creating the test case I found a hack to that solves the problem.
If you add a step between
Set up PythonandPython cachethat displaysenv.pythonLocation(i.e. uncomment lines 22-24 of t1.yml above):
Then
actcan complete all steps:@winksaville commented on GitHub (Nov 11, 2020):
In act-failing-python-cache workaround branch is t1.yml with the extra step added.
@torbjornvatn commented on GitHub (Nov 13, 2020):
Added a comment to your question about this issue here: https://github.com/nektos/act/pull/417#issuecomment-726665949
@winksaville commented on GitHub (Nov 16, 2020):
My diagnosis of the problem is that when a new step is created and newStepExecutor is invoked, see below. It setups a new environ with
_ = sc.setupEnv()(ctx)which "inherits" the environment from the previous step and then creates an expression evaluator for the new step withrc.ExprEval = sc.NewExpressionEvaluator():This is fine but there is a problem, in
setupEnvit loops through all of the environment variables interpolating any${{ xxxx }}into "concrete" values:But notice that
setupEnvusesrc.ExprEvalwhich is the evaluator for the previous step that was created before the previous step was executed. Therefore therc.ExprEvalbeing used does not contain anyenvvalues from the previous step itself, but only values from "its previous step". Therefore, if the "new step" references environment variables that were created or updated in the just completed step they will be empty or old values.Here is the full code for func
setupEnv:My solution is to call
setupEnvandNewExpressionEvaluatora second time. The first invocation will update the enviornemt variables and thenrc.ExprEvalset and its enviornemt will now be "complete", the second invocation will then have the complete set of environment variables and in my caseenv.pythonLocationwill have the correct value after the second invocations. The diff is at this comment to #419.I suspect there is a "better" solution, I'll see if I can work something up,
@winksaville commented on GitHub (Jan 13, 2021):
Fix with #423