Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Make Wrapper validator self executable and GitLab CI ready #50

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1bf572e
adding dockerfile
RAkasheh Oct 13, 2021
80c2095
edited Dockerfile
RAkasheh Oct 13, 2021
1da789c
Update Dockerfile
RAkasheh Oct 13, 2021
11a69d5
Make Wrapper validator executable and GitLab CI ready
Oct 13, 2021
db78afa
Using action.yml as definition for the program parameters
Oct 14, 2021
9199393
removing redundant type specifier
Oct 14, 2021
701d3cc
refinements and preparing test setup
Oct 14, 2021
860cd41
Merge remote-tracking branch 'aepfli/feature/gitlab-ci-compatibility'
RAkasheh Oct 14, 2021
0a71729
Merge branch 'master' of gitlab.com:netconomy/personal/r.akasheh/grad…
RAkasheh Oct 14, 2021
bd9a29d
Update WrapperValidation.gitlab-ci.yml
RAkasheh Oct 14, 2021
3ccbb71
Make it nice executable
Oct 14, 2021
9e67ca1
Removing node_env
Oct 14, 2021
841abf7
fixing build
Oct 14, 2021
1d5211f
trying out action yml path
RAkasheh Oct 14, 2021
1e99869
Update main.ts
RAkasheh Oct 14, 2021
ac7d358
Update main.ts
RAkasheh Oct 14, 2021
32ecb1b
Update main.ts
RAkasheh Oct 14, 2021
3c1acdf
Update main.ts
RAkasheh Oct 14, 2021
584dbed
Update main.ts
RAkasheh Oct 14, 2021
679d29d
testing cd __tests
RAkasheh Oct 14, 2021
50ff280
trying to add githubaction
Oct 14, 2021
7f998fa
Merge pull request #1 from aepfli/feature/gitlab-ci-compatibility
aepfli Oct 14, 2021
56586fb
adding gitlab-ci file
Oct 14, 2021
03df991
Further Testing
Oct 14, 2021
d44ce28
CI
Oct 14, 2021
1b1b81d
trying to get tests running
Oct 14, 2021
6cef04d
another try
Oct 14, 2021
520cf8a
Delete .gitlab-ci.yml
aepfli Oct 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__tests__
.github
8 changes: 8 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


include:
- local: WrapperValidation.gitlab-ci.yml

validate-wrapper:
variables:
MIN_WRAPPER_COUNT: 10
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:12-slim

ENV NODE_ENV=production

WORKDIR /app

COPY . .

RUN npm install && npm run-script build && npm install -g

ENTRYPOINT [ "wrapper-validation" ]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,11 @@ Regardless of what you find, we still kindly request that you reach out to us an

To learn more about verifying the Gradle Wrapper JAR locally, see our
[guide on the topic](https://docs.gradle.org/current/userguide/gradle_wrapper.html#wrapper_checksum_verification).


## Usage in GitLab CI

```yaml
include:
- remote: https://raw.githubusercontent.com/gradle/wrapper-validation-action/master/WrapperValidation.gitlab-ci.yml
```
9 changes: 9 additions & 0 deletions WrapperValidation.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

validate-wrapper:
stage: .pre
image:
name: wrapper-validation:latest
entrypoint: [""]
script:
- echo "wrapper-validation --min-wrapper-count=$MIN_WRAPPER_COUNT"
- wrapper-validation --min-wrapper-count=$MIN_WRAPPER_COUNT
17 changes: 14 additions & 3 deletions package-lock.json

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

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"private": true,
"description": "Gradle Wrapper Validation Action",
"main": "lib/main.js",
"bin": {
"wrapper-validation": "lib/main.js"
},
"scripts": {
"build": "tsc",
"format": "prettier --write **/*.ts",
Expand All @@ -26,22 +29,24 @@
"license": "MIT",
"dependencies": {
"@actions/core": "1.4.0",
"commander": "^8.2.0",
"typed-rest-client": "1.8.4",
"unhomoglyph": "1.0.6"
},
"devDependencies": {
"@types/node": "12.20.16",
"@types/js-yaml": "^4.0.3",
"@types/node": "^12.20.33",
"@typescript-eslint/parser": "4.28.4",
"@vercel/ncc": "0.29.0",
"eslint": "7.31.0",
"eslint-plugin-github": "4.1.5",
"eslint-plugin-jest": "24.4.0",
"glob-parent": ">=5.1.2",
"jest": "27.0.6",
"js-yaml": "4.1.0",
"js-yaml": "^4.1.0",
"nock": "13.1.1",
"prettier": "2.3.2",
"ts-jest": "27.0.4",
"typescript": "4.0.8",
"glob-parent": ">=5.1.2"
"typescript": "4.0.8"
}
}
66 changes: 56 additions & 10 deletions src/main.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,71 @@
import * as path from 'path'
import * as core from '@actions/core'
#!/usr/bin/env node

import * as validate from './validate'
import path from 'path'
import { promises as fs } from 'fs'
import { setFailed, getInput, info} from '@actions/core'

import { findInvalidWrapperJars } from './validate'
import { Command } from 'commander'
import jsyaml from 'js-yaml'

interface Action {
name: string;
description: string;
author: string;
inputs: Map<string, Input>;
}

interface Input {
description: string;
required?: boolean;
default?: string;
}

export async function run(): Promise<void> {
try {
const result = await validate.findInvalidWrapperJars(
let minWrapperCount: number
let allowSnapshots: string
let allowChecksums: string

if (process.env.GITHUB_ACTION) {
minWrapperCount = +getInput('min-wrapper-count')
allowSnapshots = getInput('allow-snapshots')
allowChecksums = getInput('allow-checksums')

} else {
const program = new Command()
const actionYaml = jsyaml.load(await fs.readFile(path.resolve('action.yml'), 'utf8')) as Action

program
.description(actionYaml.description)

Object.entries(actionYaml.inputs).forEach(([key,value]) => {
program.option(`--${key} <value>`, value.description, value.default)
})

program.parse(process.argv)
const options = program.opts()
minWrapperCount = +options.minWrapperCount
allowSnapshots = options.allowSnapshots
allowChecksums = options.allowChecksums
}

const result = await findInvalidWrapperJars(
path.resolve('.'),
+core.getInput('min-wrapper-count'),
core.getInput('allow-snapshots') === 'true',
core.getInput('allow-checksums').split(',')
minWrapperCount,
allowSnapshots === 'true',
allowChecksums.split(',')
)
if (result.isValid()) {
core.info(result.toDisplayString())
info(result.toDisplayString())
} else {
core.setFailed(
setFailed(
`Gradle Wrapper Validation Failed!\n See https://github.com/gradle/wrapper-validation-action#reporting-failures\n${result.toDisplayString()}`
)
}
} catch (error) {
core.setFailed(error.message)
if(error instanceof Error)
setFailed(error.message)
}
}

Expand Down