Add input to allow arbitrary checksums

In order for the action integration test to pass on CI
And it's a feature

Signed-off-by: Paul Merlin <paul@gradle.com>
This commit is contained in:
Paul Merlin 2020-01-06 13:36:28 +01:00
parent bb8b9a96ab
commit 73443bf726
6 changed files with 19 additions and 7 deletions

View file

@ -20,4 +20,5 @@ jobs:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: ./ - uses: ./
with: with:
milliseconds: 1000 # to allow the invalid wrapper jar present in test data
allow-checksums: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

View file

@ -4,7 +4,8 @@ import * as validate from '../src/validate'
test('validates wrapper jars', async () => { test('validates wrapper jars', async () => {
const invalidWrapperJars = await validate.findInvalidWrapperJars( const invalidWrapperJars = await validate.findInvalidWrapperJars(
path.resolve('.'), path.resolve('.'),
false false,
[]
) )
expect(invalidWrapperJars.length).toBe(1) expect(invalidWrapperJars.length).toBe(1)
expect(invalidWrapperJars[0]).toEqual( expect(invalidWrapperJars[0]).toEqual(

View file

@ -6,6 +6,10 @@ inputs:
description: 'Allow snapshot Gradle versions' description: 'Allow snapshot Gradle versions'
required: false required: false
default: 'false' default: 'false'
allow-checksums:
description: 'Allow arbitrary checksums, comma separated'
required: false
default: ''
runs: runs:
using: 'node12' using: 'node12'
main: 'dist/index.js' main: 'dist/index.js'

6
dist/index.js vendored
View file

@ -341,7 +341,8 @@ function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const allowSnapshots = core.getInput('allow-snapshots') === 'true'; 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) { if (invalidWrapperJars.length > 0) {
core.setFailed(`Invalid wrapper jars ${invalidWrapperJars}`); core.setFailed(`Invalid wrapper jars ${invalidWrapperJars}`);
} }
@ -942,11 +943,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
const find = __importStar(__webpack_require__(625)); const find = __importStar(__webpack_require__(625));
const checksums = __importStar(__webpack_require__(762)); const checksums = __importStar(__webpack_require__(762));
const hash = __importStar(__webpack_require__(652)); const hash = __importStar(__webpack_require__(652));
function findInvalidWrapperJars(gitRepoRoot, allowSnapshots) { function findInvalidWrapperJars(gitRepoRoot, allowSnapshots, allowChecksums) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const wrapperJars = yield find.findWrapperJars(gitRepoRoot); const wrapperJars = yield find.findWrapperJars(gitRepoRoot);
if (wrapperJars.length > 0) { if (wrapperJars.length > 0) {
const validChecksums = yield checksums.fetchValidChecksums(allowSnapshots); const validChecksums = yield checksums.fetchValidChecksums(allowSnapshots);
validChecksums.push(...allowChecksums);
const invalidWrapperJars = []; const invalidWrapperJars = [];
for (const wrapperJar of wrapperJars) { for (const wrapperJar of wrapperJars) {
const sha = yield hash.sha256File(wrapperJar); const sha = yield hash.sha256File(wrapperJar);

View file

@ -6,9 +6,11 @@ import * as validate from './validate'
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
const allowSnapshots = core.getInput('allow-snapshots') === 'true' const allowSnapshots = core.getInput('allow-snapshots') === 'true'
const allowChecksums = core.getInput('allow-checksums').split(',')
const invalidWrapperJars = await validate.findInvalidWrapperJars( const invalidWrapperJars = await validate.findInvalidWrapperJars(
path.resolve('.'), path.resolve('.'),
allowSnapshots allowSnapshots,
allowChecksums
) )
if (invalidWrapperJars.length > 0) { if (invalidWrapperJars.length > 0) {
core.setFailed(`Invalid wrapper jars ${invalidWrapperJars}`) core.setFailed(`Invalid wrapper jars ${invalidWrapperJars}`)

View file

@ -4,11 +4,13 @@ import * as hash from './hash'
export async function findInvalidWrapperJars( export async function findInvalidWrapperJars(
gitRepoRoot: string, gitRepoRoot: string,
allowSnapshots: boolean allowSnapshots: boolean,
allowChecksums: string[]
): Promise<string[]> { ): Promise<string[]> {
const wrapperJars = await find.findWrapperJars(gitRepoRoot) const wrapperJars = await find.findWrapperJars(gitRepoRoot)
if (wrapperJars.length > 0) { if (wrapperJars.length > 0) {
const validChecksums = await checksums.fetchValidChecksums(allowSnapshots) const validChecksums = await checksums.fetchValidChecksums(allowSnapshots)
validChecksums.push(...allowChecksums)
const invalidWrapperJars: string[] = [] const invalidWrapperJars: string[] = []
for (const wrapperJar of wrapperJars) { for (const wrapperJar of wrapperJars) {
const sha = await hash.sha256File(wrapperJar) const sha = await hash.sha256File(wrapperJar)