diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d62684f..e9a5d3c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,5 +19,6 @@ jobs: steps: - uses: actions/checkout@v1 - uses: ./ - with: - milliseconds: 1000 \ No newline at end of file + with: + # to allow the invalid wrapper jar present in test data + allow-checksums: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/__tests__/validate.test.ts b/__tests__/validate.test.ts index 838df46..8e4f359 100644 --- a/__tests__/validate.test.ts +++ b/__tests__/validate.test.ts @@ -4,7 +4,8 @@ import * as validate from '../src/validate' test('validates wrapper jars', async () => { const invalidWrapperJars = await validate.findInvalidWrapperJars( path.resolve('.'), - false + false, + [] ) expect(invalidWrapperJars.length).toBe(1) expect(invalidWrapperJars[0]).toEqual( diff --git a/action.yml b/action.yml index c82dc5b..5cc5eeb 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,10 @@ inputs: description: 'Allow snapshot Gradle versions' required: false default: 'false' + allow-checksums: + description: 'Allow arbitrary checksums, comma separated' + required: false + default: '' runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index b35efae..8de39e8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -341,7 +341,8 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const allowSnapshots = core.getInput('allow-snapshots') === 'true'; - const invalidWrapperJars = yield validate.findInvalidWrapperJars(path.resolve('.'), allowSnapshots); + const allowChecksums = core.getInput('allow-checksums').split(','); + const invalidWrapperJars = yield validate.findInvalidWrapperJars(path.resolve('.'), allowSnapshots, allowChecksums); if (invalidWrapperJars.length > 0) { core.setFailed(`Invalid wrapper jars ${invalidWrapperJars}`); } @@ -942,11 +943,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); const find = __importStar(__webpack_require__(625)); const checksums = __importStar(__webpack_require__(762)); const hash = __importStar(__webpack_require__(652)); -function findInvalidWrapperJars(gitRepoRoot, allowSnapshots) { +function findInvalidWrapperJars(gitRepoRoot, allowSnapshots, allowChecksums) { return __awaiter(this, void 0, void 0, function* () { const wrapperJars = yield find.findWrapperJars(gitRepoRoot); if (wrapperJars.length > 0) { const validChecksums = yield checksums.fetchValidChecksums(allowSnapshots); + validChecksums.push(...allowChecksums); const invalidWrapperJars = []; for (const wrapperJar of wrapperJars) { const sha = yield hash.sha256File(wrapperJar); diff --git a/src/main.ts b/src/main.ts index 75ae0ca..cccc911 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,9 +6,11 @@ import * as validate from './validate' export async function run(): Promise { try { const allowSnapshots = core.getInput('allow-snapshots') === 'true' + const allowChecksums = core.getInput('allow-checksums').split(',') const invalidWrapperJars = await validate.findInvalidWrapperJars( path.resolve('.'), - allowSnapshots + allowSnapshots, + allowChecksums ) if (invalidWrapperJars.length > 0) { core.setFailed(`Invalid wrapper jars ${invalidWrapperJars}`) diff --git a/src/validate.ts b/src/validate.ts index 372b2be..d49c173 100644 --- a/src/validate.ts +++ b/src/validate.ts @@ -4,11 +4,13 @@ import * as hash from './hash' export async function findInvalidWrapperJars( gitRepoRoot: string, - allowSnapshots: boolean + allowSnapshots: boolean, + allowChecksums: string[] ): Promise { const wrapperJars = await find.findWrapperJars(gitRepoRoot) if (wrapperJars.length > 0) { const validChecksums = await checksums.fetchValidChecksums(allowSnapshots) + validChecksums.push(...allowChecksums) const invalidWrapperJars: string[] = [] for (const wrapperJar of wrapperJars) { const sha = await hash.sha256File(wrapperJar)