-
Notifications
You must be signed in to change notification settings - Fork 11
274 lines (250 loc) · 10.4 KB
/
Copy pathci.yaml
File metadata and controls
274 lines (250 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: CI
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
permissions:
contents: write
pull-requests: write
issues: write
actions: write
statuses: write
checks: write
repository-projects: read
id-token: write
packages: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch }}
jobs:
pr-size-check:
if: ${{ github.event_name == 'pull_request' && !contains(github.head_ref, 'release-please') }}
name: PR Size Check
runs-on: ubuntu-latest
permissions:
statuses: write
pull-requests: read
steps:
- name: Validate PR Size
uses: SolaceDev/solace-public-workflows/.github/actions/pr-size-check@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
max-lines: 1500
# Validate conventional commits for PRs
validate-conventional-commit:
name: "Validate Conventional Commit"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && !contains(github.head_ref, 'release-please') && github.event.pull_request.user.login != 'dependabot[bot]'
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Validate PR Title
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
deps
revert
requireScope: false
disallowScopes: |
release
subjectPattern: ^.+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
is not empty.
# Label PR based on changed files and determine which plugins to build
label-pr:
runs-on: ubuntu-24.04
outputs:
all_plugins: ${{ steps.resolve-changed.outputs.all_plugins }}
pr_number: ${{ steps.resolve-changed.outputs.pr_number }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Label PR based on changes
id: label-pr
if: github.event_name == 'pull_request'
uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: true
configuration-path: .github/pr_labeler.yaml
- name: Resolve changed plugins and build matrix payload
id: resolve-changed
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: python3 .github/scripts/resolve_changed_plugins.py
# Build and test each plugin that changed
builds:
needs: label-pr
if: needs.label-pr.result == 'success' && needs.label-pr.outputs.all_plugins != '[]'
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.label-pr.outputs.all_plugins) }}
name: Build Plugin - ${{ matrix.plugin_directory }}
uses: ./.github/workflows/build-plugin.yaml
with:
plugin_directory: ${{ matrix.plugin_directory }}
secrets:
COMMIT_KEY: ${{ secrets.COMMIT_KEY }}
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
SONARQUBE_HOST_URL: ${{ secrets.SONARQUBE_HOST_URL }}
# CI Status check - aggregates all job results
ci-status:
name: CI Status
runs-on: ubuntu-latest
needs: [label-pr, builds]
if: always() && needs.label-pr.result == 'success'
permissions:
pull-requests: write
issues: write
checks: write
actions: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Download plugin result artifacts
if: always() && github.event_name == 'pull_request' && needs.label-pr.outputs.all_plugins != '[]' && (needs.builds.result == 'success' || needs.builds.result == 'skipped')
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: ci-plugin-result-*
merge-multiple: true
path: ci-plugin-results
- name: Run reusable release readiness aggregation
id: release_readiness_gate
if: always() && github.event_name == 'pull_request' && contains(github.head_ref, 'release-please') && needs.label-pr.outputs.all_plugins != '[]' && (needs.builds.result == 'success' || needs.builds.result == 'skipped')
continue-on-error: true
uses: SolaceDev/solace-public-workflows/pr-release-readiness-check@main
with:
pr_number: ${{ github.event.pull_request.number }}
github_token: ${{ github.token }}
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
sonarqube_token: ${{ secrets.SONARQUBE_TOKEN }}
sonarqube_host_url: ${{ secrets.SONARQUBE_HOST_URL }}
repo_owner: ${{ github.repository_owner }}
base_branch: main
check_name: Release Readiness Check
comment_marker: Release Readiness Check Results
update_pr_comment: "true"
update_check_details: "true"
fail_on_issues: "true"
- name: Publish SonarQube Quality Gate check
id: sonar_gate
if: always() && github.event_name == 'pull_request' && !contains(github.head_ref, 'release-please') && needs.label-pr.outputs.all_plugins != '[]' && (needs.builds.result == 'success' || needs.builds.result == 'skipped')
continue-on-error: true
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
uses: SolaceDev/solace-public-workflows/monorepo-ci-report-status@main
with:
check_type: sonarqube
projects_json: ${{ needs.label-pr.outputs.all_plugins }}
results_dir: ci-plugin-results
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ github.event.pull_request.number }}
sonarqube_host_url: ${{ secrets.SONARQUBE_HOST_URL }}
check_name: SonarQube Quality Gate
comment_on_pr: "true"
comment_marker: SonarQube Quality Gate
update_check_details: "true"
fail_on_issues: "true"
- name: Publish Unit Tests check
id: unit_tests_gate
if: always() && github.event_name == 'pull_request' && !contains(github.head_ref, 'release-please') && needs.label-pr.outputs.all_plugins != '[]' && (needs.builds.result == 'success' || needs.builds.result == 'skipped')
continue-on-error: true
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
uses: SolaceDev/solace-public-workflows/monorepo-ci-report-status@main
with:
check_type: unit-tests
projects_json: ${{ needs.label-pr.outputs.all_plugins }}
results_dir: ci-plugin-results
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ github.event.pull_request.number }}
check_name: Unit Tests
comment_on_pr: "false"
update_check_details: "true"
fail_on_issues: "true"
- name: Publish FOSSA Guard check
id: fossa_guard_gate
if: always() && github.event_name == 'pull_request' && !contains(github.head_ref, 'release-please') && needs.label-pr.outputs.all_plugins != '[]' && (needs.builds.result == 'success' || needs.builds.result == 'skipped')
continue-on-error: true
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
uses: SolaceDev/solace-public-workflows/monorepo-fossa-diff-report@main
with:
projects_json: ${{ needs.label-pr.outputs.all_plugins }}
repo_owner: ${{ github.repository_owner }}
head_ref: ${{ github.head_ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: FOSSA Guard
comment_on_pr: "true"
comment_marker: FOSSA Guard (PR Diff)
update_check_details: "true"
fail_on_issues: "true"
- name: Check CI status
run: |
fail() {
echo "$1"
exit 1
}
if [[ "${{ needs.label-pr.outputs.all_plugins }}" == "[]" ]]; then
echo "No plugins changed, skipping build and quality checks"
exit 0
fi
if [[ "${{ needs.builds.result }}" != "success" && "${{ needs.builds.result }}" != "skipped" ]]; then
fail "Build jobs failed"
fi
echo "Build jobs passed or were skipped"
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
echo "All CI checks passed!"
exit 0
fi
if [[ "${{ github.head_ref }}" == *"release-please"* ]]; then
if [[ "${{ steps.release_readiness_gate.outcome }}" != "success" && "${{ steps.release_readiness_gate.outcome }}" != "skipped" ]]; then
fail "Release readiness check failed"
fi
echo "Release readiness check passed or was skipped"
echo "All CI checks passed!"
exit 0
fi
if [[ "${{ steps.sonar_gate.outcome }}" != "success" && "${{ steps.sonar_gate.outcome }}" != "skipped" ]]; then
fail "SonarQube quality gate failed"
fi
echo "SonarQube quality gate passed or was skipped"
if [[ "${{ steps.unit_tests_gate.outcome }}" != "success" && "${{ steps.unit_tests_gate.outcome }}" != "skipped" ]]; then
fail "Unit tests gate failed"
fi
echo "Unit tests gate passed or was skipped"
if [[ "${{ steps.fossa_guard_gate.outcome }}" != "success" && "${{ steps.fossa_guard_gate.outcome }}" != "skipped" ]]; then
fail "FOSSA guard failed"
fi
echo "FOSSA guard passed or was skipped"
echo "All CI checks passed!"