Skip to content

Commit 3f209d7

Browse files
committed
Improve build times
1 parent ff67740 commit 3f209d7

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed

.github/.cache/buster-for-binary

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/.cache/buster-for-generate

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/.cache/buster-for-unit-tests

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/.cache/buster-for-vars

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/ci.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
go-version: stable
138138
cache-dependency-path: |
139139
go.sum
140-
.github/.cache/buster-for-vars
140+
tests/go.sum
141141
142142
- name: Check for changes
143143
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -192,7 +192,7 @@ jobs:
192192
go-version: stable
193193
cache-dependency-path: |
194194
go.sum
195-
.github/.cache/buster-for-unit-tests
195+
tests/go.sum
196196
197197
- name: Run Tests
198198
run: make unit-test
@@ -221,6 +221,8 @@ jobs:
221221
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
222222
with:
223223
node-version-file: .nvmrc
224+
cache: 'npm'
225+
cache-dependency-path: internal/controller/nginx/modules/package-lock.json
224226

225227
- name: Run tests
226228
run: npm --prefix ${{ github.workspace }}/internal/controller/nginx/modules install-ci-test
@@ -267,7 +269,7 @@ jobs:
267269
go-version: stable
268270
cache-dependency-path: |
269271
go.sum
270-
.github/.cache/buster-for-binary
272+
tests/go.sum
271273
272274
- name: Set Go module cache
273275
run: |
@@ -299,7 +301,9 @@ jobs:
299301
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
300302
with:
301303
version: v2.12.7 # renovate: datasource=github-tags depName=goreleaser/goreleaser
302-
args: ${{ (inputs.is_production_release && (inputs.dry_run == false || inputs.dry_run == null)) && 'release' || 'build --snapshot' }} --clean
304+
# On PRs: build only amd64 for speed (tests run on amd64 runners)
305+
# On main/release: build both amd64 and arm64
306+
args: ${{ (inputs.is_production_release && (inputs.dry_run == false || inputs.dry_run == null)) && 'release' || (github.event_name == 'pull_request' && 'build --single-target --snapshot' || 'build --snapshot') }} --clean
303307
env:
304308
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
305309
GOPATH: ${{ needs.vars.outputs.go_path }}
@@ -408,7 +412,9 @@ jobs:
408412
fail-fast: false
409413
matrix:
410414
image: [ngf, nginx]
411-
platforms: ["linux/arm64, linux/amd64"]
415+
# On PRs: build only amd64 for speed (tests run on amd64)
416+
# On main/release: build both amd64 and arm64
417+
platforms: ${{ github.event_name == 'pull_request' && fromJSON('["linux/amd64"]') || fromJSON('["linux/arm64, linux/amd64"]') }}
412418
# On PRs: only standard OS (2 jobs)
413419
# On main/release: include ubi (4 jobs)
414420
build-os: ${{ github.event_name == 'pull_request' && fromJSON('[""]') || fromJSON('["", "ubi"]') }}
@@ -439,7 +445,9 @@ jobs:
439445
build-os: ${{ github.event_name == 'pull_request' && fromJSON('[""]') || fromJSON('["", "ubi"]') }}
440446
with:
441447
image: plus
442-
platforms: "linux/arm64, linux/amd64"
448+
# On PRs: build only amd64 for speed (tests run on amd64)
449+
# On main/release: build both amd64 and arm64
450+
platforms: ${{ github.event_name == 'pull_request' && 'linux/amd64' || 'linux/arm64, linux/amd64' }}
443451
build-os: ${{ matrix.build-os }}
444452
tag: ${{ inputs.release_version || '' }}
445453
dry_run: ${{ inputs.dry_run || false }}
@@ -457,7 +465,9 @@ jobs:
457465
uses: ./.github/workflows/build.yml
458466
with:
459467
image: operator
460-
platforms: "linux/arm64, linux/amd64"
468+
# On PRs: build only amd64 for speed (tests run on amd64)
469+
# On main/release: build both amd64 and arm64
470+
platforms: ${{ github.event_name == 'pull_request' && 'linux/amd64' || 'linux/arm64, linux/amd64' }}
461471
tag: ${{ inputs.operator_version || '' }}
462472
dry_run: ${{ inputs.dry_run || false }}
463473
runner: ${{ github.repository_owner == 'nginx' && (inputs.is_production_release || ((github.event_name == 'push' || github.event_name == 'schedule') && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-')))) && 'ubuntu-24.04-amd64' || 'ubuntu-24.04' }}
@@ -591,7 +601,7 @@ jobs:
591601
go-version: stable
592602
cache-dependency-path: |
593603
go.sum
594-
.github/.cache/buster-for-unit-tests
604+
tests/go.sum
595605
596606
- name: Deploy Kubernetes
597607
id: k8s

.github/workflows/lint.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
4646
with:
4747
go-version: stable
48+
cache-dependency-path: |
49+
go.sum
50+
tests/go.sum
4851
4952
- name: Lint Go
5053
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
@@ -63,6 +66,8 @@ jobs:
6366
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
6467
with:
6568
node-version-file: .nvmrc
69+
cache: 'npm'
70+
cache-dependency-path: internal/controller/nginx/modules/package-lock.json
6671

6772
- name: Run Prettier on NJS code
6873
id: prettier-run

.github/workflows/renovate-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
go-version: stable
6767
cache-dependency-path: |
6868
go.sum
69-
.github/.cache/buster-for-generate
69+
tests/go.sum
7070
7171
# go mod tidy can be removed once https://github.com/renovatebot/renovate/issues/12999 is implemented
7272
- name: Update files for renovate

0 commit comments

Comments
 (0)