From 364e07a7a05cf5ead1915e9df85d881dc6f3d615 Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Tue, 29 Mar 2022 11:37:24 -0400 Subject: [PATCH] Add test for export gha Only doing this in CI because it doesn't seem worth it to mock GHA to test this, especially conserding `act` already does a good job of mocking GHA. --- .github/workflows/go.yml | 16 ++++++++++++++++ test/scenarios/github-actions/.envrc | 1 + 2 files changed, 17 insertions(+) create mode 100644 test/scenarios/github-actions/.envrc diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d1a7a0e5e..441a47370 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -42,3 +42,19 @@ jobs: GO111MODULE: on run: make test-stdlib test-bash + - name: GitHub Actions Env Test Setup + # FIXME: make this work on Windows as well + if: runner.os != 'Windows' + run: | + cd test/scenarios/github-actions/ + ../../../direnv allow + ../../../direnv export gha >> "$GITHUB_ENV" + + - name: GitHub Actions Env Test Verification + # FIXME: make this work on Windows as well + if: runner.os != 'Windows' + run: | + [[ -z ${TEST_EXPORT_DIRENV_GITHUB_ACTIONS:-} ]] && echo "TEST_EXPORT_DIRENV_GITHUB_ACTIONS is unset or empty" >&2 && exit 1 + tee TEST_EXPORT_DIRENV_GITHUB_ACTIONS.got <<<"$TEST_EXPORT_DIRENV_GITHUB_ACTIONS" + echo "${GITHUB_SHA}"$'\n'"${GITHUB_RUN_ID}"$'\n'"${GITHUB_RUN_NUMBER}" | tee TEST_EXPORT_DIRENV_GITHUB_ACTIONS.want + diff -u TEST_EXPORT_DIRENV_GITHUB_ACTIONS.want TEST_EXPORT_DIRENV_GITHUB_ACTIONS.got diff --git a/test/scenarios/github-actions/.envrc b/test/scenarios/github-actions/.envrc new file mode 100644 index 000000000..205409b06 --- /dev/null +++ b/test/scenarios/github-actions/.envrc @@ -0,0 +1 @@ +export TEST_EXPORT_DIRENV_GITHUB_ACTIONS="${GITHUB_SHA:-MISSING_GITHUB_SHA}"$'\n'"${GITHUB_RUN_ID:MISSING_GITHUB_RUN_ID}"$'\n'"${GITHUB_RUN_NUMBER:-MISSING_GITHUB_RUN_NUMBER}"