Skip to content

Commit 839a1c3

Browse files
committed
Improve integration test to ensure the variables aren't empty on the next job
1 parent 3d2b7a9 commit 839a1c3

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

.github/workflows/run-integration-test.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ jobs:
2323
with:
2424
variables: |
2525
URL=https://github.com
26+
# Next step: verify that the variable has been saved in the ENV.
2627
- run: |
27-
echo "Exported variable URL=$URL"
28+
if [ -z "$URL" ]; then
29+
echo "Error: github-action-store-variable lib did not save 'URL' to ENV as expected. The library is not working as intended."
30+
exit 1
31+
fi
32+
echo "Exported variable URL is: $URL"
2833
env:
2934
URL: ${{ env.URL }}
35+
3036
run-integration-test2:
3137
runs-on: ubuntu-22.04
3238
needs: run-integration-test1
@@ -41,12 +47,22 @@ jobs:
4147
variables: |
4248
URL
4349
SECOND_URL=https://github.com/UnlyEd
50+
# Next step: verify that both URL and SECOND_URL were propagated.
4451
- run: |
45-
echo "Found from previous job URL=$URL"
46-
echo "Exported variable SECOND_URL=$SECOND_URL"
52+
if [ -z "$URL" ]; then
53+
echo "Error: github-action-store-variable lib did not propagate 'URL' to the environment as expected. The library is not working as intended."
54+
exit 1
55+
fi
56+
if [ -z "$SECOND_URL" ]; then
57+
echo "Error: github-action-store-variable lib did not save 'SECOND_URL' to ENV as expected. The library is not working as intended."
58+
exit 1
59+
fi
60+
echo "Found from previous job, URL is: $URL"
61+
echo "Exported variable SECOND_URL is: $SECOND_URL"
4762
env:
4863
URL: ${{ env.URL }}
4964
SECOND_URL: ${{ env.SECOND_URL }}
65+
5066
run-integration-test3:
5167
runs-on: ubuntu-22.04
5268
needs: run-integration-test2
@@ -61,9 +77,18 @@ jobs:
6177
variables: |
6278
URL
6379
SECOND_URL
80+
# Next step: verify that URL and SECOND_URL are available.
6481
- run: |
65-
echo "Found from previous job URL=$URL"
66-
echo "Found from previous job SECOND_URL=$SECOND_URL"
82+
if [ -z "$URL" ]; then
83+
echo "Error: github-action-store-variable lib did not propagate 'URL' to the environment as expected. The library is not working as intended."
84+
exit 1
85+
fi
86+
if [ -z "$SECOND_URL" ]; then
87+
echo "Error: github-action-store-variable lib did not propagate 'SECOND_URL' to the environment as expected. The library is not working as intended."
88+
exit 1
89+
fi
90+
echo "Found from previous job, URL is: $URL"
91+
echo "Found from previous job, SECOND_URL is: $SECOND_URL"
6792
env:
6893
URL: ${{ env.URL }}
6994
SECOND_URL: ${{ env.SECOND_URL }}
@@ -80,4 +105,4 @@ jobs:
80105
with:
81106
variables: |
82107
UNKNOWN_VAR
83-
failIfNotFound: false # Default is false
108+
failIfNotFound: false # Default is false, so missing UNKNOWN_VAR is allowed.

0 commit comments

Comments
 (0)