Skip to content

Commit

Permalink
Add test for export gha
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mmlb committed Apr 1, 2022
1 parent f5cfc1a commit 364e07a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/go.yml
Expand Up @@ -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
1 change: 1 addition & 0 deletions 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}"

0 comments on commit 364e07a

Please sign in to comment.