Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,27 @@ with:

</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`

(optional)
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inputs:
description: "The mode to install golangci-lint. It can be 'binary', 'goinstall', or 'none'."
default: "binary"
required: false
install-only:
description: "Only install golangci-lint. It does not run golangci-lint."
default: 'false'
required: false
working-directory:
description: "golangci-lint working directory. The default is the project root."
required: false
Expand Down
13 changes: 11 additions & 2 deletions dist/post_run/index.js

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

13 changes: 11 additions & 2 deletions dist/run/index.js

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

19 changes: 17 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ type Env = {
patchPath: string
}

async function prepareEnv(): Promise<Env> {
async function prepareEnv(installOnly: boolean): Promise<Env> {
const startedAt = Date.now()

// Prepare cache, lint and go in parallel.
await restoreCache()

const binPath = await install()

if (installOnly) {
return { binPath, patchPath: `` }
}

const patchPath = await fetchPatch()

core.info(`Prepared env in ${Date.now() - startedAt}ms`)
Expand Down Expand Up @@ -196,8 +201,18 @@ async function getConfigPath(binPath: string, userArgsMap: Map<string, string>,

export async function run(): Promise<void> {
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))

if (installOnly) {
return
}

await core.group(`run golangci-lint`, () => runLint(binPath, patchPath))
} catch (error) {
core.error(`Failed to run: ${error}, ${error.stack}`)
Expand Down
Loading