@@ -15,7 +15,9 @@ import { parseRepositoryNwo } from "./repository";
1515import {
1616 createFeatures ,
1717 createTestConfig ,
18+ DEFAULT_ACTIONS_VARS ,
1819 makeVersionInfo ,
20+ setupActionsVars ,
1921 setupTests ,
2022} from "./testing-utils" ;
2123import * as uploadLib from "./upload-lib" ;
@@ -28,8 +30,7 @@ setupTests(test);
2830
2931test . serial ( "init-post action with debug mode off" , async ( t ) => {
3032 return await util . withTmpDir ( async ( tmpDir ) => {
31- process . env [ "GITHUB_REPOSITORY" ] = "github/codeql-action-fake-repository" ;
32- process . env [ "RUNNER_TEMP" ] = tmpDir ;
33+ setupActionsVars ( tmpDir , tmpDir ) ;
3334
3435 const gitHubVersion : util . GitHubVersion = {
3536 type : util . GitHubVariant . DOTCOM ,
@@ -62,8 +63,7 @@ test.serial("init-post action with debug mode off", async (t) => {
6263
6364test . serial ( "init-post action with debug mode on" , async ( t ) => {
6465 return await util . withTmpDir ( async ( tmpDir ) => {
65- process . env [ "GITHUB_REPOSITORY" ] = "github/codeql-action-fake-repository" ;
66- process . env [ "RUNNER_TEMP" ] = tmpDir ;
66+ setupActionsVars ( tmpDir , tmpDir ) ;
6767
6868 const uploadAllAvailableDebugArtifactsSpy = sinon . spy ( ) ;
6969 const printDebugLogsSpy = sinon . spy ( ) ;
@@ -343,11 +343,7 @@ test.serial(
343343 "saves overlay status when overlay-base analysis did not complete successfully" ,
344344 async ( t ) => {
345345 return await util . withTmpDir ( async ( tmpDir ) => {
346- process . env [ "GITHUB_REPOSITORY" ] = "github/codeql-action-fake-repository" ;
347- process . env [ "GITHUB_RUN_ID" ] = "12345" ;
348- process . env [ "GITHUB_RUN_ATTEMPT" ] = "1" ;
349- process . env [ "GITHUB_JOB" ] = "analyze" ;
350- process . env [ "RUNNER_TEMP" ] = tmpDir ;
346+ setupActionsVars ( tmpDir , tmpDir ) ;
351347 // Ensure analyze did not complete successfully.
352348 delete process . env [ EnvVar . ANALYZE_DID_COMPLETE_SUCCESSFULLY ] ;
353349
@@ -403,9 +399,9 @@ test.serial(
403399 builtOverlayBaseDatabase : false ,
404400 job : {
405401 checkRunId : undefined ,
406- workflowRunId : 12345 ,
407- workflowRunAttempt : 1 ,
408- name : "analyze" ,
402+ workflowRunId : Number ( DEFAULT_ACTIONS_VARS . GITHUB_RUN_ID ) ,
403+ workflowRunAttempt : Number ( DEFAULT_ACTIONS_VARS . GITHUB_RUN_ATTEMPT ) ,
404+ name : DEFAULT_ACTIONS_VARS . GITHUB_JOB ,
409405 } ,
410406 } ,
411407 "fourth arg should be the overlay status recording an unsuccessful build attempt with job details" ,
@@ -418,8 +414,7 @@ test.serial(
418414 "does not save overlay status when OverlayAnalysisStatusSave feature flag is disabled" ,
419415 async ( t ) => {
420416 return await util . withTmpDir ( async ( tmpDir ) => {
421- process . env [ "GITHUB_REPOSITORY" ] = "github/codeql-action-fake-repository" ;
422- process . env [ "RUNNER_TEMP" ] = tmpDir ;
417+ setupActionsVars ( tmpDir , tmpDir ) ;
423418 // Ensure analyze did not complete successfully.
424419 delete process . env [ EnvVar . ANALYZE_DID_COMPLETE_SUCCESSFULLY ] ;
425420
@@ -456,8 +451,7 @@ test.serial(
456451
457452test . serial ( "does not save overlay status when build successful" , async ( t ) => {
458453 return await util . withTmpDir ( async ( tmpDir ) => {
459- process . env [ "GITHUB_REPOSITORY" ] = "github/codeql-action-fake-repository" ;
460- process . env [ "RUNNER_TEMP" ] = tmpDir ;
454+ setupActionsVars ( tmpDir , tmpDir ) ;
461455 // Mark analyze as having completed successfully.
462456 process . env [ EnvVar . ANALYZE_DID_COMPLETE_SUCCESSFULLY ] = "true" ;
463457
@@ -495,8 +489,7 @@ test.serial(
495489 "does not save overlay status when overlay not enabled" ,
496490 async ( t ) => {
497491 return await util . withTmpDir ( async ( tmpDir ) => {
498- process . env [ "GITHUB_REPOSITORY" ] = "github/codeql-action-fake-repository" ;
499- process . env [ "RUNNER_TEMP" ] = tmpDir ;
492+ setupActionsVars ( tmpDir , tmpDir ) ;
500493 delete process . env [ EnvVar . ANALYZE_DID_COMPLETE_SUCCESSFULLY ] ;
501494
502495 sinon . stub ( util , "checkDiskUsage" ) . resolves ( {
@@ -582,9 +575,8 @@ async function testFailedSarifUpload(
582575 config . dbLocation = "path/to/database" ;
583576 }
584577 process . env [ "GITHUB_JOB" ] = "analyze" ;
585- process . env [ "GITHUB_REPOSITORY" ] = "github/codeql-action-fake-repository" ;
586- process . env [ "GITHUB_WORKSPACE" ] =
587- "/home/runner/work/codeql-action/codeql-action" ;
578+ process . env [ "GITHUB_REPOSITORY" ] = DEFAULT_ACTIONS_VARS . GITHUB_REPOSITORY ;
579+ process . env [ "GITHUB_WORKSPACE" ] = "/tmp" ;
588580 sinon
589581 . stub ( actionsUtil , "getRequiredInput" )
590582 . withArgs ( "matrix" )
0 commit comments