mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 13:06:18 +08:00
Lint
This commit is contained in:
parent
5c61ab77ec
commit
6cee865aea
@ -16,13 +16,9 @@
|
|||||||
"@typescript-eslint/no-require-imports": "error",
|
"@typescript-eslint/no-require-imports": "error",
|
||||||
"@typescript-eslint/array-type": "error",
|
"@typescript-eslint/array-type": "error",
|
||||||
"@typescript-eslint/await-thenable": "error",
|
"@typescript-eslint/await-thenable": "error",
|
||||||
"@typescript-eslint/ban-ts-ignore": "error",
|
|
||||||
"camelcase": "off",
|
"camelcase": "off",
|
||||||
"@typescript-eslint/camelcase": "error",
|
|
||||||
"@typescript-eslint/class-name-casing": "error",
|
|
||||||
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
|
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
|
||||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||||
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
|
|
||||||
"@typescript-eslint/no-array-constructor": "error",
|
"@typescript-eslint/no-array-constructor": "error",
|
||||||
"@typescript-eslint/no-empty-interface": "error",
|
"@typescript-eslint/no-empty-interface": "error",
|
||||||
"@typescript-eslint/no-explicit-any": "error",
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
@ -16,7 +16,7 @@ export async function execute(
|
|||||||
if (line.startsWith('Publishing build scan...')) {
|
if (line.startsWith('Publishing build scan...')) {
|
||||||
publishing = true
|
publishing = true
|
||||||
}
|
}
|
||||||
if (publishing && line.length == 0) {
|
if (publishing && line.length === 0) {
|
||||||
publishing = false
|
publishing = false
|
||||||
}
|
}
|
||||||
if (publishing && line.startsWith('http')) {
|
if (publishing && line.startsWith('http')) {
|
||||||
|
20
src/main.ts
20
src/main.ts
@ -7,11 +7,11 @@ import * as gradlew from './gradlew'
|
|||||||
import * as provision from './provision'
|
import * as provision from './provision'
|
||||||
|
|
||||||
// Invoked by GitHub Actions
|
// Invoked by GitHub Actions
|
||||||
export async function run() {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const baseDirectory = process.env[`GITHUB_WORKSPACE`] || ''
|
const baseDirectory = process.env[`GITHUB_WORKSPACE`] || ''
|
||||||
|
|
||||||
let result = await execution.execute(
|
const result = await execution.execute(
|
||||||
await resolveGradleExecutable(baseDirectory),
|
await resolveGradleExecutable(baseDirectory),
|
||||||
resolveBuildRootDirectory(baseDirectory),
|
resolveBuildRootDirectory(baseDirectory),
|
||||||
parseCommandLineArguments()
|
parseCommandLineArguments()
|
||||||
@ -21,7 +21,7 @@ export async function run() {
|
|||||||
core.setOutput('build-scan-url', result.buildScanUrl)
|
core.setOutput('build-scan-url', result.buildScanUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.status != 0) {
|
if (result.status !== 0) {
|
||||||
core.setFailed(`Gradle process exited with status ${result.status}`)
|
core.setFailed(`Gradle process exited with status ${result.status}`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -33,18 +33,18 @@ run()
|
|||||||
|
|
||||||
async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
||||||
const gradleVersion = inputOrNull('gradle-version')
|
const gradleVersion = inputOrNull('gradle-version')
|
||||||
if (gradleVersion != null && gradleVersion != 'wrapper') {
|
if (gradleVersion !== null && gradleVersion !== 'wrapper') {
|
||||||
return path.resolve(await provision.gradleVersion(gradleVersion))
|
return path.resolve(await provision.gradleVersion(gradleVersion))
|
||||||
}
|
}
|
||||||
|
|
||||||
const gradleExecutable = inputOrNull('gradle-executable')
|
const gradleExecutable = inputOrNull('gradle-executable')
|
||||||
if (gradleExecutable != null) {
|
if (gradleExecutable !== null) {
|
||||||
return path.resolve(baseDirectory, gradleExecutable)
|
return path.resolve(baseDirectory, gradleExecutable)
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapperDirectory = inputOrNull('wrapper-directory')
|
const wrapperDirectory = inputOrNull('wrapper-directory')
|
||||||
const executableDirectory =
|
const executableDirectory =
|
||||||
wrapperDirectory != null
|
wrapperDirectory !== null
|
||||||
? path.join(baseDirectory, wrapperDirectory)
|
? path.join(baseDirectory, wrapperDirectory)
|
||||||
: baseDirectory
|
: baseDirectory
|
||||||
|
|
||||||
@ -52,20 +52,20 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resolveBuildRootDirectory(baseDirectory: string): string {
|
function resolveBuildRootDirectory(baseDirectory: string): string {
|
||||||
let buildRootDirectory = inputOrNull('build-root-directory')
|
const buildRootDirectory = inputOrNull('build-root-directory')
|
||||||
return buildRootDirectory == null
|
return buildRootDirectory === null
|
||||||
? path.resolve(baseDirectory)
|
? path.resolve(baseDirectory)
|
||||||
: path.resolve(baseDirectory, buildRootDirectory)
|
: path.resolve(baseDirectory, buildRootDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCommandLineArguments(): string[] {
|
function parseCommandLineArguments(): string[] {
|
||||||
const input = inputOrNull('arguments')
|
const input = inputOrNull('arguments')
|
||||||
return input == null ? [] : parseArgsStringToArgv(input)
|
return input === null ? [] : parseArgsStringToArgv(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
function inputOrNull(name: string): string | null {
|
function inputOrNull(name: string): string | null {
|
||||||
const inputString = core.getInput(name)
|
const inputString = core.getInput(name)
|
||||||
if (inputString.length == 0) {
|
if (inputString.length === 0) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return inputString
|
return inputString
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
|
||||||
// Invoked by GitHub Actions
|
// Invoked by GitHub Actions
|
||||||
export async function run() {
|
export async function run(): Promise<void> {
|
||||||
core.info('POST Gradle Command Action')
|
core.info('POST Gradle Command Action')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'
|
|||||||
/**
|
/**
|
||||||
* @return Gradle executable path
|
* @return Gradle executable path
|
||||||
*/
|
*/
|
||||||
export async function gradleVersion(gradleVersion: string): Promise<string> {
|
export async function gradleVersion(version: string): Promise<string> {
|
||||||
switch (gradleVersion) {
|
switch (version) {
|
||||||
case 'current':
|
case 'current':
|
||||||
return gradleCurrent()
|
return gradleCurrent()
|
||||||
case 'rc':
|
case 'rc':
|
||||||
@ -25,7 +25,7 @@ export async function gradleVersion(gradleVersion: string): Promise<string> {
|
|||||||
case 'release-nightly':
|
case 'release-nightly':
|
||||||
return gradleReleaseNightly()
|
return gradleReleaseNightly()
|
||||||
default:
|
default:
|
||||||
return gradle(gradleVersion)
|
return gradle(version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,9 +129,9 @@ async function httpGetJson(url: string): Promise<any> {
|
|||||||
return JSON.parse(body)
|
return JSON.parse(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function httpDownload(url: string, path: string): Promise<void> {
|
async function httpDownload(url: string, localPath: string): Promise<void> {
|
||||||
return new Promise<void>(function (resolve, reject) {
|
return new Promise<void>(function (resolve, reject) {
|
||||||
const writeStream = fs.createWriteStream(path)
|
const writeStream = fs.createWriteStream(localPath)
|
||||||
httpc
|
httpc
|
||||||
.get(url)
|
.get(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user