Skip to content

Commit e28ee43

Browse files
committed
CI: parallelizing tests
1 parent 77b3446 commit e28ee43

File tree

1 file changed

+49
-37
lines changed

1 file changed

+49
-37
lines changed

.github/workflows/go.yml

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Go
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
permissions:
1010
contents: read
@@ -39,6 +39,9 @@ jobs:
3939
uses: actions/setup-go@v6
4040
with:
4141
go-version-file: go.work
42+
cache: true
43+
cache-dependency-path: |
44+
**/go.sum
4245
id: go
4346
- name: sync go modules
4447
run: make workspace-sync
@@ -59,12 +62,16 @@ jobs:
5962
uses: actions/setup-go@v6
6063
with:
6164
go-version-file: go.work
65+
cache: true
66+
cache-dependency-path: |
67+
**/go.sum
6268
id: go
6369
- name: Lint
6470
run: make lint
6571
- name: Verify boilerplate
6672
run: make check-license
6773

74+
## test all module in this repo
6875
test-linux:
6976
name: Test Linux
7077
needs: conditional-changes
@@ -77,54 +84,59 @@ jobs:
7784
uses: actions/setup-go@v6
7885
with:
7986
go-version-file: go.work
87+
cache: true
88+
cache-dependency-path: |
89+
**/go.sum
8090
id: go
8191
- name: Test all modules
8292
run: make test-unit-non-plugin
8393
env:
8494
KUSTOMIZE_DOCKER_E2E: true
8595

86-
test-macos:
87-
name: Test MacOS
96+
test-modules:
97+
name: Test ${{ matrix.os }} - ${{ matrix.module }}
8898
needs: conditional-changes
8999
# if: needs.conditional-changes.outputs.doc == 'false'
90-
runs-on: [macos-latest]
100+
runs-on: ${{ matrix.os }}
101+
strategy:
102+
fail-fast: false
103+
matrix:
104+
os: [ubuntu-latest, macos-latest, windows-latest]
105+
module:
106+
- kyaml
107+
- cmd/config
108+
- api
109+
- kustomize
110+
include:
111+
- module: kyaml
112+
test-cmd: go test -race -v -cover ./...
113+
- module: cmd/config
114+
test-cmd: go test -v -cover ./...
115+
- module: api
116+
test-cmd: go test -v -cover ./... -ldflags "-X sigs.k8s.io/kustomize/api/provenance.buildDate=2023-01-31T23:38:41Z -X sigs.k8s.io/kustomize/api/provenance.version=(test)"
117+
- module: kustomize
118+
test-cmd: go test -v -cover ./...
119+
- os: ubuntu-latest
120+
docker-e2e: true
121+
- os: macos-latest
122+
docker-e2e: false
123+
- os: windows-latest
124+
docker-e2e: false
125+
env:
126+
KUSTOMIZE_DOCKER_E2E: ${{ matrix.docker-e2e }}
91127
steps:
92128
- name: Check out code into the Go module directory
93129
uses: actions/checkout@v5
94130
- name: Set up Go 1.x
95131
uses: actions/setup-go@v6
96132
with:
97133
go-version-file: go.work
134+
cache: true
135+
cache-dependency-path: |
136+
**/go.sum
98137
id: go
99-
- name: Test all modules
100-
run: make test-unit-non-plugin
101-
env:
102-
KUSTOMIZE_DOCKER_E2E: false # docker not installed on mac
103-
104-
test-windows:
105-
name: Test Windows
106-
needs: conditional-changes
107-
# if: needs.conditional-changes.outputs.doc == 'false'
108-
runs-on: [windows-latest]
109-
steps:
110-
- name: Check out code into the Go module directory
111-
uses: actions/checkout@v5
112-
- name: Set up Go 1.x
113-
uses: actions/setup-go@v6
114-
with:
115-
go-version-file: go.work
116-
id: go
117-
- name: Test kyaml
118-
run: go test -cover ./...
119-
working-directory: ./kyaml
120-
- name: Test cmd/config
121-
run: go test -cover ./...
122-
working-directory: ./cmd/config
123-
env:
124-
KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet
125-
126-
# TODO (#4001): replace specific modules above with this once Windows tests are passing.
127-
#- name: Test all modules
128-
# run: make test-unit-non-plugin
129-
# env:
130-
# KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet
138+
- name: Test ${{ matrix.module }}
139+
run: ${{ matrix.test-cmd }}
140+
# TODO (#4001): replace specific modules above with this once Windows tests are passing.
141+
if: ${{ !(matrix.os == 'windows-latest' && (matrix.module == 'api' || matrix.module == 'kustomize')) }}
142+
working-directory: ./${{ matrix.module }}

0 commit comments

Comments
 (0)