2323 GOPROXY : " direct"
2424
2525jobs :
26- proxy-sanity-check :
27- name : Proxy Sanity Check
26+ cache-dependencies :
27+ name : Cache Dependencies
2828 runs-on : ubuntu-22.04
29- if : ${{ !github.event.pull_request.head.repo.fork && !startsWith(github.head_ref, 'dependabot-') }}
30- env :
31- GOPROXY : " https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_URL_DEV }}"
29+ if : github.ref == 'refs/heads/main'
3230 steps :
33- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
34- with :
31+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32+ with :
3533 fetch-tags : ' true'
36- - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
37- with :
34+ - name : Configure Go Proxy
35+ uses : ./.github/actions/configure-goproxy
36+ with :
37+ user : ${{ secrets.ARTIFACTORY_USER }}
38+ token : ${{ secrets.ARTIFACTORY_TOKEN }}
39+ url : ${{ secrets.ARTIFACTORY_URL_DEV }}
40+ - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
41+ with :
3842 go-version-file : ' go.mod'
3943 cache : false
40- - name : run goproxy-sanity-check
41- run : |
42- make build
44+ - name : Download Go modules
45+ run : go mod download
46+ - name : Setup Build Environment
47+ run : go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
48+ - name : Fix golang dependency permissions
49+ run : chmod -R 0755 ~/go/pkg/mod ~/.cache/go-build
50+ - uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
51+ with :
52+ path : |
53+ ~/.cache/go-build
54+ ~/go/pkg/mod
55+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
56+ restore-keys : |
57+ ${{ runner.os }}-go-
4358
4459 lint :
4560 name : Lint
@@ -54,84 +69,112 @@ jobs:
5469 url : ${{ secrets.ARTIFACTORY_URL_DEV }}
5570 - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
5671 with :
57- go-version-file : ' go.mod'
58- cache : false
72+ go-version-file : ' go.mod'
73+ cache : false
74+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
75+ with :
76+ path : |
77+ ~/.cache/go-build
78+ ~/go/pkg/mod
79+ key : ${{ runner.os }}-go-
5980 - name : Lint Go
6081 uses : golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
6182 with :
6283 version : v2.4.0
6384
6485 unit-test :
65- name : Unit Tests
66- runs-on : ubuntu-22.04
67- permissions :
68- contents : write
69- steps :
70- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
71- - name : Configure Go Proxy
72- uses : ./.github/actions/configure-goproxy
73- with :
74- user : ${{ secrets.ARTIFACTORY_USER }}
75- token : ${{ secrets.ARTIFACTORY_TOKEN }}
76- url : ${{ secrets.ARTIFACTORY_URL_DEV }}
77- - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
78- with :
79- go-version-file : ' go.mod'
80- cache : false
81- - name : Run Unit Tests
82- run : make unit-test
83- - name : Uplaod Test Coverage
84- uses : codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
85- with :
86- files : ./build/test/coverage.out
87- token : ${{ secrets.CODECOV_TOKEN }}
86+ name : Unit Tests
87+ runs-on : ubuntu-22.04
88+ permissions :
89+ contents : write
90+ steps :
91+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
92+ - name : Configure Go Proxy
93+ uses : ./.github/actions/configure-goproxy
94+ with :
95+ user : ${{ secrets.ARTIFACTORY_USER }}
96+ token : ${{ secrets.ARTIFACTORY_TOKEN }}
97+ url : ${{ secrets.ARTIFACTORY_URL_DEV }}
98+ - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
99+ with :
100+ go-version-file : ' go.mod'
101+ cache : false
102+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
103+ with :
104+ path : |
105+ ~/.cache/go-build
106+ ~/go/pkg/mod
107+ key : ${{ runner.os }}-go-
108+ - name : Run Unit Tests
109+ run : make unit-test
110+ - name : Uplaod Test Coverage
111+ uses : codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
112+ with :
113+ files : ./build/test/coverage.out
114+ token : ${{ secrets.CODECOV_TOKEN }}
88115
89116 race-condition-test :
90- name : Unit tests with race condition detection
91- runs-on : ubuntu-22.04
92- steps :
93- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
94- - name : Configure Go Proxy
95- uses : ./.github/actions/configure-goproxy
96- with :
97- user : ${{ secrets.ARTIFACTORY_USER }}
98- token : ${{ secrets.ARTIFACTORY_TOKEN }}
99- url : ${{ secrets.ARTIFACTORY_URL_DEV }}
100- - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
101- with :
102- go-version-file : ' go.mod'
103- cache : false
104- - name : Run unit tests with race condition detection
105- run : make race-condition-test
117+ name : Unit tests with race condition detection
118+ runs-on : ubuntu-22.04
119+ steps :
120+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
121+ - name : Configure Go Proxy
122+ uses : ./.github/actions/configure-goproxy
123+ with :
124+ user : ${{ secrets.ARTIFACTORY_USER }}
125+ token : ${{ secrets.ARTIFACTORY_TOKEN }}
126+ url : ${{ secrets.ARTIFACTORY_URL_DEV }}
127+ - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
128+ with :
129+ go-version-file : ' go.mod'
130+ cache : false
131+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
132+ with :
133+ path : |
134+ ~/.cache/go-build
135+ ~/go/pkg/mod
136+ key : ${{ runner.os }}-go-
137+ - name : Run unit tests with race condition detection
138+ run : make race-condition-test
106139
107140 build-unsigned-snapshot :
108- name : Build Unsigned Snapshot
109- runs-on : ubuntu-22.04
110- steps :
111- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
112- with :
113- fetch-tags : ' true'
114- - name : Configure Go Proxy
115- uses : ./.github/actions/configure-goproxy
116- with :
117- user : ${{ secrets.ARTIFACTORY_USER }}
118- token : ${{ secrets.ARTIFACTORY_TOKEN }}
119- url : ${{ secrets.ARTIFACTORY_URL_DEV }}
120- - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
121- with :
122- go-version-file : ' go.mod'
123- cache : false
124- - name : Setup Build Environment
125- run : go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
126- - name : Build Packages
127- run : |
128- make clean local-deb-package local-rpm-package local-apk-package
129- - name : Upload Artifacts
130- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
131- with :
132- name : nginx-agent-unsigned-snapshots
133- path : build
134- retention-days : 1
141+ name : Build Unsigned Snapshot
142+ runs-on : ubuntu-22.04
143+ steps :
144+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
145+ with :
146+ fetch-tags : ' true'
147+ - name : Configure Go Proxy
148+ uses : ./.github/actions/configure-goproxy
149+ with :
150+ user : ${{ secrets.ARTIFACTORY_USER }}
151+ token : ${{ secrets.ARTIFACTORY_TOKEN }}
152+ url : ${{ secrets.ARTIFACTORY_URL_DEV }}
153+ - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
154+ with :
155+ go-version-file : ' go.mod'
156+ cache : false
157+ - name : Download Go modules
158+ run : go mod download
159+ - name : Setup Build Environment
160+ run : go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
161+ - name : Fix golang dependency permissions
162+ run : chmod -R 0755 ~/go/pkg/mod ~/.cache/go-build
163+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
164+ with :
165+ path : |
166+ ~/.cache/go-build
167+ ~/go/pkg/mod
168+ key : ${{ runner.os }}-go-
169+ - name : Build Packages
170+ run : |
171+ make clean local-deb-package local-rpm-package local-apk-package
172+ - name : Upload Artifacts
173+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
174+ with :
175+ name : nginx-agent-unsigned-snapshots
176+ path : build
177+ retention-days : 1
135178
136179 integration-tests :
137180 name : Integration Tests
@@ -158,6 +201,12 @@ jobs:
158201 with :
159202 go-version-file : ' go.mod'
160203 cache : false
204+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
205+ with :
206+ path : |
207+ ~/.cache/go-build
208+ ~/go/pkg/mod
209+ key : ${{ runner.os }}-go-
161210 - name : Download Packages
162211 uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
163212 with :
@@ -208,6 +257,12 @@ jobs:
208257 with :
209258 go-version-file : ' go.mod'
210259 cache : false
260+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
261+ with :
262+ path : |
263+ ~/.cache/go-build
264+ ~/go/pkg/mod
265+ key : ${{ runner.os }}-go-
211266 - name : Download Packages
212267 uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
213268 with :
@@ -265,6 +320,12 @@ jobs:
265320 with :
266321 go-version-file : ' go.mod'
267322 cache : false
323+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
324+ with :
325+ path : |
326+ ~/.cache/go-build
327+ ~/go/pkg/mod
328+ key : ${{ runner.os }}-go-
268329 - name : Download Packages
269330 uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
270331 with :
@@ -332,6 +393,12 @@ jobs:
332393 with :
333394 go-version-file : ' go.mod'
334395 cache : false
396+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
397+ with :
398+ path : |
399+ ~/.cache/go-build
400+ ~/go/pkg/mod
401+ key : ${{ runner.os }}-go-
335402 - name : Download Packages
336403 uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
337404 with :
@@ -398,6 +465,12 @@ jobs:
398465 with :
399466 go-version-file : ' go.mod'
400467 cache : false
468+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
469+ with :
470+ path : |
471+ ~/.cache/go-build
472+ ~/go/pkg/mod
473+ key : ${{ runner.os }}-go-
401474 - name : Download Packages
402475 uses : actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
403476 with :
@@ -465,6 +538,12 @@ jobs:
465538 with :
466539 go-version-file : ' go.mod'
467540 cache : false
541+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
542+ with :
543+ path : |
544+ ~/.cache/go-build
545+ ~/go/pkg/mod
546+ key : ${{ runner.os }}-go-
468547 - name : Download Packages
469548 uses : actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
470549 with :
@@ -502,6 +581,7 @@ jobs:
502581 performance-tests :
503582 name : Performance Tests
504583 runs-on : ubuntu-22.04
584+ needs : build-unsigned-snapshot
505585 permissions :
506586 contents : write
507587 steps :
@@ -516,6 +596,12 @@ jobs:
516596 with :
517597 go-version-file : ' go.mod'
518598 cache : false
599+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
600+ with :
601+ path : |
602+ ~/.cache/go-build
603+ ~/go/pkg/mod
604+ key : ${{ runner.os }}-go-
519605 - name : Run Performance Tests
520606 run : |
521607 make performance-test
@@ -534,21 +620,28 @@ jobs:
534620 - name : Push benchmark result
535621 if : ${{ success() && github.ref_name == 'main'}}
536622 run : git push 'https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/nginx/agent.git' benchmark-results:benchmark-results
623+
537624 load-tests :
538625 name : Load Tests
539626 if : ${{ !github.event.pull_request.head.repo.fork && !startsWith(github.head_ref, 'dependabot-') }}
540627 permissions :
541628 contents : write
542629 runs-on : ubuntu-22.04
543630 needs : build-unsigned-snapshot
544-
545631 steps :
546632 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
547633 - uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
548634 with :
549635 go-version-file : ' go.mod'
550636 cache : false
551637
638+ - uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
639+ with :
640+ path : |
641+ ~/.cache/go-build
642+ ~/go/pkg/mod
643+ key : ${{ runner.os }}-go-
644+
552645 - name : Download Packages
553646 uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
554647 with :
0 commit comments