Skip to content

Commit

Permalink
wip: hash bundle url and use it as the cache version
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Kalyvitis committed Jun 17, 2020
1 parent 6de3e1c commit fff3de9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions lib/setup-tools.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/setup-tools.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/setup-tools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as core from '@actions/core';
import * as toolcache from '@actions/tool-cache';
import * as path from 'path';
import * as crypto from 'crypto';

export class CodeQLSetup {
public dist: string;
Expand Down Expand Up @@ -29,17 +30,18 @@ export class CodeQLSetup {
}

export async function setupCodeQL(): Promise<CodeQLSetup> {
const version = '1.0.0';
const hash = crypto.createHash('sha256');
const codeqlURL = core.getInput('tools', { required: true });
const codeqlURLHash = hash.update(codeqlURL).digest('hex');

try {
let codeqlFolder = toolcache.find('CodeQL', version);
let codeqlFolder = toolcache.find('CodeQL', codeqlURLHash);
if (codeqlFolder) {
core.debug(`CodeQL found in cache ${codeqlFolder}`);
} else {
const codeqlPath = await toolcache.downloadTool(codeqlURL);
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', version);
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', codeqlURLHash);
}
return new CodeQLSetup(path.join(codeqlFolder, 'codeql'));

Expand Down

0 comments on commit fff3de9

Please sign in to comment.