-
Notifications
You must be signed in to change notification settings - Fork 16
240 lines (238 loc) · 7.55 KB
/
compose_test.yaml
File metadata and controls
240 lines (238 loc) · 7.55 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
name: Docker Compose CI
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- main
jobs:
changes:
runs-on: ubuntu-latest
outputs:
all: ${{ toJson(steps.changed-files.outputs) }}
steps:
- uses: actions/checkout@v6
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v47
with:
files_yaml_from_source_file: .github/changed_files.yaml
yaml-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).yaml_all_modified_files
steps:
- uses: actions/checkout@v6
- name: Install 'yamllint'
run: sudo apt-get install -y yamllint
- name: Lint YAML files
run: yamllint -c .github/yamllint_config.yaml .
json-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).json_all_modified_files
steps:
- uses: actions/checkout@v6
- name: Install 'jsonlint' and 'git'
run: sudo apt install python3-demjson git
- name: Lint JSON files
run: >-
git ls-files -z '*.json' | xargs -0r jsonlint -s --allow=non-portable
shell-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).sh_all_modified_files
steps:
- uses: actions/checkout@v6
- name: Install 'shellcheck' and 'git'
run: sudo apt install shellcheck git
- name: Lint shell files ([ba]sh scripts)
run: >-
git ls-files -z '*.sh' '*.bash' '*.ksh' '*.bashrc' '*.bash_profile'
'*.bash_login' '*.bash_logout' | xargs -0r shellcheck
javascript-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).js_all_modified_files
steps:
- uses: actions/checkout@v6
- name: Use Node.js v20
uses: actions/setup-node@v6
with:
node-version: 24
- name: install eslint and default rules
run: npm install eslint @eslint/js --save-dev
- name: Lint javascript files
run: npx eslint --config .github/eslint.config.mjs
- name: Lint html files
run: find . -name "*.html" -o -name ".*.html" | xargs npx --yes htmlhint
python-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).python_all_modified_files
steps:
- uses: actions/checkout@v6
- uses: chartboost/ruff-action@v1
with:
args: check --select ALL
markdown-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).mds_all_modified_files
steps:
- uses: actions/checkout@v6
- name: Check markdown links
uses: lycheeverse/lychee-action@v2
with:
args: >-
--no-progress --root-dir . '**/*.md'
fail: true
- uses: DavidAnson/markdownlint-cli2-action@v23
with:
globs: |
**/*.md
!**/node_modules/**
config: .github/markdownlint/.markdownlint-cli2.yaml
check-mkdocs:
runs-on: ubuntu-latest
needs:
- changes
- yaml-lint
- python-lint
- javascript-lint
- markdown-lint
if: >
!failure()
&& !cancelled()
&& fromJson(needs.changes.outputs.all).docs_all_modified_files
steps:
- uses: SciCatProject/scicatlive/.github/actions/mkdocs-pages@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCS_LINK_CHECK: true
TAG: ${{ github.sha }}
docs_folder: ''
test:
runs-on: ubuntu-latest
needs:
- changes
- yaml-lint
- json-lint
- shell-lint
- javascript-lint
- python-lint
- check-mkdocs
if: >
! failure()
&& ! cancelled()
&& fromJson(needs.changes.outputs.all).src_all_modified_files
strategy:
matrix:
BE_VERSION: [v3, v4]
ELASTIC_ENABLED: ['', elastic]
JOBS_ENABLED: ['', jobs]
LDAP_ENABLED: ['', ldap]
OIDC_ENABLED: ['', oidc]
DEV: ['', dev]
GENERATE_SDK: ['']
exclude:
- BE_VERSION: ${{
!fromJson(needs.changes.outputs.all).v3_all_modified_files
&& 'v3' || 'nothing'
}}
- ELASTIC_ENABLED: ${{
!fromJson(needs.changes.outputs.all).elastic_all_modified_files
&& 'elastic' || 'nothing'
}}
- JOBS_ENABLED: ${{
!fromJson(needs.changes.outputs.all).jobs_all_modified_files
&& 'jobs' || 'nothing'
}}
- LDAP_ENABLED: ${{
!fromJson(needs.changes.outputs.all).ldap_all_modified_files
&& 'ldap' || 'nothing'
}}
- OIDC_ENABLED: ${{
!fromJson(needs.changes.outputs.all).oidc_all_modified_files
&& 'oidc' || 'nothing'
}}
- DEV: ${{
!fromJson(needs.changes.outputs.all).dev_all_modified_files
&& 'dev' || 'nothing'
}}
- ELASTIC_ENABLED: elastic
BE_VERSION: v3
include:
- BE_VERSION: v4
DEV: dev
GENERATE_SDK: generate_sdk
steps:
- uses: actions/checkout@v6
- name: Test compose.yaml
id: docker_up
continue-on-error: ${{ matrix.GENERATE_SDK == 'generate_sdk' }}
run: |-
export JOBS_ENABLED=${{ matrix.JOBS_ENABLED }}
export ELASTIC_ENABLED=${{ matrix.ELASTIC_ENABLED }}
export LDAP_ENABLED=${{ matrix.LDAP_ENABLED }}
export OIDC_ENABLED=${{ matrix.OIDC_ENABLED }}
export BE_VERSION=${{ matrix.BE_VERSION }}
export DEV=${{ matrix.DEV }}
export DEV_BBACKUP=${DEV}
export GENERATE_SDK=${{ matrix.GENERATE_SDK }}
docker compose --profile '*' \
-f compose.yaml ${DEV:+-f .github/compose.dev.test.yaml} \
up --wait --wait-timeout 1200 \
|| {
docker compose ps --status=exited --services \
| while read service; do
echo "Logs for $service"
docker compose logs "$service"
done
exit 1
}
- name: Add Failure Label
if: >-
steps.docker_up.outcome == 'failure' &&
matrix.GENERATE_SDK == 'generate_sdk'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ github.event.pull_request.number }} --body \
"## ⚠️ SDK Generation Failed
The SDK test failed. This is non-blocking, but please check \
the logs before merging."
gh pr edit ${{ github.event.pull_request.number }} --add-label \
"sdk-failed"
- name: Cleanup Failure Label
if: >-
steps.docker_up.outcome == 'success' &&
matrix.GENERATE_SDK == 'generate_sdk'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Remove the label if it exists (ignore error if it's already gone)
gh pr label remove ${{ github.event.pull_request.number }} \
--name "sdk-failed" || true
tests-status:
runs-on: ubuntu-latest
if: always()
needs:
- changes
- yaml-lint
- json-lint
- shell-lint
- javascript-lint
- python-lint
- markdown-lint
- check-mkdocs
- test
steps:
- name: Evaluate Results
run: |
RES="${{ join(needs.*.result, ' ') }}"
[[ $RES =~ "failure" || $RES =~ "cancelled" ]] && exit 1 || exit 0