mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2025-12-12 14:01:14 +00:00
feat: add install-only option (#1305)
This commit is contained in:
parent
7fe1b22e0c
commit
a66d26a465
5 changed files with 64 additions and 6 deletions
21
README.md
21
README.md
|
|
@ -302,6 +302,27 @@ with:
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
### `install-only`
|
||||||
|
|
||||||
|
(optional)
|
||||||
|
|
||||||
|
If set to `true`, the action will only install golangci-lint.
|
||||||
|
It does not run golangci-lint.
|
||||||
|
|
||||||
|
The default value is `false`.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Example</summary>
|
||||||
|
|
||||||
|
```yml
|
||||||
|
uses: golangci/golangci-lint-action@v8
|
||||||
|
with:
|
||||||
|
install-only: true
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
### `github-token`
|
### `github-token`
|
||||||
|
|
||||||
(optional)
|
(optional)
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@ inputs:
|
||||||
description: "The mode to install golangci-lint. It can be 'binary', 'goinstall', or 'none'."
|
description: "The mode to install golangci-lint. It can be 'binary', 'goinstall', or 'none'."
|
||||||
default: "binary"
|
default: "binary"
|
||||||
required: false
|
required: false
|
||||||
|
install-only:
|
||||||
|
description: "Only install golangci-lint. It does not run golangci-lint."
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
working-directory:
|
working-directory:
|
||||||
description: "golangci-lint working directory. The default is the project root."
|
description: "golangci-lint working directory. The default is the project root."
|
||||||
required: false
|
required: false
|
||||||
|
|
|
||||||
13
dist/post_run/index.js
generated
vendored
13
dist/post_run/index.js
generated
vendored
|
|
@ -97343,11 +97343,14 @@ const cache_1 = __nccwpck_require__(7377);
|
||||||
const install_1 = __nccwpck_require__(232);
|
const install_1 = __nccwpck_require__(232);
|
||||||
const patch_1 = __nccwpck_require__(7161);
|
const patch_1 = __nccwpck_require__(7161);
|
||||||
const execShellCommand = (0, util_1.promisify)(child_process_1.exec);
|
const execShellCommand = (0, util_1.promisify)(child_process_1.exec);
|
||||||
async function prepareEnv() {
|
async function prepareEnv(installOnly) {
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
// Prepare cache, lint and go in parallel.
|
// Prepare cache, lint and go in parallel.
|
||||||
await (0, cache_1.restoreCache)();
|
await (0, cache_1.restoreCache)();
|
||||||
const binPath = await (0, install_1.install)();
|
const binPath = await (0, install_1.install)();
|
||||||
|
if (installOnly) {
|
||||||
|
return { binPath, patchPath: `` };
|
||||||
|
}
|
||||||
const patchPath = await (0, patch_1.fetchPatch)();
|
const patchPath = await (0, patch_1.fetchPatch)();
|
||||||
core.info(`Prepared env in ${Date.now() - startedAt}ms`);
|
core.info(`Prepared env in ${Date.now() - startedAt}ms`);
|
||||||
return { binPath, patchPath };
|
return { binPath, patchPath };
|
||||||
|
|
@ -97483,8 +97486,14 @@ async function getConfigPath(binPath, userArgsMap, cmdArgs) {
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv);
|
const installOnly = core.getBooleanInput(`install-only`, { required: true });
|
||||||
|
const { binPath, patchPath } = await core.group(`prepare environment`, () => {
|
||||||
|
return prepareEnv(installOnly);
|
||||||
|
});
|
||||||
core.addPath(path.dirname(binPath));
|
core.addPath(path.dirname(binPath));
|
||||||
|
if (installOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await core.group(`run golangci-lint`, () => runLint(binPath, patchPath));
|
await core.group(`run golangci-lint`, () => runLint(binPath, patchPath));
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
||||||
13
dist/run/index.js
generated
vendored
13
dist/run/index.js
generated
vendored
|
|
@ -97343,11 +97343,14 @@ const cache_1 = __nccwpck_require__(7377);
|
||||||
const install_1 = __nccwpck_require__(232);
|
const install_1 = __nccwpck_require__(232);
|
||||||
const patch_1 = __nccwpck_require__(7161);
|
const patch_1 = __nccwpck_require__(7161);
|
||||||
const execShellCommand = (0, util_1.promisify)(child_process_1.exec);
|
const execShellCommand = (0, util_1.promisify)(child_process_1.exec);
|
||||||
async function prepareEnv() {
|
async function prepareEnv(installOnly) {
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
// Prepare cache, lint and go in parallel.
|
// Prepare cache, lint and go in parallel.
|
||||||
await (0, cache_1.restoreCache)();
|
await (0, cache_1.restoreCache)();
|
||||||
const binPath = await (0, install_1.install)();
|
const binPath = await (0, install_1.install)();
|
||||||
|
if (installOnly) {
|
||||||
|
return { binPath, patchPath: `` };
|
||||||
|
}
|
||||||
const patchPath = await (0, patch_1.fetchPatch)();
|
const patchPath = await (0, patch_1.fetchPatch)();
|
||||||
core.info(`Prepared env in ${Date.now() - startedAt}ms`);
|
core.info(`Prepared env in ${Date.now() - startedAt}ms`);
|
||||||
return { binPath, patchPath };
|
return { binPath, patchPath };
|
||||||
|
|
@ -97483,8 +97486,14 @@ async function getConfigPath(binPath, userArgsMap, cmdArgs) {
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv);
|
const installOnly = core.getBooleanInput(`install-only`, { required: true });
|
||||||
|
const { binPath, patchPath } = await core.group(`prepare environment`, () => {
|
||||||
|
return prepareEnv(installOnly);
|
||||||
|
});
|
||||||
core.addPath(path.dirname(binPath));
|
core.addPath(path.dirname(binPath));
|
||||||
|
if (installOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await core.group(`run golangci-lint`, () => runLint(binPath, patchPath));
|
await core.group(`run golangci-lint`, () => runLint(binPath, patchPath));
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
||||||
19
src/run.ts
19
src/run.ts
|
|
@ -16,13 +16,18 @@ type Env = {
|
||||||
patchPath: string
|
patchPath: string
|
||||||
}
|
}
|
||||||
|
|
||||||
async function prepareEnv(): Promise<Env> {
|
async function prepareEnv(installOnly: boolean): Promise<Env> {
|
||||||
const startedAt = Date.now()
|
const startedAt = Date.now()
|
||||||
|
|
||||||
// Prepare cache, lint and go in parallel.
|
// Prepare cache, lint and go in parallel.
|
||||||
await restoreCache()
|
await restoreCache()
|
||||||
|
|
||||||
const binPath = await install()
|
const binPath = await install()
|
||||||
|
|
||||||
|
if (installOnly) {
|
||||||
|
return { binPath, patchPath: `` }
|
||||||
|
}
|
||||||
|
|
||||||
const patchPath = await fetchPatch()
|
const patchPath = await fetchPatch()
|
||||||
|
|
||||||
core.info(`Prepared env in ${Date.now() - startedAt}ms`)
|
core.info(`Prepared env in ${Date.now() - startedAt}ms`)
|
||||||
|
|
@ -196,8 +201,18 @@ async function getConfigPath(binPath: string, userArgsMap: Map<string, string>,
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv)
|
const installOnly = core.getBooleanInput(`install-only`, { required: true })
|
||||||
|
|
||||||
|
const { binPath, patchPath } = await core.group(`prepare environment`, () => {
|
||||||
|
return prepareEnv(installOnly)
|
||||||
|
})
|
||||||
|
|
||||||
core.addPath(path.dirname(binPath))
|
core.addPath(path.dirname(binPath))
|
||||||
|
|
||||||
|
if (installOnly) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
await core.group(`run golangci-lint`, () => runLint(binPath, patchPath))
|
await core.group(`run golangci-lint`, () => runLint(binPath, patchPath))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error(`Failed to run: ${error}, ${error.stack}`)
|
core.error(`Failed to run: ${error}, ${error.stack}`)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue