| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | 1 | import pkg from "./package.json" with { type: "json" }; | |
| 2 | 2 | ||
| 3 | 3 | globalThis.__CODEQL_ACTION_VERSION__ = pkg.version; | |
| 4 | + globalThis.__CODEQL_ACTION_TEST_ENV__ = "unit-test"; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,7 +78,7 @@ const UPLOAD_LIB_SRC = "./src/upload-lib"; | |||
| 78 | 78 | * | |
| 79 | 79 | * The virtual module additionally re-exports `upload-lib` under the `uploadLib` namespace so that | |
| 80 | 80 | * external consumers can access it via the small `lib/upload-lib.js` stub emitted below. | |
| 81 | - * | ||
| 81 | + * | ||
| 82 | 82 | * A tiny stub file is emitted for each Action entrypoint, and one for `upload-lib`. Each stub | |
| 83 | 83 | * imports the shared bundle and calls/re-exports from the respective entry point. | |
| 84 | 84 | * | |
@@ -212,6 +212,7 @@ const context = await esbuild.context({ | |||
| 212 | 212 | target: ["node20"], | |
| 213 | 213 | define: { | |
| 214 | 214 | __CODEQL_ACTION_VERSION__: JSON.stringify(pkg.version), | |
| 215 | + __CODEQL_ACTION_TEST_ENV__: JSON.stringify(""), | ||
| 215 | 216 | }, | |
| 216 | 217 | metafile: true, | |
| 217 | 218 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -140,6 +140,17 @@ export default [ | |||
| 140 | 140 | "no-async-foreach/no-async-foreach": "error", | |
| 141 | 141 | "no-sequences": "error", | |
| 142 | 142 | "no-shadow": "off", | |
| 143 | + | ||
| 144 | + // A basic check that we don't use `exportVariable` from `@actions/core`. | ||
| 145 | + "no-restricted-syntax": [ | ||
| 146 | + "error", | ||
| 147 | + { | ||
| 148 | + selector: "MemberExpression[property.name='exportVariable']", | ||
| 149 | + message: | ||
| 150 | + "Use the `export` method of an `Env` instance or `exportEnvVar` from `environment.ts` instead.", | ||
| 151 | + }, | ||
| 152 | + ], | ||
| 153 | + | ||
| 143 | 154 | // This is overly restrictive with unsetting `EnvVar`s | |
| 144 | 155 | "@typescript-eslint/no-dynamic-delete": "off", | |
| 145 | 156 | "@typescript-eslint/no-shadow": "error", | |
@@ -157,6 +168,15 @@ export default [ | |||
| 157 | 168 | ], | |
| 158 | 169 | }, | |
| 159 | 170 | }, | |
| 171 | + { | ||
| 172 | + files: ["src/environment.ts"], | ||
| 173 | + | ||
| 174 | + // We allow `exportVariable` from `@actions/core` to be used in this file | ||
| 175 | + // since it defines the wrapper around it that other modules use. | ||
| 176 | + rules: { | ||
| 177 | + "no-restricted-syntax": "off", | ||
| 178 | + }, | ||
| 179 | + }, | ||
| 160 | 180 | { | |
| 161 | 181 | files: ["**/*.ts", "**/*.js"], | |
| 162 | 182 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,8 @@ predicate isSafeForDefaultSetup(string envVar) { | |||
| 23 | 23 | "GITHUB_BASE_REF", "GITHUB_EVENT_NAME", "GITHUB_JOB", "GITHUB_RUN_ATTEMPT", "GITHUB_RUN_ID", | |
| 24 | 24 | "GITHUB_SHA", "GITHUB_REPOSITORY", "GITHUB_SERVER_URL", "GITHUB_TOKEN", "GITHUB_WORKFLOW", | |
| 25 | 25 | "GITHUB_WORKSPACE", "GOFLAGS", "ImageVersion", "JAVA_TOOL_OPTIONS", "RUNNER_ARCH", | |
| 26 | - "RUNNER_ENVIRONMENT", "RUNNER_NAME", "RUNNER_OS", "RUNNER_TEMP", "RUNNER_TOOL_CACHE" | ||
| 26 | + "RUNNER_ENVIRONMENT", "RUNNER_NAME", "RUNNER_OS", "RUNNER_TEMP", "RUNNER_TOOL_CACHE", | ||
| 27 | + "NODE_ENV" | ||
| 27 | 28 | ] | |
| 28 | 29 | } | |
| 29 | 30 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,6 @@ declare const __CODEQL_ACTION_VERSION__: string; | |||
| 30 | 30 | export interface ActionsEnv { | |
| 31 | 31 | getRequiredInput: (name: string) => string; | |
| 32 | 32 | getOptionalInput: (name: string) => string | undefined; | |
| 33 | - exportVariable: (name: string, value: string) => void; | ||
| 34 | 33 | } | |
| 35 | 34 | ||
| 36 | 35 | /** | |
@@ -40,7 +39,6 @@ export function getActionsEnv(): ActionsEnv { | |||
| 40 | 39 | return { | |
| 41 | 40 | getRequiredInput, | |
| 42 | 41 | getOptionalInput, | |
| 43 | - exportVariable: core.exportVariable, | ||
| 44 | 42 | }; | |
| 45 | 43 | } | |
| 46 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -214,9 +214,10 @@ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) { | |||
| 214 | 214 | ||
| 215 | 215 | async function run({ | |
| 216 | 216 | startedAt, | |
| 217 | + env, | ||
| 217 | 218 | logger, | |
| 218 | 219 | actions, | |
| 219 | - }: ActionState<["Base", "Logger", "Actions"]>) { | ||
| 220 | + }: ActionState<["Base", "Env", "Logger", "Actions"]>) { | ||
| 220 | 221 | // To capture errors appropriately, keep as much code within the try-catch as | |
| 221 | 222 | // possible, and only use safe functions outside. | |
| 222 | 223 | ||
@@ -287,7 +288,7 @@ async function run({ | |||
| 287 | 288 | ||
| 288 | 289 | const apiDetails = getApiDetails(); | |
| 289 | 290 | const outputDir = actionsUtil.getRequiredInput("output"); | |
| 290 | - core.exportVariable(EnvVar.SARIF_RESULTS_OUTPUT_DIR, outputDir); | ||
| 291 | + env.export(EnvVar.SARIF_RESULTS_OUTPUT_DIR, outputDir); | ||
| 291 | 292 | const threads = util.getThreadsFlag( | |
| 292 | 293 | actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], | |
| 293 | 294 | logger, | |
@@ -456,7 +457,7 @@ async function run({ | |||
| 456 | 457 | `expect-error input was set to true but no error was thrown.`, | |
| 457 | 458 | ); | |
| 458 | 459 | } | |
| 459 | - core.exportVariable(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY, "true"); | ||
| 460 | + env.export(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY, "true"); | ||
| 460 | 461 | } catch (unwrappedError) { | |
| 461 | 462 | const error = util.wrapError(unwrappedError); | |
| 462 | 463 | if ( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,7 @@ import { | |||
| 17 | 17 | ReadOnlyEnv, | |
| 18 | 18 | RegistryProxyVars, | |
| 19 | 19 | getEnv, | |
| 20 | + exportEnvVar, | ||
| 20 | 21 | } from "./environment"; | |
| 21 | 22 | import { Logger } from "./logging"; | |
| 22 | 23 | import { getRepositoryNwo, RepositoryNwo } from "./repository"; | |
@@ -316,7 +317,7 @@ export async function getAnalysisKey(): Promise<string> { | |||
| 316 | 317 | const jobName = getRequiredEnvParam("GITHUB_JOB"); | |
| 317 | 318 | ||
| 318 | 319 | analysisKey = `${workflowPath}:${jobName}`; | |
| 319 | - core.exportVariable(EnvVar.ANALYSIS_KEY, analysisKey); | ||
| 320 | + exportEnvVar(EnvVar.ANALYSIS_KEY, analysisKey); | ||
| 320 | 321 | return analysisKey; | |
| 321 | 322 | } | |
| 322 | 323 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,7 +68,11 @@ async function sendCompletedStatusReport( | |||
| 68 | 68 | } | |
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | - async function run({ startedAt, logger }: ActionState<["Base", "Logger"]>) { | ||
| 71 | + async function run({ | ||
| 72 | + startedAt, | ||
| 73 | + env, | ||
| 74 | + logger, | ||
| 75 | + }: ActionState<["Base", "Env", "Logger"]>) { | ||
| 72 | 76 | // To capture errors appropriately, keep as much code within the try-catch as | |
| 73 | 77 | // possible, and only use safe functions outside. | |
| 74 | 78 | ||
@@ -135,7 +139,7 @@ async function run({ startedAt, logger }: ActionState<["Base", "Logger"]>) { | |||
| 135 | 139 | return; | |
| 136 | 140 | } | |
| 137 | 141 | ||
| 138 | - core.exportVariable(EnvVar.AUTOBUILD_DID_COMPLETE_SUCCESSFULLY, "true"); | ||
| 142 | + env.export(EnvVar.AUTOBUILD_DID_COMPLETE_SUCCESSFULLY, "true"); | ||
| 139 | 143 | ||
| 140 | 144 | await sendCompletedStatusReport(config, logger, startedAt, languages ?? []); | |
| 141 | 145 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,9 @@ | |||
| 1 | - import * as core from "@actions/core"; | ||
| 2 | - | ||
| 3 | 1 | import { getTemporaryDirectory, getWorkflowEventName } from "./actions-util"; | |
| 4 | 2 | import { getGitHubVersion } from "./api-client"; | |
| 5 | 3 | import { CodeQL, getCodeQL } from "./codeql"; | |
| 6 | 4 | import * as configUtils from "./config-utils"; | |
| 7 | 5 | import { DocUrl } from "./doc-url"; | |
| 8 | - import { ActionsEnvVars, EnvVar } from "./environment"; | ||
| 6 | + import { ActionsEnvVars, EnvVar, exportEnvVar } from "./environment"; | ||
| 9 | 7 | import { Feature, featureConfig, initFeatures } from "./feature-flags"; | |
| 10 | 8 | import { BuiltInLanguage, Language } from "./languages"; | |
| 11 | 9 | import { Logger } from "./logging"; | |
@@ -136,16 +134,16 @@ export async function setupCppAutobuild(codeql: CodeQL, logger: Logger) { | |||
| 136 | 134 | : "" | |
| 137 | 135 | }`, | |
| 138 | 136 | ); | |
| 139 | - core.exportVariable(envVar, "false"); | ||
| 137 | + exportEnvVar(envVar, "false"); | ||
| 140 | 138 | } else { | |
| 141 | 139 | logger.info( | |
| 142 | 140 | `Enabling ${featureName}. This can be disabled by setting the ${envVar} environment variable to 'false'. See ${DocUrl.DEFINE_ENV_VARIABLES} for more information.`, | |
| 143 | 141 | ); | |
| 144 | - core.exportVariable(envVar, "true"); | ||
| 142 | + exportEnvVar(envVar, "true"); | ||
| 145 | 143 | } | |
| 146 | 144 | } else { | |
| 147 | 145 | logger.info(`Disabling ${featureName}.`); | |
| 148 | - core.exportVariable(envVar, "false"); | ||
| 146 | + exportEnvVar(envVar, "false"); | ||
| 149 | 147 | } | |
| 150 | 148 | } | |
| 151 | 149 | ||
@@ -165,7 +163,7 @@ export async function runAutobuild( | |||
| 165 | 163 | await codeQL.runAutobuild(config, language); | |
| 166 | 164 | } | |
| 167 | 165 | if (language === BuiltInLanguage.go) { | |
| 168 | - core.exportVariable(EnvVar.DID_AUTOBUILD_GOLANG, "true"); | ||
| 166 | + exportEnvVar(EnvVar.DID_AUTOBUILD_GOLANG, "true"); | ||
| 169 | 167 | } | |
| 170 | 168 | logger.endGroup(); | |
| 171 | 169 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments