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 Mar 29, 2022
1 parent 752c8e1 commit a75d22d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/go.yml
Expand Up @@ -41,3 +41,18 @@ jobs:
GO111MODULE: on
run: make test-stdlib test-bash

- name: GitHub Actions Env Test Setup
id: test-gha-setup
run: |
topdir=$PWD
cd test/scenarios/github-actions/
export RANDOM1=$RANDOM RANDOM2=$RANDOM RANDOM3=$RANDOM RANDOM4=$RANDOM
"$topdir/direnv" allow
"$topdir/direnv" export gha >> "$GITHUB_ENV"
- name: GitHub Actions Env Test Verification
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 a75d22d

Please sign in to comment.