@@ -9,21 +9,26 @@ import { withTmpDir } from "./util";
9
9
10
10
setupTests ( test ) ;
11
11
12
+ function setupEnvironmentAndStub ( tmpDir : string ) {
13
+ setupActionsVars ( tmpDir , tmpDir ) ;
14
+
15
+ process . env [ "CODEQL_ACTION_ANALYSIS_KEY" ] = "analysis-key" ;
16
+ process . env [ "GITHUB_REF" ] = "refs/heads/main" ;
17
+ process . env [ "GITHUB_REPOSITORY" ] = "octocat/HelloWorld" ;
18
+ process . env [ "GITHUB_RUN_ATTEMPT" ] = "2" ;
19
+ process . env [ "GITHUB_RUN_ID" ] = "100" ;
20
+ process . env [ "GITHUB_SHA" ] = "a" . repeat ( 40 ) ;
21
+ process . env [ "ImageVersion" ] = "2023.05.19.1" ;
22
+ process . env [ "RUNNER_OS" ] = "macOS" ;
23
+ process . env [ "RUNNER_TEMP" ] = tmpDir ;
24
+
25
+ const getRequiredInput = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
26
+ getRequiredInput . withArgs ( "matrix" ) . resolves ( "input/matrix" ) ;
27
+ }
28
+
12
29
test ( "createStatusReportBase" , async ( t ) => {
13
30
await withTmpDir ( async ( tmpDir : string ) => {
14
- setupActionsVars ( tmpDir , tmpDir ) ;
15
-
16
- process . env [ "CODEQL_ACTION_ANALYSIS_KEY" ] = "analysis-key" ;
17
- process . env [ "GITHUB_REF" ] = "refs/heads/main" ;
18
- process . env [ "GITHUB_REPOSITORY" ] = "octocat/HelloWorld" ;
19
- process . env [ "GITHUB_RUN_ATTEMPT" ] = "2" ;
20
- process . env [ "GITHUB_RUN_ID" ] = "100" ;
21
- process . env [ "GITHUB_SHA" ] = "a" . repeat ( 40 ) ;
22
- process . env [ "ImageVersion" ] = "2023.05.19.1" ;
23
- process . env [ "RUNNER_OS" ] = "macOS" ;
24
-
25
- const getRequiredInput = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
26
- getRequiredInput . withArgs ( "matrix" ) . resolves ( "input/matrix" ) ;
31
+ setupEnvironmentAndStub ( tmpDir ) ;
27
32
28
33
const statusReport = await createStatusReportBase (
29
34
"init" ,
@@ -43,14 +48,14 @@ test("createStatusReportBase", async (t) => {
43
48
) ;
44
49
t . is ( statusReport . analysis_key , "analysis-key" ) ;
45
50
t . is ( statusReport . cause , "failure cause" ) ;
46
- t . is ( statusReport . commit_oid , process . env [ "GITHUB_SHA" ] ) ;
51
+ t . is ( statusReport . commit_oid , process . env [ "GITHUB_SHA" ] ! ) ;
47
52
t . is ( statusReport . exception , "exception stack trace" ) ;
48
53
t . is ( statusReport . job_name , process . env [ "GITHUB_JOB" ] || "" ) ;
49
54
t . is ( typeof statusReport . job_run_uuid , "string" ) ;
50
- t . is ( statusReport . ref , process . env [ "GITHUB_REF" ] ) ;
55
+ t . is ( statusReport . ref , process . env [ "GITHUB_REF" ] ! ) ;
51
56
t . is ( statusReport . runner_available_disk_space_bytes , 100 ) ;
52
57
t . is ( statusReport . runner_image_version , process . env [ "ImageVersion" ] ) ;
53
- t . is ( statusReport . runner_os , process . env [ "RUNNER_OS" ] ) ;
58
+ t . is ( statusReport . runner_os , process . env [ "RUNNER_OS" ] ! ) ;
54
59
t . is ( statusReport . started_at , process . env [ EnvVar . WORKFLOW_STARTED_AT ] ! ) ;
55
60
t . is ( statusReport . status , "failure" ) ;
56
61
t . is ( statusReport . workflow_name , process . env [ "GITHUB_WORKFLOW" ] || "" ) ;
@@ -61,20 +66,7 @@ test("createStatusReportBase", async (t) => {
61
66
62
67
test ( "createStatusReportBase_firstParty" , async ( t ) => {
63
68
await withTmpDir ( async ( tmpDir : string ) => {
64
- setupActionsVars ( tmpDir , tmpDir ) ;
65
-
66
- process . env [ "CODEQL_ACTION_ANALYSIS_KEY" ] = "analysis-key" ;
67
- process . env [ "GITHUB_REF" ] = "refs/heads/main" ;
68
- process . env [ "GITHUB_REPOSITORY" ] = "octocat/HelloWorld" ;
69
- process . env [ "GITHUB_RUN_ATTEMPT" ] = "2" ;
70
- process . env [ "GITHUB_RUN_ID" ] = "100" ;
71
- process . env [ "GITHUB_SHA" ] = "a" . repeat ( 40 ) ;
72
- process . env [ "ImageVersion" ] = "2023.05.19.1" ;
73
- process . env [ "RUNNER_OS" ] = "macOS" ;
74
- process . env [ "RUNNER_TEMP" ] = tmpDir ;
75
-
76
- const getRequiredInput = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
77
- getRequiredInput . withArgs ( "matrix" ) . resolves ( "input/matrix" ) ;
69
+ setupEnvironmentAndStub ( tmpDir ) ;
78
70
79
71
t . is (
80
72
(
@@ -104,7 +96,7 @@ test("createStatusReportBase_firstParty", async (t) => {
104
96
true ,
105
97
) ;
106
98
107
- process . env [ "CODEQL_INIT_ACTION_HAS_RUN " ] = "foobar" ;
99
+ process . env [ "CODEQL_ACTION_INIT_HAS_RUN " ] = "foobar" ;
108
100
t . is (
109
101
(
110
102
await createStatusReportBase (
@@ -133,7 +125,7 @@ test("createStatusReportBase_firstParty", async (t) => {
133
125
true ,
134
126
) ;
135
127
136
- process . env [ "CODEQL_INIT_ACTION_HAS_RUN " ] = "true" ;
128
+ process . env [ "CODEQL_ACTION_INIT_HAS_RUN " ] = "true" ;
137
129
t . is (
138
130
(
139
131
await createStatusReportBase (
0 commit comments