GeezerVison is showing github.com — Merge pull request #2876 from github/henrymercer/fix-diff-informed-mu… · github/codeql-action@81a9508
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/codescanning-config-cli.yml +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | name: Code-Scanning config CLI tests | 4 | 4 | env: | 5 | 5 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | | 6 | + # Diff informed queries add an additional query filter which is not yet | | 7 | + # taken into account by these tests. | | 8 | + CODEQL_ACTION_DIFF_INFORMED_QUERIES: false | 6 | 9 |
| 7 | 10 | on: | 8 | 11 | push: | |
Collapse file Copy file name to clipboardExpand all lines: lib/analyze.js +6-1Lines changed: 6 additions & 1 deletion Collapse file Copy file name to clipboardExpand all lines: lib/analyze.js.map +1-1Lines changed: 1 addition & 1 deletion Collapse file Copy file name to clipboardExpand all lines: lib/dependency-caching.js +40-38Lines changed: 40 additions & 38 deletions Collapse file Copy file name to clipboardExpand all lines: lib/dependency-caching.js.map +1-1Lines changed: 1 addition & 1 deletion Collapse file Copy file name to clipboardExpand all lines: src/analyze.ts +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -507,7 +507,13 @@ function writeDiffRangeDataExtensionPack( | 507 | 507 | actionsUtil.getTemporaryDirectory(), | 508 | 508 | "pr-diff-range", | 509 | 509 | ); | 510 | | - fs.mkdirSync(diffRangeDir); | | 510 | + | | 511 | + // We expect the Actions temporary directory to already exist, so are mainly | | 512 | + // using `recursive: true` to avoid errors if the directory already exists, | | 513 | + // for example if the analyze Action is run multiple times in the same job. | | 514 | + // This is not really something that is supported, but we make use of it in | | 515 | + // tests. | | 516 | + fs.mkdirSync(diffRangeDir, { recursive: true }); | 511 | 517 | fs.writeFileSync( | 512 | 518 | path.join(diffRangeDir, "qlpack.yml"), | 513 | 519 | ` | |
Collapse file Copy file name to clipboardExpand all lines: src/dependency-caching.ts +40-38Lines changed: 40 additions & 38 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -41,42 +41,44 @@ export function getJavaTempDependencyDir(): string { | 41 | 41 | /** | 42 | 42 | * Default caching configurations per language. | 43 | 43 | */ | 44 | | -const CODEQL_DEFAULT_CACHE_CONFIG: { [language: string]: CacheConfig } = { | 45 | | - java: { | 46 | | - paths: [ | 47 | | - // Maven | 48 | | - join(os.homedir(), ".m2", "repository"), | 49 | | - // Gradle | 50 | | - join(os.homedir(), ".gradle", "caches"), | 51 | | - // CodeQL Java build-mode: none | 52 | | - getJavaTempDependencyDir(), | 53 | | - ], | 54 | | - hash: [ | 55 | | - // Maven | 56 | | - "**/pom.xml", | 57 | | - // Gradle | 58 | | - "**/*.gradle*", | 59 | | - "**/gradle-wrapper.properties", | 60 | | - "buildSrc/**/Versions.kt", | 61 | | - "buildSrc/**/Dependencies.kt", | 62 | | - "gradle/*.versions.toml", | 63 | | - "**/versions.properties", | 64 | | - ], | 65 | | - }, | 66 | | - csharp: { | 67 | | - paths: [join(os.homedir(), ".nuget", "packages")], | 68 | | - hash: [ | 69 | | - // NuGet | 70 | | - "**/packages.lock.json", | 71 | | - // Paket | 72 | | - "**/paket.lock", | 73 | | - ], | 74 | | - }, | 75 | | - go: { | 76 | | - paths: [join(os.homedir(), "go", "pkg", "mod")], | 77 | | - hash: ["**/go.sum"], | 78 | | - }, | 79 | | -}; | | 44 | +function getDefaultCacheConfig(): { [language: string]: CacheConfig } { | | 45 | + return { | | 46 | + java: { | | 47 | + paths: [ | | 48 | + // Maven | | 49 | + join(os.homedir(), ".m2", "repository"), | | 50 | + // Gradle | | 51 | + join(os.homedir(), ".gradle", "caches"), | | 52 | + // CodeQL Java build-mode: none | | 53 | + getJavaTempDependencyDir(), | | 54 | + ], | | 55 | + hash: [ | | 56 | + // Maven | | 57 | + "**/pom.xml", | | 58 | + // Gradle | | 59 | + "**/*.gradle*", | | 60 | + "**/gradle-wrapper.properties", | | 61 | + "buildSrc/**/Versions.kt", | | 62 | + "buildSrc/**/Dependencies.kt", | | 63 | + "gradle/*.versions.toml", | | 64 | + "**/versions.properties", | | 65 | + ], | | 66 | + }, | | 67 | + csharp: { | | 68 | + paths: [join(os.homedir(), ".nuget", "packages")], | | 69 | + hash: [ | | 70 | + // NuGet | | 71 | + "**/packages.lock.json", | | 72 | + // Paket | | 73 | + "**/paket.lock", | | 74 | + ], | | 75 | + }, | | 76 | + go: { | | 77 | + paths: [join(os.homedir(), "go", "pkg", "mod")], | | 78 | + hash: ["**/go.sum"], | | 79 | + }, | | 80 | + }; | | 81 | +} | 80 | 82 |
| 81 | 83 | async function makeGlobber(patterns: string[]): Promise<glob.Globber> { | 82 | 84 | return glob.create(patterns.join("\n")); | @@ -96,7 +98,7 @@ export async function downloadDependencyCaches( | 96 | 98 | const restoredCaches: Language[] = []; | 97 | 99 |
| 98 | 100 | for (const language of languages) { | 99 | | - const cacheConfig = CODEQL_DEFAULT_CACHE_CONFIG[language]; | | 101 | + const cacheConfig = getDefaultCacheConfig()[language]; | 100 | 102 |
| 101 | 103 | if (cacheConfig === undefined) { | 102 | 104 | logger.info( | @@ -150,7 +152,7 @@ export async function downloadDependencyCaches( | 150 | 152 | */ | 151 | 153 | export async function uploadDependencyCaches(config: Config, logger: Logger) { | 152 | 154 | for (const language of config.languages) { | 153 | | - const cacheConfig = CODEQL_DEFAULT_CACHE_CONFIG[language]; | | 155 | + const cacheConfig = getDefaultCacheConfig()[language]; | 154 | 156 |
| 155 | 157 | if (cacheConfig === undefined) { | 156 | 158 | logger.info( | |
|