-
Notifications
You must be signed in to change notification settings - Fork 20
171 lines (159 loc) · 6.75 KB
/
main.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
name: Basic Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash -el {0}
jobs:
shellcheck:
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx'
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Run shellcheck
# Excluded codes related to sourcing files
# SC1090: Can't follow non-constant source
# SC1091: Not following sourced file
run: |
find -name '*.sh' -print0 | xargs -0 -n1 shellcheck --exclude=SC1090,SC1091 --external-source
unittest:
name: Unit test - ${{ matrix.package }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- package: "./diracx-core"
dependencies: "./diracx-testing"
- package: "./diracx-db"
dependencies: "./diracx-testing ./diracx-core"
- package: "./diracx-routers"
dependencies: "./diracx-testing ./diracx-core ./diracx-db"
- package: "./diracx-client"
dependencies: "./diracx-testing ./diracx-core"
- package: "./diracx-api"
dependencies: "./diracx-testing ./diracx-core ./diracx-client"
- package: "./diracx-cli"
dependencies: "./diracx-testing ./diracx-core ./diracx-client ./diracx-api"
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v2
with:
# TODO: Use a conda environment file used for the diracx/base container image
environment-name: test-env
environment-file: environment.yml
init-shell: bash
post-cleanup: 'all'
- name: Set up environment
run: |
pip install pytest-github-actions-annotate-failures
# Note: DIRAC will install pretty much everything
# from diracx so installing just the dependency may
# be a bit useless
pip install git+https://github.com/DIRACGrid/DIRAC.git@integration
pip install ${{ matrix.dependencies }}
- name: Run pytest
run: |
cd ${{ matrix.package }}
pip install .[testing]
pytest --cov-report=xml:coverage.xml --junitxml=report.xml
- name: Run mypy
run: |
pip install mypy ${{ matrix.package }}[types]
mypy ${{ matrix.package }}/src
- name: Upload coverage report
uses: codecov/[email protected]
pytest-integration:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
init-shell: bash
post-cleanup: 'all'
- name: Set up environment
run: |
pip install pytest-github-actions-annotate-failures
pip install git+https://github.com/DIRACGrid/DIRAC.git@integration
pip install ./diracx-core/[testing] ./diracx-api/[testing] ./diracx-cli/[testing] ./diracx-client/[testing] ./diracx-routers/[testing] ./diracx-db/[testing] ./diracx-testing/
- name: Start demo
run: |
git clone https://github.com/DIRACGrid/diracx-charts.git ../diracx-charts
../diracx-charts/run_demo.sh --enable-open-telemetry --enable-coverage --exit-when-done --set-value developer.autoReload=false --ci-values ../diracx-charts/demo/ci_values.yaml $PWD
- name: Debugging information
run: |
DIRACX_DEMO_DIR=$PWD/../diracx-charts/.demo
export KUBECONFIG=${DIRACX_DEMO_DIR}/kube.conf
export PATH=${DIRACX_DEMO_DIR}:$PATH
kubectl get pods
for pod_name in $(kubectl get pods -o json | jq -r '.items[] | .metadata.name' | grep -vE '(dex|minio|mysql|rabbitmq|opensearch)'); do
echo "${pod_name}"
kubectl describe pod/"${pod_name}" || true
for container_name in $(kubectl get pods $pod_name -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}'); do
echo $pod_name $container_name
kubectl logs "${pod_name}" -c "${container_name}" || true
done
done
if [ ! -f "${DIRACX_DEMO_DIR}/.success" ]; then
cat "${DIRACX_DEMO_DIR}/.failed"
exit 1
fi
- name: Run pytest
run: |
pytest --demo-dir=../diracx-charts/ --cov-report=xml:coverage-pytest.xml --junitxml=report.xml
- name: Collect demo coverage
run: |
DIRACX_DEMO_DIR=$PWD/../diracx-charts/.demo
export KUBECONFIG=${DIRACX_DEMO_DIR}/kube.conf
export PATH=${DIRACX_DEMO_DIR}:$PATH
# Shutdown the pods so we collect coverage data
for pod_name in $(kubectl get pods -o json | jq -r '.items[] | .metadata.name' | grep -vE '(dex|minio|mysql|rabbitmq|opensearch)'); do
kubectl delete pod/"${pod_name}"
done
# Combine the coverage data from the demo and make an XML report
coverage_data=$(mktemp)
sudo chown -R $(id -u) "${DIRACX_DEMO_DIR}"/coverage-reports/
coverage combine --keep --data-file "${coverage_data}" "${DIRACX_DEMO_DIR}"/coverage-reports/*
# coverage can't handle having multiple src directories, so we need to make a fake one with symlinks
fake_module=$(mktemp -d)
mkdir -p "${fake_module}/src/diracx"
for fn in "${PWD}"/*/src/diracx/*; do
ln -sf "${fn}" "${fake_module}/src/diracx/$(basename "${fn}")"
done
sed -i "s@source =@source =\n ${fake_module}/src@g" .coveragerc
cat .coveragerc
coverage xml -o coverage-demo.xml --data-file "${coverage_data}"
- name: Upload coverage report
uses: codecov/[email protected]
with:
files: ./coverage-pytest.xml,./coverage-demo.xml
client-generation:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
init-shell: bash
post-cleanup: 'all'
- name: Set up environment
run: |
micromamba install -c conda-forge nodejs pre-commit
pip install git+https://github.com/DIRACGrid/DIRAC.git@integration
pip install ./diracx-core/ ./diracx-api/ ./diracx-cli/ -e ./diracx-client/[testing] ./diracx-routers/[testing] ./diracx-db/ ./diracx-testing/
npm install -g autorest
- name: Run autorest
run: |
autorest --python --help
$HOME/.autorest/\@autorest_python\@*/node_modules/\@autorest/python/venv/bin/python -m pip install --upgrade setuptools
pytest --no-cov --regenerate-client diracx-client/tests/test_regenerate.py