Skip to content

Commit 3fccbc4

Browse files
committed
GitHub Actions use matrix strategy on go-test
Signed-off-by: Smyslov Maxim <maksim.smyslov@flant.com>
1 parent d82d47b commit 3fccbc4

1 file changed

Lines changed: 14 additions & 20 deletions

File tree

.github/workflows/go-test.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,30 @@ jobs:
2424
git diff --exit-code go.mod
2525
git diff --exit-code go.sum
2626
27-
lint:
27+
detect-modules:
2828
runs-on: ubuntu-latest
29+
outputs:
30+
modules: ${{ steps.set-modules.outputs.modules }}
2931
steps:
3032
- uses: actions/checkout@v4
3133
- uses: actions/setup-go@v5
3234
with:
3335
go-version: ${{ env.GO_VERSION }}
34-
- name: lint
35-
uses: golangci/golangci-lint-action@v8
36-
with:
37-
version: ${{ env.GOLANGCI_LINT_VERSION }}
38-
39-
tests:
40-
needs: lint
41-
runs-on: ubuntu-latest
42-
steps:
43-
- uses: actions/checkout@v4
44-
- uses: actions/setup-go@v5
45-
with:
46-
go-version: ${{ env.GO_VERSION }}
47-
- name: Run tests
48-
run: go test ./... -race
36+
- run: go work init && find . -name go.mod|sed -r 's/(.*)(go.mod)/use \1/g' >> go.work # kludge
37+
- id: set-modules
38+
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT
4939

50-
tests-examples:
51-
needs: tests
40+
go-test:
41+
needs: detect-modules
5242
runs-on: ubuntu-latest
43+
strategy:
44+
matrix:
45+
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
5346
steps:
5447
- uses: actions/checkout@v4
5548
- uses: actions/setup-go@v5
5649
with:
5750
go-version: ${{ env.GO_VERSION }}
58-
- name: Submodules test
59-
run: go work init && find . -name go.mod|sed -r 's/(.*)(go.mod)/use \1/g' >> go.work && find . -name go.mod -execdir go test ./... -race \;
51+
- run: go work init && find . -name go.mod|sed -r 's/(.*)(go.mod)/use \1/g' >> go.work # kludge
52+
- run: go test ./... -race
53+
working-directory: ${{ matrix.modules }}

0 commit comments

Comments
 (0)