Made env interpolated instead of evaluated. (#1222)

* Made env interpolated instead of evaluated.

* [skip ci] Add Test Workflow file

* Activate Test

* fix Test

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
This commit is contained in:
Grigory Entin 2022-07-27 21:46:04 +02:00 committed by GitHub
parent 17dd54d692
commit ddee19b946
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 5 deletions

View file

@ -14,7 +14,6 @@ import (
"github.com/nektos/act/pkg/common"
"github.com/nektos/act/pkg/container"
"github.com/nektos/act/pkg/exprparser"
"github.com/nektos/act/pkg/model"
)
@ -165,10 +164,7 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
// evaluate environment variables since they can contain
// GitHub's special environment variables.
for k, v := range rc.GetEnv() {
valueEval, err := rc.ExprEval.evaluate(ctx, v, exprparser.DefaultStatusCheckNone)
if err == nil {
rc.Env[k] = fmt.Sprintf("%v", valueEval)
}
rc.Env[k] = rc.ExprEval.Interpolate(ctx, v)
}
if len(rc.String()) > maxJobNameLen {
maxJobNameLen = len(rc.String())

View file

@ -177,6 +177,7 @@ func TestRunEvent(t *testing.T) {
{workdir, "if-expressions", "push", "Job 'mytest' failed", platforms},
{workdir, "actions-environment-and-context-tests", "push", "", platforms},
{workdir, "uses-action-with-pre-and-post-step", "push", "", platforms},
{workdir, "evalenv", "push", "", platforms},
{"../model/testdata", "strategy", "push", "", platforms}, // TODO: move all testdata into pkg so we can validate it with planner and runner
// {"testdata", "issue-228", "push", "", platforms, }, // TODO [igni]: Remove this once everything passes
{"../model/testdata", "container-volumes", "push", "", platforms},

21
pkg/runner/testdata/evalenv/push.yml vendored Normal file
View file

@ -0,0 +1,21 @@
name: CI
on: push
jobs:
test:
runs-on: ubuntu-latest
env:
BUILD_DIR: ${{ github.workspace }}/build
steps:
- name: Dump
run: |
echo "$BUILD_DIR"
echo "$EXPECTED_BUILD_DIR"
echo "$GITHUB_WORKSPACE/build"
env:
EXPECTED_BUILD_DIR: ${{ github.workspace }}/build
- name: Test
run: |
[ "$BUILD_DIR" = "$EXPECTED_BUILD_DIR" ] && [ "$BUILD_DIR" = "$GITHUB_WORKSPACE/build" ]
env:
EXPECTED_BUILD_DIR: ${{ github.workspace }}/build