@@ -2,233 +2,14 @@ import * as github from '@actions/github';
2
2
3
3
import {
4
4
buildCommitExec ,
5
- buildExec ,
6
5
buildGeneralExec ,
7
6
buildReportExec ,
8
7
buildUploadExec ,
9
8
} from './buildExec' ;
10
9
11
- import { version } from '../package.json' ;
12
10
13
11
const context = github . context ;
14
12
15
- test ( 'no arguments' , ( ) => {
16
- const { execArgs, failCi} = buildExec ( ) ;
17
-
18
- const args = [
19
- '-n' ,
20
- '' ,
21
- '-Q' ,
22
- `github-action-${ version } ` ,
23
- ] ;
24
- if ( context . eventName == 'pull_request' ) {
25
- args . push ( '-C' , `${ context . payload . pull_request . head . sha } ` ) ;
26
- }
27
-
28
- expect ( execArgs ) . toEqual ( args ) ;
29
- expect ( failCi ) . toBeFalsy ( ) ;
30
- } ) ;
31
-
32
- test ( 'all arguments' , ( ) => {
33
- const envs = {
34
- 'commit_parent' : '83231650328f11695dfb754ca0f540516f188d27' ,
35
- 'directory' : 'coverage/' ,
36
- 'dry_run' : 'true' ,
37
- 'env_vars' : 'OS,PYTHON' ,
38
- 'fail_ci_if_error' : 'true' ,
39
- 'file' : 'coverage.xml' ,
40
- 'files' : 'dir1/coverage.xml,dir2/coverage.xml' ,
41
- 'flags' : 'test,test2' ,
42
- 'functionalities' : 'network' ,
43
- 'full_report' : 'oldDir/oldReport.json' ,
44
- 'gcov' : 'true' ,
45
- 'gcov_args' : '-v' ,
46
- 'gcov_ignore' : '*.fake' ,
47
- 'gcov_include' : 'real_file' ,
48
- 'gcov_executable' : 'gcov2' ,
49
- 'move_coverage_to_trash' : 'true' ,
50
- 'name' : 'codecov' ,
51
- 'network_filter' : 'src/' ,
52
- 'network_prefix' : 'build/' ,
53
- 'override_branch' : 'thomasrockhu/test' ,
54
- 'override_build' : '1' ,
55
- 'override_commit' : '9caabca5474b49de74ef5667deabaf74cdacc244' ,
56
- 'override_pr' : '2' ,
57
- 'override_tag' : 'v1.2' ,
58
- 'root_dir' : 'root/' ,
59
- 'swift' : 'true' ,
60
- 'swift_project' : 'MyApp' ,
61
- 'slug' : 'fakeOwner/fakeRepo' ,
62
- 'token' : 'd3859757-ab80-4664-924d-aef22fa7557b' ,
63
- 'upstream_proxy' : 'https://codecov.example.com' ,
64
- 'url' : 'https://codecov.enterprise.com' ,
65
- 'verbose' : 't' ,
66
- 'xcode' : 'true' ,
67
- 'xcode_archive_path' : '/test.xcresult' ,
68
- 'xtra_args' : '--some --other --args' ,
69
- } ;
70
-
71
- for ( const env of Object . keys ( envs ) ) {
72
- process . env [ 'INPUT_' + env . toUpperCase ( ) ] = envs [ env ] ;
73
- }
74
-
75
- const { execArgs, failCi} = buildExec ( ) ;
76
- expect ( execArgs ) . toEqual ( [
77
- '-n' ,
78
- 'codecov' ,
79
- '-Q' ,
80
- `github-action-${ version } ` ,
81
- '-c' ,
82
- '-N' ,
83
- '83231650328f11695dfb754ca0f540516f188d27' ,
84
- '-d' ,
85
- '-e' ,
86
- 'OS,PYTHON' ,
87
- '-X' ,
88
- 'network' ,
89
- '-Z' ,
90
- '-f' ,
91
- 'coverage.xml' ,
92
- '-f' ,
93
- 'dir1/coverage.xml' ,
94
- '-f' ,
95
- 'dir2/coverage.xml' ,
96
- '--full' ,
97
- 'oldDir/oldReport.json' ,
98
- '-F' ,
99
- 'test' ,
100
- '-F' ,
101
- 'test2' ,
102
- '-g' ,
103
- '--ga' ,
104
- '-v' ,
105
- '--gi' ,
106
- '*.fake' ,
107
- '--gI' ,
108
- 'real_file' ,
109
- '--gx' ,
110
- 'gcov2' ,
111
- '-i' ,
112
- 'src/' ,
113
- '-k' ,
114
- 'build/' ,
115
- '-B' ,
116
- 'thomasrockhu/test' ,
117
- '-b' ,
118
- '1' ,
119
- '-C' ,
120
- '9caabca5474b49de74ef5667deabaf74cdacc244' ,
121
- '-P' ,
122
- '2' ,
123
- '-T' ,
124
- 'v1.2' ,
125
- '-R' ,
126
- 'root/' ,
127
- '-s' ,
128
- 'coverage/' ,
129
- '-r' ,
130
- 'fakeOwner/fakeRepo' ,
131
- '--xs' ,
132
- '--xsp' ,
133
- 'MyApp' ,
134
- '-U' ,
135
- 'https://codecov.example.com' ,
136
- '-u' ,
137
- 'https://codecov.enterprise.com' ,
138
- '-v' ,
139
- '--xc' ,
140
- '--xp' ,
141
- '/test.xcresult' ,
142
- '--some --other --args' ,
143
- ] ) ;
144
- expect ( failCi ) . toBeTruthy ( ) ;
145
-
146
- for ( const env of Object . keys ( envs ) ) {
147
- delete process . env [ 'INPUT_' + env . toUpperCase ( ) ] ;
148
- }
149
- } ) ;
150
-
151
- describe ( 'trim arguments after splitting them' , ( ) => {
152
- const baseExpectation = [
153
- '-n' ,
154
- expect . stringContaining ( '' ) ,
155
- '-Q' ,
156
- expect . stringContaining ( 'github-action' ) ,
157
- ] ;
158
-
159
- test ( 'files' , ( ) => {
160
- const envs = { files : './client-coverage.txt, ./lcov.info' } ;
161
-
162
- for ( const [ name , value ] of Object . entries ( envs ) ) {
163
- process . env [ 'INPUT_' + name . toUpperCase ( ) ] = value ;
164
- }
165
-
166
- const { execArgs} = buildExec ( ) ;
167
-
168
- expect ( execArgs ) . toEqual (
169
- expect . arrayContaining ( [
170
- ...baseExpectation ,
171
- '-f' ,
172
- './client-coverage.txt' ,
173
- '-f' ,
174
- './lcov.info' ,
175
- ] ) ,
176
- ) ;
177
-
178
- for ( const env of Object . keys ( envs ) ) {
179
- delete process . env [ 'INPUT_' + env . toUpperCase ( ) ] ;
180
- }
181
- } ) ;
182
-
183
- test ( 'flags' , ( ) => {
184
- const envs = { flags : 'ios, mobile' } ;
185
-
186
- for ( const [ name , value ] of Object . entries ( envs ) ) {
187
- process . env [ 'INPUT_' + name . toUpperCase ( ) ] = value ;
188
- }
189
-
190
- const { execArgs} = buildExec ( ) ;
191
-
192
- expect ( execArgs ) . toEqual (
193
- expect . arrayContaining ( [
194
- ...baseExpectation ,
195
- '-F' ,
196
- 'ios' ,
197
- '-F' ,
198
- 'mobile' ,
199
- ] ) ,
200
- ) ;
201
-
202
- for ( const env of Object . keys ( envs ) ) {
203
- delete process . env [ 'INPUT_' + env . toUpperCase ( ) ] ;
204
- }
205
- } ) ;
206
-
207
- test ( 'functionalities' , ( ) => {
208
- const envs = { functionalities : 'network, gcov' } ;
209
-
210
- for ( const [ name , value ] of Object . entries ( envs ) ) {
211
- process . env [ 'INPUT_' + name . toUpperCase ( ) ] = value ;
212
- }
213
-
214
- const { execArgs} = buildExec ( ) ;
215
-
216
- expect ( execArgs ) . toEqual (
217
- expect . arrayContaining ( [
218
- ...baseExpectation ,
219
- '-X' ,
220
- 'network' ,
221
- '-X' ,
222
- 'gcov' ,
223
- ] ) ,
224
- ) ;
225
-
226
- for ( const env of Object . keys ( envs ) ) {
227
- delete process . env [ 'INPUT_' + env . toUpperCase ( ) ] ;
228
- }
229
- } ) ;
230
- } ) ;
231
-
232
13
test ( 'general args' , ( ) => {
233
14
const envs = {
234
15
url : 'https://codecov.enterprise.com' ,
@@ -238,15 +19,15 @@ test('general args', () => {
238
19
process . env [ 'INPUT_' + env . toUpperCase ( ) ] = envs [ env ] ;
239
20
}
240
21
241
- const args = buildGeneralExec ( ) ;
22
+ const { args, verbose } = buildGeneralExec ( ) ;
242
23
243
24
expect ( args ) . toEqual (
244
25
expect . arrayContaining ( [
245
26
'--enterprise-url' ,
246
27
'https://codecov.enterprise.com' ,
247
28
'-v' ,
248
29
] ) ) ;
249
-
30
+ expect ( verbose ) . toBeTruthy ( ) ;
250
31
for ( const env of Object . keys ( envs ) ) {
251
32
delete process . env [ 'INPUT_' + env . toUpperCase ( ) ] ;
252
33
}
0 commit comments