Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
64c208bfbc | |||
20d5541dab | |||
85a3a6abe4 | |||
b66692b61d | |||
348830fe4b |
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -23,4 +23,5 @@ jobs:
|
||||
- uses: ./
|
||||
with:
|
||||
version: v1.26
|
||||
args: --issues-exit-code=0 ./sample/...
|
||||
args: --issues-exit-code=0 ./...
|
||||
working-directory: sample
|
||||
|
10
README.md
10
README.md
@ -27,15 +27,21 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v0.2.0
|
||||
uses: golangci/golangci-lint-action@v1
|
||||
with:
|
||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||
version: v1.26
|
||||
|
||||
# Optional: working directory, useful for monorepos
|
||||
# working-directory: somedir
|
||||
|
||||
# Optional: golangci-lint command line arguments.
|
||||
# args: ./the-only-dir-to-analyze/...
|
||||
# args: --issues-exit-code=0
|
||||
```
|
||||
|
||||
We recommend running this action in a job separate from other jobs (`go test`, etc)
|
||||
because different jobs [run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job).
|
||||
|
||||
## Comments and Annotations
|
||||
|
||||
Currently, GitHub parses the action's output and creates [annotations](https://github.community/t5/GitHub-Actions/What-are-annotations/td-p/30770).
|
||||
|
10
action.yml
10
action.yml
@ -1,6 +1,6 @@
|
||||
---
|
||||
name: 'Run golangci-lint'
|
||||
description: 'Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution. Beta version.'
|
||||
description: 'Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution.'
|
||||
author: 'golangci'
|
||||
inputs:
|
||||
version:
|
||||
@ -10,9 +10,9 @@ inputs:
|
||||
description: 'golangci-lint command line arguments'
|
||||
default: ''
|
||||
required: false
|
||||
github-token:
|
||||
description: 'GitHub token with scope `repo.public_repo`. Used for fetching a list of releases of golangci-lint.'
|
||||
required: true
|
||||
working-directory:
|
||||
description: 'golangci-lint working directory, default is project root'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
@ -20,4 +20,4 @@ runs:
|
||||
post: 'dist/post_run/index.js'
|
||||
branding:
|
||||
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 });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
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 cache_1 = __webpack_require__(722);
|
||||
const install_1 = __webpack_require__(655);
|
||||
@ -2396,11 +2398,19 @@ function runLint(lintPath) {
|
||||
if (args.includes(`-out-format`)) {
|
||||
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();
|
||||
core.info(`Running [${cmd}] ...`);
|
||||
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`);
|
||||
const startedAt = Date.now();
|
||||
try {
|
||||
const res = yield execShellCommand(cmd);
|
||||
const res = yield execShellCommand(cmd, cmdArgs);
|
||||
printOutput(res);
|
||||
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 });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
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 cache_1 = __webpack_require__(722);
|
||||
const install_1 = __webpack_require__(655);
|
||||
@ -2408,11 +2410,19 @@ function runLint(lintPath) {
|
||||
if (args.includes(`-out-format`)) {
|
||||
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();
|
||||
core.info(`Running [${cmd}] ...`);
|
||||
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`);
|
||||
const startedAt = Date.now();
|
||||
try {
|
||||
const res = yield execShellCommand(cmd);
|
||||
const res = yield execShellCommand(cmd, cmdArgs);
|
||||
printOutput(res);
|
||||
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 { 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 { 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`)
|
||||
}
|
||||
|
||||
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()
|
||||
core.info(`Running [${cmd}] ...`)
|
||||
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`)
|
||||
const startedAt = Date.now()
|
||||
try {
|
||||
const res = await execShellCommand(cmd)
|
||||
const res = await execShellCommand(cmd, cmdArgs)
|
||||
printOutput(res)
|
||||
core.info(`golangci-lint found no issues`)
|
||||
} catch (exc) {
|
||||
|
Reference in New Issue
Block a user