@@ -11,21 +11,99 @@ jobs:
1111 runs-on : ubuntu-latest
1212 steps :
1313 - uses : actions/checkout@v4
14- - name : Set Node.js 20.x
14+ - name : Set up Node.js
1515 uses : actions/setup-node@v4
1616 with :
17- node-version : 20.x
17+ node-version : 20
1818 cache : npm
19- - run : |
19+ - name : Build and test
20+ run : |
2021 npm -v
2122 node -v
22- npm install
23+ npm clean- install
2324 npm run all
24- test : # make sure the action works on a clean machine without building
25+
26+
27+ # Integration test for successful validation of wrappers
28+ test-validation-success :
29+ name : ' Test: Validation success'
2530 runs-on : ubuntu-latest
2631 steps :
2732 - uses : actions/checkout@v4
28- - uses : ./
33+
34+ - name : Set up Node.js
35+ uses : actions/setup-node@v4
36+ with :
37+ node-version : 20
38+
39+ - name : Build action (pull request)
40+ # Pull requests are not expected to update `dist/index.js` themselves; therefore build `dist/index.js`
41+ # here before running integration test
42+ if : github.event_name == 'pull_request'
43+ run : |
44+ npm clean-install
45+ npm run build
46+
47+ - name : Run wrapper-validation-action
48+ id : action-test
49+ uses : ./
2950 with :
3051 # to allow the invalid wrapper jar present in test data
3152 allow-checksums : e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
53+
54+ - name : Check outcome
55+ env :
56+ # Evaluate workflow expressions here as env variable values instead of inside shell script
57+ # below to not accidentally inject code into shell script or break its syntax
58+ FAILED_WRAPPERS : ${{ steps.action-test.outputs.failed-wrapper }}
59+ FAILED_WRAPPERS_MATCHES : ${{ steps.action-test.outputs.failed-wrapper == '' }}
60+ run : |
61+ if [ "$FAILED_WRAPPERS_MATCHES" != "true" ] ; then
62+ echo "'outputs.failed-wrapper' has unexpected content: $FAILED_WRAPPERS"
63+ exit 1
64+ fi
65+
66+
67+ # Integration test for failing validation of wrappers
68+ test-validation-error :
69+ name : ' Test: Validation error'
70+ runs-on : ubuntu-latest
71+ steps :
72+ - uses : actions/checkout@v4
73+
74+ - name : Set up Node.js
75+ uses : actions/setup-node@v4
76+ with :
77+ node-version : 20
78+
79+ - name : Build action (pull request)
80+ # Pull requests are not expected to update `dist/index.js` themselves; therefore build `dist/index.js`
81+ # here before running integration test
82+ if : github.event_name == 'pull_request'
83+ run : |
84+ npm clean-install
85+ npm run build
86+
87+ - name : Run wrapper-validation-action
88+ id : action-test
89+ uses : ./
90+ # Expected to fail; validated below
91+ continue-on-error : true
92+
93+ - name : Check outcome
94+ env :
95+ # Evaluate workflow expressions here as env variable values instead of inside shell script
96+ # below to not accidentally inject code into shell script or break its syntax
97+ VALIDATION_FAILED : ${{ steps.action-test.outcome == 'failure' }}
98+ FAILED_WRAPPERS : ${{ steps.action-test.outputs.failed-wrapper }}
99+ FAILED_WRAPPERS_MATCHES : ${{ steps.action-test.outputs.failed-wrapper == '__tests__/data/invalid/gradle-wrapper.jar|__tests__/data/invalid/gradlе-wrapper.jar' }}
100+ run : |
101+ if [ "$VALIDATION_FAILED" != "true" ] ; then
102+ echo "Expected validation to fail, but it didn't"
103+ exit 1
104+ fi
105+
106+ if [ "$FAILED_WRAPPERS_MATCHES" != "true" ] ; then
107+ echo "'outputs.failed-wrapper' has unexpected content: $FAILED_WRAPPERS"
108+ exit 1
109+ fi
0 commit comments