@@ -15,6 +15,7 @@ import { createStubCodeQL } from "./codeql";
1515import { UserConfig } from "./config/db-config" ;
1616import * as file from "./config/file" ;
1717import * as configUtils from "./config-utils" ;
18+ import { ActionsEnvVars } from "./environment" ;
1819import * as errorMessages from "./error-messages" ;
1920import { Feature } from "./feature-flags" ;
2021import { RepositoryProperties } from "./feature-flags/properties" ;
@@ -42,6 +43,7 @@ import {
4243 SAMPLE_DOTCOM_API_DETAILS ,
4344 AssertableTarget ,
4445 RecordingLogger ,
46+ getTestEnv ,
4547} from "./testing-utils" ;
4648import {
4749 GitHubVariant ,
@@ -151,9 +153,11 @@ function mockListLanguages(languages: string[]) {
151153test . serial ( "load empty config" , async ( t ) => {
152154 return await withTmpDir ( async ( tempDir ) => {
153155 const logger = new RecordingLogger ( ) ;
156+ const state = initAllState ( { logger } ) ;
157+
154158 const languages = "javascript,python" ;
155159
156- setupActionsVars ( tempDir , tempDir ) ;
160+ setupActionsVars ( tempDir , tempDir , { } , state . env ) ;
157161
158162 const codeql = createStubCodeQL ( {
159163 async resolveLanguages ( ) {
@@ -166,7 +170,6 @@ test.serial("load empty config", async (t) => {
166170 } ,
167171 } ) ;
168172
169- const state = initAllState ( { logger } ) ;
170173 const config = await configUtils . initConfig (
171174 state ,
172175 createTestInitConfigInputs ( {
@@ -197,9 +200,10 @@ test.serial("load empty config", async (t) => {
197200test . serial ( "load code quality config" , async ( t ) => {
198201 return await withTmpDir ( async ( tempDir ) => {
199202 const logger = new RecordingLogger ( ) ;
203+ const state = initAllState ( { logger } ) ;
200204 const languages = "actions" ;
201205
202- setupActionsVars ( tempDir , tempDir ) ;
206+ setupActionsVars ( tempDir , tempDir , { } , state . env ) ;
203207
204208 const codeql = createStubCodeQL ( {
205209 async resolveLanguages ( ) {
@@ -211,7 +215,6 @@ test.serial("load code quality config", async (t) => {
211215 } ,
212216 } ) ;
213217
214- const state = initAllState ( { logger } ) ;
215218 const config = await configUtils . initConfig (
216219 state ,
217220 createTestInitConfigInputs ( {
@@ -253,9 +256,10 @@ test.serial(
253256 async ( t ) => {
254257 return await withTmpDir ( async ( tempDir ) => {
255258 const logger = new RecordingLogger ( ) ;
259+ const state = initAllState ( { logger } ) ;
256260 const languages = "javascript" ;
257261
258- setupActionsVars ( tempDir , tempDir ) ;
262+ setupActionsVars ( tempDir , tempDir , { } , state . env ) ;
259263
260264 const codeql = createStubCodeQL ( {
261265 async resolveLanguages ( ) {
@@ -291,7 +295,6 @@ test.serial(
291295 repositoryProperties,
292296 } ) ;
293297
294- const state = initAllState ( { logger } ) ;
295298 await t . notThrowsAsync ( async ( ) => {
296299 const config = await configUtils . initConfig (
297300 state ,
@@ -316,6 +319,8 @@ test.serial(
316319test . serial ( "loading a saved config produces the same config" , async ( t ) => {
317320 return await withTmpDir ( async ( tempDir ) => {
318321 const logger = new RecordingLogger ( ) ;
322+ const state = initAllState ( { logger } ) ;
323+ setupActionsVars ( tempDir , tempDir , { } , state . env ) ;
319324
320325 const codeql = createStubCodeQL ( {
321326 async resolveLanguages ( ) {
@@ -334,7 +339,6 @@ test.serial("loading a saved config produces the same config", async (t) => {
334339 // Sanity check that getConfig returns undefined before we have called initConfig
335340 t . deepEqual ( await configUtils . getConfig ( tempDir , logger ) , undefined ) ;
336341
337- const state = initAllState ( { logger } ) ;
338342 const config1 = await configUtils . initConfig (
339343 state ,
340344 createTestInitConfigInputs ( {
@@ -364,6 +368,8 @@ test.serial("loading a saved config produces the same config", async (t) => {
364368test . serial ( "loading config with version mismatch throws" , async ( t ) => {
365369 return await withTmpDir ( async ( tempDir ) => {
366370 const logger = new RecordingLogger ( ) ;
371+ const state = initAllState ( { logger } ) ;
372+ setupActionsVars ( tempDir , tempDir , { } , state . env ) ;
367373
368374 const codeql = createStubCodeQL ( {
369375 async resolveLanguages ( ) {
@@ -387,7 +393,6 @@ test.serial("loading config with version mismatch throws", async (t) => {
387393 . stub ( actionsUtil , "getActionVersion" )
388394 . returns ( "does-not-exist" ) ;
389395
390- const state = initAllState ( { logger } ) ;
391396 const config = await configUtils . initConfig (
392397 state ,
393398 createTestInitConfigInputs ( {
@@ -497,7 +502,8 @@ const otherConfigFileContents = `
497502
498503test . serial ( "load non-empty input" , async ( t ) => {
499504 return await withTmpDir ( async ( tempDir ) => {
500- setupActionsVars ( tempDir , tempDir ) ;
505+ const state = initAllState ( ) ;
506+ setupActionsVars ( tempDir , tempDir , { } , state . env ) ;
501507
502508 const codeql = createStubCodeQL ( {
503509 async resolveLanguages ( ) {
@@ -538,7 +544,6 @@ test.serial("load non-empty input", async (t) => {
538544 const languagesInput = "javascript" ;
539545 const configFilePath = createConfigFile ( otherConfigFileContents , tempDir ) ;
540546
541- const state = initAllState ( ) ;
542547 const actualConfig = await configUtils . initConfig (
543548 state ,
544549 createTestInitConfigInputs ( {
@@ -657,7 +662,9 @@ test.serial("API client used when reading remote config", async (t) => {
657662 const configFile = "octo-org/codeql-config/config.yaml@main" ;
658663 const languagesInput = "javascript" ;
659664
660- const state = initAllState ( ) ;
665+ const state = initAllState ( {
666+ env : getTestEnv ( { [ ActionsEnvVars . RUNNER_TEMP ] : tempDir } ) ,
667+ } ) ;
661668 await configUtils . initConfig (
662669 state ,
663670 createTestInitConfigInputs ( {
0 commit comments