Add working-directory support (#18)
Add working-directory support Fixes #15
This commit is contained in:
parent
85a3a6abe4
commit
20d5541dab
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -23,4 +23,5 @@ jobs:
|
|||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
version: v1.26
|
version: v1.26
|
||||||
args: --issues-exit-code=0 ./sample/...
|
args: --issues-exit-code=0 ./...
|
||||||
|
working-directory: sample
|
||||||
|
@ -10,9 +10,9 @@ inputs:
|
|||||||
description: 'golangci-lint command line arguments'
|
description: 'golangci-lint command line arguments'
|
||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
github-token:
|
working-directory:
|
||||||
description: 'GitHub token with scope `repo.public_repo`. Used for fetching a list of releases of golangci-lint.'
|
description: 'golangci-lint working directory, default is project root'
|
||||||
required: true
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
@ -20,4 +20,4 @@ runs:
|
|||||||
post: 'dist/post_run/index.js'
|
post: 'dist/post_run/index.js'
|
||||||
branding:
|
branding:
|
||||||
icon: 'shield'
|
icon: 'shield'
|
||||||
color: 'yellow'
|
color: 'yellow'
|
||||||
|
14
dist/post_run/index.js
vendored
14
dist/post_run/index.js
vendored
@ -2352,6 +2352,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const child_process_1 = __webpack_require__(129);
|
const child_process_1 = __webpack_require__(129);
|
||||||
|
const fs = __importStar(__webpack_require__(747));
|
||||||
|
const path = __importStar(__webpack_require__(622));
|
||||||
const util_1 = __webpack_require__(669);
|
const util_1 = __webpack_require__(669);
|
||||||
const cache_1 = __webpack_require__(722);
|
const cache_1 = __webpack_require__(722);
|
||||||
const install_1 = __webpack_require__(655);
|
const install_1 = __webpack_require__(655);
|
||||||
@ -2396,11 +2398,19 @@ function runLint(lintPath) {
|
|||||||
if (args.includes(`-out-format`)) {
|
if (args.includes(`-out-format`)) {
|
||||||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
|
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
|
||||||
}
|
}
|
||||||
|
const workingDirectory = core.getInput(`working-directory`);
|
||||||
|
const cmdArgs = {};
|
||||||
|
if (workingDirectory != ``) {
|
||||||
|
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||||
|
throw new Error(`working-directory (${workingDirectory}) was not a path`);
|
||||||
|
}
|
||||||
|
cmdArgs.cwd = path.resolve(workingDirectory);
|
||||||
|
}
|
||||||
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight();
|
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight();
|
||||||
core.info(`Running [${cmd}] ...`);
|
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`);
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
try {
|
try {
|
||||||
const res = yield execShellCommand(cmd);
|
const res = yield execShellCommand(cmd, cmdArgs);
|
||||||
printOutput(res);
|
printOutput(res);
|
||||||
core.info(`golangci-lint found no issues`);
|
core.info(`golangci-lint found no issues`);
|
||||||
}
|
}
|
||||||
|
14
dist/run/index.js
vendored
14
dist/run/index.js
vendored
@ -2364,6 +2364,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const child_process_1 = __webpack_require__(129);
|
const child_process_1 = __webpack_require__(129);
|
||||||
|
const fs = __importStar(__webpack_require__(747));
|
||||||
|
const path = __importStar(__webpack_require__(622));
|
||||||
const util_1 = __webpack_require__(669);
|
const util_1 = __webpack_require__(669);
|
||||||
const cache_1 = __webpack_require__(722);
|
const cache_1 = __webpack_require__(722);
|
||||||
const install_1 = __webpack_require__(655);
|
const install_1 = __webpack_require__(655);
|
||||||
@ -2408,11 +2410,19 @@ function runLint(lintPath) {
|
|||||||
if (args.includes(`-out-format`)) {
|
if (args.includes(`-out-format`)) {
|
||||||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
|
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
|
||||||
}
|
}
|
||||||
|
const workingDirectory = core.getInput(`working-directory`);
|
||||||
|
const cmdArgs = {};
|
||||||
|
if (workingDirectory != ``) {
|
||||||
|
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||||
|
throw new Error(`working-directory (${workingDirectory}) was not a path`);
|
||||||
|
}
|
||||||
|
cmdArgs.cwd = path.resolve(workingDirectory);
|
||||||
|
}
|
||||||
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight();
|
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight();
|
||||||
core.info(`Running [${cmd}] ...`);
|
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`);
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
try {
|
try {
|
||||||
const res = yield execShellCommand(cmd);
|
const res = yield execShellCommand(cmd, cmdArgs);
|
||||||
printOutput(res);
|
printOutput(res);
|
||||||
core.info(`golangci-lint found no issues`);
|
core.info(`golangci-lint found no issues`);
|
||||||
}
|
}
|
||||||
|
18
src/run.ts
18
src/run.ts
@ -1,5 +1,7 @@
|
|||||||
import * as core from "@actions/core"
|
import * as core from "@actions/core"
|
||||||
import { exec } from "child_process"
|
import { exec, ExecOptions } from "child_process"
|
||||||
|
import * as fs from "fs"
|
||||||
|
import * as path from "path"
|
||||||
import { promisify } from "util"
|
import { promisify } from "util"
|
||||||
|
|
||||||
import { restoreCache, saveCache } from "./cache"
|
import { restoreCache, saveCache } from "./cache"
|
||||||
@ -55,11 +57,21 @@ async function runLint(lintPath: string): Promise<void> {
|
|||||||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
|
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const workingDirectory = core.getInput(`working-directory`)
|
||||||
|
const cmdArgs: ExecOptions = {}
|
||||||
|
if (workingDirectory != ``) {
|
||||||
|
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||||
|
throw new Error(`working-directory (${workingDirectory}) was not a path`)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdArgs.cwd = path.resolve(workingDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight()
|
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight()
|
||||||
core.info(`Running [${cmd}] ...`)
|
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`)
|
||||||
const startedAt = Date.now()
|
const startedAt = Date.now()
|
||||||
try {
|
try {
|
||||||
const res = await execShellCommand(cmd)
|
const res = await execShellCommand(cmd, cmdArgs)
|
||||||
printOutput(res)
|
printOutput(res)
|
||||||
core.info(`golangci-lint found no issues`)
|
core.info(`golangci-lint found no issues`)
|
||||||
} catch (exc) {
|
} catch (exc) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user