11# CI: proto and commitlint; fan-out Go (fmt, lint, unit-tests) || UI (ui-lint, ui-test);
22# then build (gitops, gitops-server). On tag: image, chart, goreleaser.
33#
4- # Flow: pr-title-lint (if PR; else skipped) -> conventional-commits (if !tag;
5- # runs when pr-title-lint success or skipped) -> proto (make proto, git diff)
6- # in parallel with ui-lint, ui-test. Then go-fmt,
7- # go-lint, go-unit-tests (need proto). Then build
8- # (make gitops, make gitops-server). Tag jobs (image, chart, goreleaser) need build .
4+ # Flow: vars (sets run_release_jobs: true when ref is v* tag OR workflow_dispatch with run_release_jobs=true) and conventional-commits run first.
5+ # conventional-commits -> pr-title-lint (if PR), proto, ui-lint, ui-test -> go-* -> build.
6+ # Release jobs (build-push-gitops-server, build-and-push-chart, goreleaser) need [build, vars] and
7+ # if: needs.vars.outputs.run_release_jobs == 'true'.
8+ # workflow_dispatch input run_release_jobs is the sentinel when release.yaml (or manual) invokes CI via API .
99# No make clean (each run is a fresh checkout).
1010#
1111# On tag (v*): build-push-gitops-server (provenance, SBOM, cosign), build-and-push-chart
@@ -15,11 +15,17 @@ name: CI
1515
1616on :
1717 push :
18- branches : [main, feature/re-implement-workflows ]
18+ branches : [main]
1919 tags : ["v*"]
2020 pull_request :
21- branches : [main, feature/re-implement-workflows ]
21+ branches : [main]
2222 workflow_dispatch :
23+ inputs :
24+ run_release_jobs :
25+ description : " Run image, chart and goreleaser jobs (release build). Set when dispatching to (re-)run release, or when invoked by release.yaml."
26+ required : false
27+ default : false
28+ type : boolean
2329
2430concurrency :
2531 group : ${{ github.workflow }}-${{ github.ref }}
3339 PYTHON_VERSION : " 3.12"
3440
3541jobs :
42+ vars :
43+ name : Set CI vars
44+ runs-on : ubuntu-latest
45+ outputs :
46+ run_release_jobs : ${{ steps.set_vars.outputs.is_release_tag == 'true' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_release_jobs == 'true') }}
47+ steps :
48+ - uses : actions/checkout@v4
49+ - uses : actions/setup-python@v5
50+ with :
51+ python-version : " 3.12"
52+ cache : " pip"
53+ - run : pip install -e ./tooling
54+ - id : set_vars
55+ run : echo "is_release_tag=$(weavetooling ci is-tag)" >> $GITHUB_OUTPUT
56+
57+ conventional-commits :
58+ name : Conventional Commits
59+ runs-on : ubuntu-latest
60+ steps :
61+ - uses : actions/checkout@v4
62+ with :
63+ fetch-depth : 0
64+ - uses : wagoid/commitlint-github-action@v5
65+
3666 pr-title-lint :
3767 name : Validate PR title
68+ needs : [conventional-commits]
3869 runs-on : ubuntu-latest
3970 if : github.event_name == 'pull_request'
4071 permissions :
@@ -71,21 +102,36 @@ jobs:
71102 header : pr-title-lint-error
72103 delete : true
73104
74- conventional-commits :
75- name : Conventional Commits
105+ ui-lint :
106+ name : UI lint
76107 needs : [pr-title-lint]
77108 runs-on : ubuntu-latest
78- if : always() && (needs.pr-title-lint.result == 'success' || needs.pr-title-lint.result == 'skipped') && !startsWith(github.ref, 'refs/tags/')
79109 steps :
80110 - uses : actions/checkout@v4
111+ - uses : actions/setup-node@v4
81112 with :
82- fetch-depth : 0
83- - uses : wagoid/commitlint-github-action@v5
113+ node-version-file : package.json
114+ cache : yarn
115+ - run : make node_modules
116+ - run : make ui-lint
117+ - run : make ui-audit
84118
119+ ui-test :
120+ name : UI test
121+ needs : [pr-title-lint]
122+ runs-on : ubuntu-latest
123+ steps :
124+ - uses : actions/checkout@v4
125+ - uses : actions/setup-node@v4
126+ with :
127+ node-version-file : package.json
128+ cache : yarn
129+ - run : make node_modules
130+ - run : make ui-test
131+
85132 proto :
86133 name : Proto (generate + git diff)
87- needs : [conventional-commits]
88- if : always() && (needs.conventional-commits.result == 'success' || needs.conventional-commits.result == 'skipped')
134+ needs : [pr-title-lint]
89135 runs-on : ubuntu-latest
90136 steps :
91137 - uses : actions/checkout@v4
@@ -101,7 +147,7 @@ jobs:
101147
102148 go-fmt :
103149 name : Go fmt
104- needs : [proto]
150+ needs : [proto, ui-lint, ui-test ]
105151 runs-on : ubuntu-latest
106152 steps :
107153 - uses : actions/checkout@v4
@@ -112,7 +158,7 @@ jobs:
112158
113159 go-lint :
114160 name : Go lint
115- needs : [proto]
161+ needs : [proto, ui-lint, ui-test ]
116162 runs-on : ubuntu-latest
117163 steps :
118164 - uses : actions/checkout@v4
@@ -123,7 +169,7 @@ jobs:
123169
124170 go-unit-tests :
125171 name : Go unit-tests
126- needs : [proto]
172+ needs : [proto, ui-lint, ui-test ]
127173 runs-on : ubuntu-latest
128174 steps :
129175 - uses : actions/checkout@v4
@@ -141,41 +187,9 @@ jobs:
141187 version : ${{ steps.get_flux_version.outputs.version }}
142188 - run : make unit-tests
143189
144- ui-lint :
145- name : UI lint
146- needs : [conventional-commits]
147- if : always() && (needs.conventional-commits.result == 'success' || needs.conventional-commits.result == 'skipped')
148- runs-on : ubuntu-latest
149- steps :
150- - uses : actions/checkout@v4
151- - uses : actions/setup-node@v4
152- with :
153- node-version-file : package.json
154- cache : yarn
155- - run : make node_modules
156- - run : make ui-lint
157- # Re-enable after workflow re-org when ui-audit errors are fixed
158- - name : UI audit (skipped)
159- if : false
160- run : make ui-audit
161-
162- ui-test :
163- name : UI test
164- needs : [conventional-commits]
165- if : always() && (needs.conventional-commits.result == 'success' || needs.conventional-commits.result == 'skipped')
166- runs-on : ubuntu-latest
167- steps :
168- - uses : actions/checkout@v4
169- - uses : actions/setup-node@v4
170- with :
171- node-version-file : package.json
172- cache : yarn
173- - run : make node_modules
174- - run : make ui-test
175-
176190 build :
177191 name : Build (gitops, gitops-server)
178- needs : [go-fmt, go-lint, go-unit-tests, ui-lint, ui-test ]
192+ needs : [go-fmt, go-lint, go-unit-tests]
179193 runs-on : ubuntu-latest
180194 steps :
181195 - uses : actions/checkout@v4
@@ -188,8 +202,8 @@ jobs:
188202 # --- Tag-only: image, chart, goreleaser ---
189203 build-push-gitops-server :
190204 name : Build and push gitops-server image
191- needs : [build]
192- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && needs.build.result == 'success '
205+ needs : [build, vars ]
206+ if : needs.vars.outputs.run_release_jobs == 'true '
193207 runs-on : ubuntu-latest
194208 permissions :
195209 contents : read
@@ -251,8 +265,8 @@ jobs:
251265
252266 build-and-push-chart :
253267 name : Build and push Helm chart
254- needs : [build]
255- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && needs.build.result == 'success '
268+ needs : [build, vars ]
269+ if : needs.vars.outputs.run_release_jobs == 'true '
256270 runs-on : ubuntu-latest
257271 permissions :
258272 contents : read
@@ -296,8 +310,8 @@ jobs:
296310
297311 goreleaser :
298312 name : Goreleaser (gitops CLI)
299- needs : [build]
300- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && needs.build.result == 'success '
313+ needs : [build, vars ]
314+ if : needs.vars.outputs.run_release_jobs == 'true '
301315 runs-on : ubuntu-latest
302316 permissions :
303317 contents : write
0 commit comments