Skip to content

Commit e7fa5ac

Browse files
authored
feat: automatic module directories (#1315)
1 parent f3ae99f commit e7fa5ac

File tree

18 files changed

+542
-276
lines changed

18 files changed

+542
-276
lines changed

.github/workflows/test.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,30 @@ jobs:
146146
version: ${{ matrix.version }}
147147
working-directory: sample-plugins
148148
args: --timeout=5m --issues-exit-code=0 ./...
149+
150+
test-monorepo:
151+
needs: [ build ]
152+
strategy:
153+
matrix:
154+
os:
155+
- ubuntu-latest
156+
- ubuntu-22.04-arm
157+
- macos-latest
158+
- windows-latest
159+
runs-on: ${{ matrix.os }}
160+
permissions:
161+
contents: read
162+
pull-requests: read
163+
steps:
164+
- uses: actions/checkout@v5
165+
- uses: actions/setup-node@v6
166+
with:
167+
node-version: 24.x
168+
- uses: actions/setup-go@v6
169+
with:
170+
go-version: oldstable
171+
- uses: ./
172+
with:
173+
working-directory: sample-monorepo
174+
experimental: "automatic-module-directories"
175+
args: --timeout=5m --issues-exit-code=0 ./...

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ You will also likely need to add the following `.gitattributes` file to ensure t
275275
| [`skip-save-cache`](#skip-save-cache) | Don't save cache. |
276276
| [`cache-invalidation-interval`](#cache-invalidation-interval) | Number of days before cache invalidation. |
277277
| [`problem-matchers`](#problem-matchers) | Forces the usage of the embedded problem matchers. |
278+
| [Experimental](#experimental) | Experimental options |
278279

279280
### Installation
280281

@@ -552,6 +553,47 @@ with:
552553

553554
</details>
554555

556+
### Experimental
557+
558+
The following options are experimental: those may or may not be supported in the future, and so they will be either converted into a dedicated option or removed.
559+
560+
List of comma-separated options.
561+
562+
<details>
563+
<summary>Example</summary>
564+
565+
```yaml
566+
uses: golangci/golangci-lint-action@v9
567+
with:
568+
experimental: "foo,bar"
569+
```
570+
571+
</details>
572+
573+
#### `automatic-module-directories`
574+
575+
(optional)
576+
577+
This option will run golangci-lint in each module directory, useful for monorepos.
578+
579+
The automatic detection of modules uses the `working-directory` as the base directory if defined, otherwise the root directory.
580+
581+
> [!IMPORTANT]
582+
> - The cache key will refer to the `working-directory` (if defined) because all the golangci-lint runs must use the same cache directory/key.
583+
> - The version detection will only work if the project has a single module.
584+
> - If the project has multiple modules, the custom build file must be located in the repository root ( or `working-directory`).
585+
586+
<details>
587+
<summary>Example</summary>
588+
589+
```yaml
590+
uses: golangci/golangci-lint-action@v9
591+
with:
592+
experimental: "automatic-module-directories"
593+
```
594+
595+
</details>
596+
555597
## Annotations
556598

557599
Currently, GitHub parses the action's output and creates [annotations](https://github.blog/2018-12-14-introducing-check-runs-and-annotations/).

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ inputs:
6565
example: "cache,clean"
6666
default: ""
6767
required: false
68+
experimental:
69+
description: |
70+
Experimental options for the action.
71+
List of comma separated options.
72+
default: ""
73+
required: false
6874
runs:
6975
using: "node24"
7076
main: "dist/run/index.js"

0 commit comments

Comments
 (0)