-
Notifications
You must be signed in to change notification settings - Fork 35
240 lines (222 loc) · 9.21 KB
/
main.yml
File metadata and controls
240 lines (222 loc) · 9.21 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: Basic Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
paths-ignore:
- 'CHANGELOG.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
run-install: false
post-cleanup: false
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
cache: false
environments: shellcheck
- name: Run shellcheck
run: pixi run shellcheck
unittest:
name: Unit test - ${{ matrix.package }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- diracx-core
- diracx-db
- diracx-logic
- diracx-routers
- diracx-client
- diracx-api
- diracx-cli
- gubbins-core
- gubbins-db
- gubbins-logic
- gubbins-routers
- gubbins-client
- gubbins-api
- gubbins-cli
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
run-install: false
post-cleanup: false
- name: Apply workarounds
run: |
# Workaround for https://github.com/prefix-dev/pixi/issues/3762
sed -i.bak 's@editable = true@editable = false@g' pixi.toml
rm pixi.toml.bak
# Show any changes
git diff
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
cache: false
environments: ${{ matrix.package }}
- name: Run pytest
run: pixi run pytest-${{ matrix.package }} --cov-report=xml:coverage.xml --junitxml=report.xml
- name: Upload coverage report
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
pytest-integration:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
extension:
- diracx
- gubbins
steps:
- name: Free disk space
run: |
echo "Before cleanup:"
df -h
# remove .NET SDKs
sudo rm -rf /usr/share/dotnet || true
# remove Android SDK
sudo rm -rf usr/local/lib/android || true
# remove Haskell Compiler
sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/.ghcup || true
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."
# prune docker
docker system prune -af || true
echo "After cleanup:"
df -h
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
run-install: false
post-cleanup: false
- name: Apply workarounds
run: |
# Workaround for https://github.com/prefix-dev/pixi/issues/3762
sed -i.bak 's@editable = true@editable = false@g' pixi.toml
rm pixi.toml.bak
# Show any changes
git diff
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
cache: false
environments: ${{ matrix.extension == 'diracx' && 'default' || 'default-gubbins' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Build services image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
context: .
file: containers/Dockerfile
build-args: |
PIXI_ENV=${{ matrix.extension == 'diracx' && 'container-services' || 'gubbins-container-services' }}
tags: ghcr.io/${{ matrix.extension == 'diracx' && 'diracgrid/diracx' || 'gubbins' }}/services:dev
outputs: type=docker,dest=/tmp/services_image.tar
- name: Build client image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
context: .
file: containers/Dockerfile
build-args: |
PIXI_ENV=${{ matrix.extension == 'diracx' && 'container-client' || 'gubbins-container-client' }}
tags: ghcr.io/${{ matrix.extension == 'diracx' && 'diracgrid/diracx' || 'gubbins' }}/client:dev
outputs: type=docker,dest=/tmp/client_image.tar
- name: Load images
run: |
docker load --input /tmp/services_image.tar
rm -f /tmp/services_image.tar
docker load --input /tmp/client_image.tar
rm -f /tmp/client_image.tar
docker builder prune -af || true
docker image ls -a
- name: Start demo
run: |
git clone https://github.com/DIRACGrid/diracx-charts.git ../diracx-charts
declare -a demo_args=()
demo_args+=("--enable-open-telemetry")
demo_args+=("--enable-coverage")
demo_args+=("--exit-when-done")
demo_args+=("--ci-values" "../diracx-charts/demo/ci_values.yaml")
declare -a demo_source_dirs=("$PWD")
# Download helm/kubectl/kind first
../diracx-charts/run_demo.sh --only-download-deps
if [ ${{ matrix.extension }} == 'gubbins' ]; then
demo_args+=("--set-value" "diracx.developer.autoReload=false")
# We have to copy the code to another directory
# and make it a git repository by itself because otherwise the
# root in the pyproject do not make sense once mounted
# in the containers.
cp -r ./extensions/gubbins /tmp/
sed -i 's@../..@.@g' /tmp/gubbins/pyproject.toml
sed -i 's@../../@@g' /tmp/gubbins/gubbins-*/pyproject.toml
git init /tmp/gubbins/
# Copy gubbins-charts to a temporary location and build dependencies
cp -r ./extensions/gubbins-charts /tmp/
../diracx-charts/.demo/helm dependency build /tmp/gubbins-charts
# Replace the downloaded subchart with the locally-cloned one to
# ensure we have the pixi-compatible ConfigMap entrypoint
rm -f /tmp/gubbins-charts/charts/diracx-*.tgz
../diracx-charts/.demo/helm package ../diracx-charts/diracx -d /tmp/gubbins-charts/charts/
demo_args+=("--extension-chart-path" "/tmp/gubbins-charts")
demo_args+=("--ci-values" "./extensions/gubbins_values.yaml")
demo_args+=("--load-docker-image" "ghcr.io/gubbins/services:dev")
demo_args+=("--load-docker-image" "ghcr.io/gubbins/client:dev")
demo_args+=("--prune-loaded-images")
demo_source_dirs+=("/tmp/gubbins/")
elif [ ${{ matrix.extension }} != 'diracx' ]; then
echo "Unknown extension: ${{ matrix.extension }}"
exit 1
else
demo_args+=("--set-value" "developer.autoReload=false")
demo_args+=("--set-value" "global.imagePullPolicy=IfNotPresent")
demo_args+=("--load-docker-image" "ghcr.io/diracgrid/diracx/services:dev")
demo_args+=("--load-docker-image" "ghcr.io/diracgrid/diracx/client:dev")
demo_args+=("--prune-loaded-images")
fi
# Run the demo with the provided arguments
set -x
../diracx-charts/run_demo.sh "${demo_args[@]}" "${demo_source_dirs[@]}"
- name: Debugging information
if: always()
run: .github/scripts/collect-k8s-debug-info.sh "$PWD/../diracx-charts/.demo" "${{ matrix.extension == 'gubbins' && 'gubbins' || 'diracx' }}"
- name: Run pytest
run: |
pixi run pytest-${{ matrix.extension }} --demo-dir="$PWD/../diracx-charts/" --cov-report=xml:coverage-pytest.xml --junitxml=report.xml
- name: Collect demo coverage
run: |
pixi run -e ${{ matrix.extension == 'diracx' && 'default' || 'default-gubbins' }} python -m diracx.testing coverage collect-demo --demo-dir=../diracx-charts/.demo
- name: Upload coverage report
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
with:
files: ./coverage-pytest.xml,./coverage-demo.xml
client-generation:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: [diracx, gubbins]
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
run-install: false
post-cleanup: false
- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
cache: false
locked: false
environments: ${{ matrix.package }}-generate-client
- name: Run autorest
run: pixi run -e ${{ matrix.package }}-generate-client generate-client