@@ -2,233 +2,14 @@ import * as github from '@actions/github';
22
33import {
44 buildCommitExec ,
5- buildExec ,
65 buildGeneralExec ,
76 buildReportExec ,
87 buildUploadExec ,
98} from './buildExec' ;
109
11- import { version } from '../package.json' ;
1210
1311const context = github . context ;
1412
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-
23213test ( 'general args' , ( ) => {
23314 const envs = {
23415 url : 'https://codecov.enterprise.com' ,
@@ -238,15 +19,15 @@ test('general args', () => {
23819 process . env [ 'INPUT_' + env . toUpperCase ( ) ] = envs [ env ] ;
23920 }
24021
241- const args = buildGeneralExec ( ) ;
22+ const { args, verbose } = buildGeneralExec ( ) ;
24223
24324 expect ( args ) . toEqual (
24425 expect . arrayContaining ( [
24526 '--enterprise-url' ,
24627 'https://codecov.enterprise.com' ,
24728 '-v' ,
24829 ] ) ) ;
249-
30+ expect ( verbose ) . toBeTruthy ( ) ;
25031 for ( const env of Object . keys ( envs ) ) {
25132 delete process . env [ 'INPUT_' + env . toUpperCase ( ) ] ;
25233 }
0 commit comments