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

@ -19,5 +19,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- uses: ./
with:
milliseconds: 1000
with:
# 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 () => {
const invalidWrapperJars = await validate.findInvalidWrapperJars(
path.resolve('.'),
false
false,
[]
)
expect(invalidWrapperJars.length).toBe(1)
expect(invalidWrapperJars[0]).toEqual(

View file

@ -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'

6
dist/index.js vendored
View file

@ -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);

View file

@ -6,9 +6,11 @@ import * as validate from './validate'
export async function run(): Promise<void> {
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}`)

View file

@ -4,11 +4,13 @@ import * as hash from './hash'
export async function findInvalidWrapperJars(
gitRepoRoot: string,
allowSnapshots: boolean
allowSnapshots: boolean,
allowChecksums: string[]
): Promise<string[]> {
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)