8
8
9
9
jobs :
10
10
test-return :
11
+ name : ' Integration test: return'
11
12
runs-on : ubuntu-latest
12
13
steps :
13
14
- uses : actions/checkout@v3
@@ -18,26 +19,34 @@ jobs:
18
19
result-encoding : string
19
20
input-value : output
20
21
- run : |
21
- if [[ "${{steps.output-set.outputs.result}}" != "output" ]]; then
22
+ echo "- Validating output is produced"
23
+ expected="output"
24
+ if [[ "${{steps.output-set.outputs.result}}" != "$expected" ]]; then
25
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.output-set.outputs.result}}"
22
26
exit 1
23
27
fi
28
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
24
29
25
30
test-relative-require :
31
+ name : ' Integration test: relative-path require'
26
32
runs-on : ubuntu-latest
27
33
steps :
28
34
- uses : actions/checkout@v3
29
- - id : output-set
35
+ - id : relative-require
30
36
uses : ./
31
37
with :
32
38
script : return require('./package.json').name
33
39
result-encoding : string
34
- input-value : output
35
40
- run : |
36
- if [[ "${{steps.output-set.outputs.result}}" != "github-script" ]]; then
41
+ echo "- Validating relative require output"
42
+ if [[ "${{steps.relative-require.outputs.result}}" != "github-script" ]]; then
43
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.relative-require.outputs.result}}"
37
44
exit 1
38
45
fi
46
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
39
47
40
48
test-npm-require :
49
+ name : ' Integration test: npm package require'
41
50
runs-on : ubuntu-latest
42
51
steps :
43
52
- uses : actions/checkout@v3
@@ -47,13 +56,196 @@ jobs:
47
56
key : ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
48
57
restore-keys : ${{runner.os}}-npm-
49
58
- run : npm ci
50
- - id : output-set
59
+ - id : npm-require
51
60
uses : ./
52
61
with :
53
62
script : return require('@actions/core/package.json').name
54
63
result-encoding : string
55
- input-value : output
56
64
- run : |
57
- if [[ "${{steps.output-set.outputs.result}}" != "@actions/core" ]]; then
65
+ echo "- Validating npm require output"
66
+ expected="@actions/core"
67
+ if [[ "${{steps.npm-require.outputs.result}}" != "$expected" ]]; then
68
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.npm-require.outputs.result}}"
69
+ exit 1
70
+ fi
71
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
72
+
73
+ test-previews :
74
+ name : ' Integration test: previews option'
75
+ runs-on : ubuntu-latest
76
+ steps :
77
+ - uses : actions/checkout@v3
78
+ - uses : actions/cache@v3
79
+ with :
80
+ path : ~/.npm
81
+ key : ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
82
+ restore-keys : ${{runner.os}}-npm-
83
+ - run : npm ci
84
+ - id : previews-default
85
+ name : Default previews not set
86
+ uses : ./
87
+ with :
88
+ script : |
89
+ const endpoint = github.request.endpoint
90
+ return endpoint({}).headers.accept
91
+ result-encoding : string
92
+ - id : previews-set-single
93
+ name : Previews set to a single value
94
+ uses : ./
95
+ with :
96
+ previews : foo
97
+ script : |
98
+ const endpoint = github.request.endpoint
99
+ return endpoint({}).headers.accept
100
+ result-encoding : string
101
+ - id : previews-set-multiple
102
+ name : Previews set to comma-separated list
103
+ uses : ./
104
+ with :
105
+ previews : foo,bar,baz
106
+ script : |
107
+ const endpoint = github.request.endpoint
108
+ return endpoint({}).headers.accept
109
+ result-encoding : string
110
+ - run : |
111
+ echo "- Validating previews default"
112
+ expected="application/vnd.github.v3+json"
113
+ if [[ "${{steps.previews-default.outputs.result}}" != $expected ]]; then
114
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-default.outputs.result}}"
115
+ exit 1
116
+ fi
117
+ echo "- Validating previews set to a single value"
118
+ expected="application/vnd.github.foo-preview+json"
119
+ if [[ "${{steps.previews-set-single.outputs.result}}" != $expected ]]; then
120
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-set-single.outputs.result}}"
121
+ exit 1
122
+ fi
123
+ echo "- Validating previews set to multiple values"
124
+ expected="application/vnd.github.foo-preview+json,application/vnd.github.bar-preview+json,application/vnd.github.baz-preview+json"
125
+ if [[ "${{steps.previews-set-multiple.outputs.result}}" != $expected ]]; then
126
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-set-multiple.outputs.result}}"
127
+ exit 1
128
+ fi
129
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
130
+
131
+ test-user-agent :
132
+ name : ' Integration test: user-agent option'
133
+ runs-on : ubuntu-latest
134
+ steps :
135
+ - uses : actions/checkout@v3
136
+ - uses : actions/cache@v3
137
+ with :
138
+ path : ~/.npm
139
+ key : ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
140
+ restore-keys : ${{runner.os}}-npm-
141
+ - run : npm ci
142
+ - id : user-agent-default
143
+ name : Default user-agent not set
144
+ uses : ./
145
+ with :
146
+ script : |
147
+ const endpoint = github.request.endpoint
148
+ return endpoint({}).headers['user-agent']
149
+ result-encoding : string
150
+ - id : user-agent-set
151
+ name : User-agent set
152
+ uses : ./
153
+ with :
154
+ user-agent : foobar
155
+ script : |
156
+ const endpoint = github.request.endpoint
157
+ return endpoint({}).headers['user-agent']
158
+ result-encoding : string
159
+ - id : user-agent-empty
160
+ name : User-agent set to an empty string
161
+ uses : ./
162
+ with :
163
+ user-agent : ' '
164
+ script : |
165
+ const endpoint = github.request.endpoint
166
+ return endpoint({}).headers['user-agent']
167
+ result-encoding : string
168
+ - run : |
169
+ echo "- Validating user-agent default"
170
+ expected="actions/github-script octokit-core.js/"
171
+ if [[ "${{steps.user-agent-default.outputs.result}}" != "$expected"* ]]; then
172
+ echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-default.outputs.result}}"
173
+ exit 1
174
+ fi
175
+ echo "- Validating user-agent set to a value"
176
+ expected="foobar octokit-core.js/"
177
+ if [[ "${{steps.user-agent-set.outputs.result}}" != "$expected"* ]]; then
178
+ echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-set.outputs.result}}"
179
+ exit 1
180
+ fi
181
+ echo "- Validating user-agent set to an empty string"
182
+ expected="octokit-core.js/"
183
+ if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
184
+ echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
185
+ exit 1
186
+ fi
187
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
188
+
189
+ test-debug :
190
+ name : ' Integration test: debug option'
191
+ runs-on : ubuntu-latest
192
+ steps :
193
+ - uses : actions/checkout@v3
194
+ - uses : actions/cache@v3
195
+ with :
196
+ path : ~/.npm
197
+ key : ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
198
+ restore-keys : ${{runner.os}}-npm-
199
+ - run : npm ci
200
+ - id : debug-default
201
+ name : Default debug not set
202
+ uses : ./
203
+ with :
204
+ script : |
205
+ const log = github.log
206
+ return {
207
+ debug: log.debug === console.debug,
208
+ info: log.info === console.info
209
+ }
210
+ - id : debug-true
211
+ name : Debug set to true
212
+ uses : ./
213
+ with :
214
+ debug : true
215
+ script : |
216
+ const log = github.log
217
+ return {
218
+ debug: log.debug === console.debug,
219
+ info: log.info === console.info
220
+ }
221
+ - id : debug-false
222
+ name : Debug set to false
223
+ uses : ./
224
+ with :
225
+ debug : false
226
+ script : |
227
+ const log = github.log
228
+ return {
229
+ debug: log.debug === console.debug,
230
+ info: log.info === console.info
231
+ }
232
+ - run : |
233
+ echo "- Validating debug default"
234
+ expected='{debug:false,info:false}'
235
+ if [[ "${{steps.debug-default.outputs.result}}" != "$expected" ]]; then
236
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-default.outputs.result}}"
237
+ exit 1
238
+ fi
239
+ echo "- Validating debug set to true"
240
+ expected='{debug:true,info:true}'
241
+ if [[ "${{steps.debug-true.outputs.result}}" != "$expected" ]]; then
242
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-true.outputs.result}}"
243
+ exit 1
244
+ fi
245
+ echo "- Validating debug set to false"
246
+ expected='{debug:false,info:false}'
247
+ if [[ "${{steps.debug-false.outputs.result}}" != "$expected" ]]; then
248
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-false.outputs.result}}"
58
249
exit 1
59
250
fi
251
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
0 commit comments