-
Notifications
You must be signed in to change notification settings - Fork 6
330 lines (292 loc) · 12.9 KB
/
gubbins-test.yml
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
name: Gubbins extension Tests
on:
push:
paths-ignore:
- 'packages/diracx-web/**'
branches-ignore:
- dependabot/**
- release-please-**
pull_request:
branches-ignore:
- release-please-**
jobs:
# Run lint and type checks
run-lint:
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
- name: Install dependencies
run: npm ci
# ========================================================================#
# WARNING: In your CI/CD pipeline, you should remove the following step #
# ------------------------------------------------------------------------#
- name: Build Library
run: npm run build:diracx-web-components
# ------------------------------------------------------------------------#
# ========================================================================#
- name: Check code-quality rules
run: npm --prefix packages/extensions run lint
- name: Check typescript type validity
run: npm --prefix packages/extensions run ts-lint
# ============================================================================#
# WARNING: In your CI/CD pipeline, you should remove the following jobs #
# ----------------------------------------------------------------------------#
# By default, the gubbins extension is part of a monorepo and uses a local #
# version of `diracx-web-components`. This default setup is not #
# representative of a standalone extension configuration. Here we want to #
# closely mimic a standalone extension. To do so, we: #
# - Isolate the packages/extensions directory: Move its content to a new #
# repository or directory outside the monorepo. #
# - Update Configuration: Adjust relevant variables to align with a #
# standalone setup. #
prepare-gubbins-backend:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web' }}
defaults:
run:
# We need extglob for REFERENCE_BRANCH substitution
shell: bash -l -O extglob {0}
steps:
- name: Clone source
run: |
cd ..
git clone https://github.com/DIRACGrid/diracx.git
# Prepare the gubbins extension
- name: Where the magic happens (Move extensions to a temporary directory)
run: |
# We have to copy the code to another directory
# and make it a git repository by itself because otherwise the
# root in the pyproject to do not make sense once mounted
# in the containers.
cp -r ../diracx/extensions/gubbins /tmp/
sed -i 's@../..@.@g' /tmp/gubbins/pyproject.toml
sed -i 's@../../@@g' /tmp/gubbins/gubbins-*/pyproject.toml
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gubbins
path: /tmp/gubbins
include-hidden-files: true
# Prepare the gubbins image
# - Build the gubbins wheels
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Installing dependencies
run: |
cd ../diracx
python -m pip install \
build \
python-dateutil \
pytz \
readme_renderer[md] \
requests \
setuptools_scm
- name: Build distributions
run: |
cd ../diracx
for pkg_dir in $PWD/diracx-*; do
echo "Building $pkg_dir"
python -m build --outdir $PWD/dist $pkg_dir
done
# Also build the diracx metapackage
python -m build --outdir $PWD/dist .
# And build the gubbins package
for pkg_dir in $PWD/extensions/gubbins/gubbins-*; do
# Skip the testing package
if [[ "${pkg_dir}" =~ .*testing.* ]];
then
echo "Do not build ${pkg_dir}";
continue;
fi
echo "Building $pkg_dir"
python -m build --outdir $PWD/dist $pkg_dir
done
- name: "Find wheels"
id: find_wheel
run: |
cd ../diracx/dist
# We need to copy them there to be able to access them in the RUN --mount
cp diracx*.whl gubbins*.whl ../extensions/containers/services/
for wheel_fn in *.whl; do
pkg_name=$(basename "${wheel_fn}" | cut -d '-' -f 1)
echo "${pkg_name}-wheel-name=$(ls "${pkg_name}"-*.whl)" >> $GITHUB_OUTPUT
done
# - Build the gubbins image using the wheels
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export service
uses: docker/build-push-action@v6
with:
context: ../diracx/extensions/containers/services
tags: gubbins/services:dev
outputs: type=docker,dest=/tmp/gubbins_services_image.tar
build-args: |
EXTRA_PACKAGES_TO_INSTALL=git+https://github.com/DIRACGrid/DIRAC.git@integration
EXTENSION_CUSTOM_SOURCES_TO_INSTALL=/bindmount/gubbins_db*.whl,/bindmount/gubbins_routers*.whl,/bindmount/gubbins_client*.whl
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gubbins-services-img
path: /tmp/gubbins_services_image.tar
prepare-gubbins-frontend-as-a-standalone:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Build diracx-web-components
working-directory: packages/diracx-web-components
run: |
npm pack
- name: Where the magic happens (Move extensions to a temporary directory)
run: |
# Move the extensions to the temporary directory
cp -r packages/extensions /tmp/gubbins-web
# Move the library package to the extensions directory
mv packages/diracx-web-components/*.tgz /tmp/gubbins-web/diracx-web-components.tgz
# Update the package.json to point to the local diracx-web-components
jq '.dependencies["@dirac-grid/diracx-web-components"] = "file:./diracx-web-components.tgz"' /tmp/gubbins-web/package.json > /tmp/gubbins-web/package.temp.json
mv /tmp/gubbins-web/package.temp.json /tmp/gubbins-web/package.json
# Update the package.json to point to the correct postinstall script
jq '.scripts.postinstall = "node ./node_modules/@axa-fr/react-oidc/bin/copy-service-worker-files.mjs public"' /tmp/gubbins-web/package.json > /tmp/gubbins-web/package.temp.json
mv /tmp/gubbins-web/package.temp.json /tmp/gubbins-web/package.json
# Update the next.config.js to prevent the standalone extension from searching a local version of diracx-web-components that does not exist
echo 'const nextConfig = { output: "export", images: { unoptimized: true }}; export default nextConfig;' > /tmp/gubbins-web/next.config.js
- name: Install extensions dependencies
working-directory: /tmp/gubbins-web
run: npm install
- name: Upload the extensions directory
uses: actions/upload-artifact@v4
with:
name: gubbins-web
path: /tmp/gubbins-web
retention-days: 1
# ----------------------------------------------------------------------------#
# In the following jobs, you should: #
# - Replace /tmp/gubbins-web with the path to your extension source code #
# - Remove the `needs: prepare-gubbins-as-a-standalone` line #
# ============================================================================#
# Build the extension image
build-gubbins-dev-image:
runs-on: ubuntu-latest
needs: prepare-gubbins-frontend-as-a-standalone
if: ${{ github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web' }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# ========================================================================#
# WARNING: In your CI/CD pipeline, you should remove the following steps #
# ------------------------------------------------------------------------#
- name: Download gubbins-web
uses: actions/download-artifact@v4
with:
name: gubbins-web
path: /tmp/gubbins-web
# ------------------------------------------------------------------------#
# ========================================================================#
# In your extension, you have to push the image to the registry (check deployment.yml)
- name: Build Docker image (extension example)
uses: docker/build-push-action@v6
with:
context: /tmp/gubbins-web
push: false
tags: ghcr.io/diracgrid/diracx-web/gubbins:dev
platforms: linux/amd64,linux/arm64
# Run the demo with the extension source code (frontend and backend)
run-demo:
runs-on: ubuntu-latest
needs: [prepare-gubbins-frontend-as-a-standalone, prepare-gubbins-backend]
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web'
steps:
- uses: actions/checkout@v4
- name: Clone source
run: |
cd ..
git clone https://github.com/DIRACGrid/diracx-charts.git
# ========================================================================#
# WARNING: In your CI/CD pipeline, you should remove the following steps #
# ------------------------------------------------------------------------#
- name: Download gubbins
uses: actions/download-artifact@v4
with:
name: gubbins
path: /tmp/gubbins
- name: Create a new git repository
run: |
git init /tmp/gubbins/
- name: Clone diracx source
run: |
cd ..
git clone https://github.com/DIRACGrid/diracx.git
- name: Download gubbins:services image
uses: actions/download-artifact@v4
with:
name: gubbins-services-img
path: /tmp/
- name: Load docker image
run: docker load --input /tmp/gubbins_services_image.tar
- name: Download gubbins-web
uses: actions/download-artifact@v4
with:
name: gubbins-web
path: /tmp/gubbins-web
# ------------------------------------------------------------------------#
# ========================================================================#
# Runs the demo with the extension source code
- name: Start demo
run: |
cd ..
diracx-charts/run_demo.sh --exit-when-done --set-value developer.autoReload=false --ci-values ./diracx/extensions/gubbins_values.yaml --load-docker-image "gubbins/services:dev" diracx/ /tmp/gubbins/ /tmp/gubbins-web/
- name: Debugging information
run: |
cd ../diracx-charts
export KUBECONFIG=$PWD/.demo/kube.conf
.demo/kubectl get pods
for pod_name in $(.demo/kubectl get pods -o json | jq -r '.items[] | .metadata.name' | grep -vE '(dex|minio|mysql|rabbitmq|opensearch)'); do
echo "${pod_name}"
.demo/kubectl describe pod/"${pod_name}" || true
for container_name in $(.demo/kubectl get pods $pod_name -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}'); do
echo $pod_name $container_name
.demo/kubectl logs "${pod_name}" -c "${container_name}" || true
done
done
- name: Check for success
run: |
cd ../diracx-charts
if [ ! -f ".demo/.success" ]; then
echo "Demo failed"
cat ".demo/.failed"
exit 1
fi
# Find the URL to be tested and put it in the github environment for the next step
- name: Set DIRACX_URL
run: echo "DIRACX_URL=https://$(ifconfig | grep 'inet ' | awk '{ print $2 }' | grep -v '^127' | head -n 1 | cut -d '/' -f 1).nip.io:8000" >> $GITHUB_ENV
# Run e2e tests with Cypress
- name: Start Cypress
uses: cypress-io/github-action@v6
with:
browser: chrome
config: baseUrl=${{ env.DIRACX_URL }}
project: /tmp/gubbins-web