1+ name : PR CI
2+
13on :
24 push :
35 branches :
46 - main
7+ - fix/*
58 pull_request :
69 branches :
710 - main
@@ -12,13 +15,37 @@ concurrency:
1215 cancel-in-progress : ${{ github.event_name == 'pull_request' }}
1316
1417permissions :
15- contents : read # for actions/checkout to fetch code
18+ contents : read
1619
17- name : PR CI Workflow
1820jobs :
19- ci-js :
20- name : CI Test JS
21+
22+ # Static analysis and code quality
23+ lint :
24+ name : Lint and format check
2125 runs-on : ubuntu-latest
26+ steps :
27+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
28+ - name : Setup Go
29+ uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
30+ with :
31+ go-version-file : go.mod
32+ - run : make check-format
33+ - run : make lint
34+ - run : go mod tidy
35+ - name : Verify go mod tidy
36+ run : git diff --no-ext-diff --exit-code
37+ - run : make proto
38+ - name : Verify proto generation
39+ run : git diff --no-ext-diff --exit-code
40+ - run : make fakes
41+ - name : Verify fakes generation
42+ run : git diff --no-ext-diff --exit-code
43+
44+ # Test JavaScript/UI
45+ test-js :
46+ name : Test JavaScript
47+ runs-on : ubuntu-latest
48+ needs : lint
2249 steps :
2350 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2451 - name : Setup Node.js
@@ -27,21 +54,20 @@ jobs:
2754 node-version-file : package.json
2855 cache : yarn
2956 - run : make node_modules
30- - name : Check that package.json & package-lock.json were updated in commit
31- run : |
32- echo "Using node.js "$(node --version)
33- echo "Using Yarn "$(yarn --version)
34- git diff --no-ext-diff --exit-code
57+ - name : Verify package files
58+ run : git diff --no-ext-diff --exit-code
3559 - run : make ui-audit
3660 - run : make ui
3761 - run : make ui-lint
3862 - run : make ui-prettify-check
3963 - run : make ui-test
4064 - run : make ui-lib
4165
42- ci-go :
43- name : CI Test Go
66+ # Test Go code
67+ test-go :
68+ name : Test Go
4469 runs-on : ubuntu-latest
70+ needs : lint
4571 steps :
4672 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4773 - name : Setup Go
@@ -52,130 +78,27 @@ jobs:
5278 uses : fluxcd/flux2/action@4a15fa6a023259353ef750acf1c98fe88407d4d0 # v2.7.2
5379 - run : make unit-tests
5480
55- ci-static :
56- name : CI Check Static Checks
57- runs-on : ubuntu-latest
58- steps :
59- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
60- - name : Setup Go
61- uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
62- with :
63- go-version-file : go.mod
64- - run : make check-format
65- - run : make lint
66- - run : go mod tidy
67- - name : Check that go mod tidy has been run
68- run : git diff --no-ext-diff --exit-code
69- - run : make proto
70- - name : Check that make proto has been run
71- run : git diff --no-ext-diff --exit-code
72- - run : make fakes
73- - name : Check that make fakes has been run
74- run : git diff --no-ext-diff --exit-code
7581
76- build-push-image :
77- name : CI Build Image
82+ # Build Docker images (but don't push on PRs)
83+ build-images :
84+ name : Build Docker Images
7885 uses : ./.github/workflows/build-push-image.yaml
86+ needs :
87+ - test-go
88+ - test-js
7989 with :
8090 file : ${{ matrix.docker-image }}.dockerfile
8191 image : ghcr.io/${{ github.repository }}/${{ matrix.docker-image }}
82- push : ${{ github.event_name != 'pull_request' && github.repository == 'weaveworks/weave-gitops' }}
92+ push : ${{ github.event_name != 'pull_request' }}
8393 tags : |
8494 type=ref,event=branch
8595 type=ref,event=pr
8696 permissions :
87- contents : read # for actions/checkout to fetch code
88- id-token : write # for Cosign to be able to sign images with GHA token
89- packages : write # for docker/build-push-action to push images
97+ contents : read
98+ id-token : write
99+ packages : write
90100 strategy :
91101 matrix :
92102 docker-image :
93103 - gitops
94104 - gitops-server
95-
96- ci-upload-binary :
97- name : Upload Binary - Disabled
98- runs-on : ${{ matrix.os }}
99- needs : [ci-go, ci-static, ci-js]
100- strategy :
101- matrix :
102- os : [ubuntu-latest, macOS-latest]
103- if : ${{ github.event_name != 'pull_request' && github.repository == 'weaveworks/weave-gitops' }}
104- steps :
105- - name : Checkout code
106- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
107- - name : Setup Go
108- uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
109- with :
110- go-version-file : go.mod
111- - name : Clean
112- run : make clean
113- - id : gitsha
114- run : |
115- gitsha=$(git rev-parse --short ${{ github.sha }})
116- echo "sha=$gitsha" >> $GITHUB_OUTPUT
117- - name : build
118- run : |
119- make gitops
120- - name : Upload binary
121- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
122- with :
123- name : gitops-${{ matrix.os }}-${{ steps.gitsha.outputs.sha }}
124- path : bin/gitops
125- overwrite : true
126-
127- ci-publish-js-lib :
128- name : Publish js library
129- runs-on : ubuntu-latest
130- if : " ${{ github.repository_owner == 'weaveworks' && github.ref_name == 'main'}}"
131- needs : [ci-js]
132- permissions :
133- packages : write
134- outputs :
135- js-version : ${{ steps.package-version.outputs.js-version }}
136- steps :
137- - name : Checkout
138- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
139- with :
140- # avoid the merge commit that on.pull_request creates
141- # fallback to github.sha if not present (e.g. on.push(main))
142- # https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit
143- # We want the correct sha so we can tag the npm package correctly
144- ref : ${{ github.event.pull_request.head.sha || github.sha }}
145- fetch-depth : 0
146- - name : Setup Node.js
147- uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
148- with :
149- node-version-file : package.json
150- registry-url : " https://npm.pkg.github.com"
151- scope : " @weaveworks"
152- - run : yarn
153- - run : make ui-lib
154- - name : Update package version
155- id : package-version
156- run : |
157- GITOPS_VERSION=$(git describe)
158- echo "js-version=$GITOPS_VERSION" >> $GITHUB_OUTPUT
159- jq '.version = "'$GITOPS_VERSION'" | .name = "@weaveworks/weave-gitops-main"' < dist/package.json > dist/package-new.json
160- mv dist/package-new.json dist/package.json
161- cp .npmrc dist
162- - run : cd dist && npm publish
163- env :
164- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
165-
166- # release step updates 'release' status check for non releases branches. See ../../doc/incidents/issues-3907 for full context.
167- release :
168- if : ${{ github.event_name == 'pull_request' && !startsWith(github.event.pull_request.head.ref, 'releases/') && !github.event.pull_request.head.repo.fork }}
169- runs-on : ubuntu-latest
170- steps :
171- - name : Release
172- run : |
173- curl --fail --request POST \
174- --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
175- --header 'authorization: Bearer ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }}' \
176- --header 'content-type: application/json' \
177- --data '{
178- "state":"success",
179- "description":"release not required",
180- "context":"release"
181- }'
0 commit comments