-
Notifications
You must be signed in to change notification settings - Fork 1
177 lines (146 loc) · 5.49 KB
/
ci_tests.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
name: CI - Tests
on:
pull_request:
push:
branches:
- 'master'
- 'push-action/**' # Allow pushing to protected branches (using CasperWA/push-protected)
jobs:
pylint-safety:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -U -r requirements.txt -r .dev/requirements_dev.txt -r .dev/requirements_ci.txt
- name: Run pylint
run: pylint --rcfile=pyproject.toml --ignore-paths=tests/ --extension-pkg-whitelist='pydantic' --recursive=yes *.py app
- name: Run pylint - tests
run: pylint --rcfile=pyproject.toml --extension-pkg-whitelist='pydantic' --disable=C0415,W0621 tests
# ID: 70612
# Package: Jinja2
# Has been disputed by the maintainer and multiple third parties.
# For more information see: https://github.com/advisories/GHSA-f6pv-j8mr-w6rr
- name: Run safety
run: pip freeze | safety check --stdin --ignore=70612
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
docker-target: ["development", "production"]
steps:
- uses: actions/checkout@v4
- name: Build Dockerfile
run: |
docker build \
-f Dockerfile \
--target ${{ matrix.docker-target }} \
.
pytest:
name: "pytest (Python ${{ matrix.python-version}} - Live Redis: ${{ matrix.live-redis }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
live-redis: [true, false]
services:
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version}}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version}}
- name: Install python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -U -r requirements.txt -r .dev/requirements_dev.txt
- name: Test with pytest
run: |
if [ "${{ matrix.live-redis }}" == "true" ]; then
LIVE_REDIS=--live-redis
REDIS_HOST=localhost
else
LIVE_REDIS=
# An incorrect host, which will ensure we fallback to using 'fakeredis'
REDIS_HOST=redis
fi
OTEAPI_REDIS_HOST=${REDIS_HOST} pytest -vvv --cov-report=xml --cov=app ${LIVE_REDIS}
env:
OTEAPI_REDIS_TYPE: redis
OTEAPI_REDIS_PORT: 6379
- name: Upload coverage to Codecov
if: matrix.python-version == '3.9' && github.repository == 'EMMC-ASBL/oteapi-services'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: oteapi-services
files: ./coverage.xml
flags: pytest
docker-compose:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
docker-target: ["development", "production"]
env:
PORT: 8123
OTEAPI_prefix: /api/ci/v1
DOCKER_OTEAPI_TARGET: ${{ matrix.docker-target }}
LOCAL_OTEAPI_PATH: /tmp/oteapi-core
steps:
- uses: actions/checkout@v4
- name: Build OTEAPI Services Dockerfiles
run: |
docker compose version
docker compose -f docker-compose_dev.yml build
docker compose -f .github/utils/docker-compose_ci_plugins.yml build
- name: Start the Docker services
run: |
docker compose -f docker-compose_dev.yml up &
.github/utils/wait_for_it.sh localhost:${{ env.PORT }} -t 120
sleep 15
curl -X "GET" -i "http://localhost:${{ env.PORT }}${{ env.OTEAPI_prefix }}/session"
- name: Clone current requirement version of `oteapi-core` locally
run: |
REQ_VERSION=$(cat requirements.txt | grep "oteapi-core")
git clone --branch v${REQ_VERSION#oteapi-core==} https://github.com/EMMC-ASBL/oteapi-core ${LOCAL_OTEAPI_PATH}
- name: Start the Docker services with local `oteapi-core`
if: matrix.docker-target == 'development'
run: |
docker compose -f docker-compose_dev.yml down
docker compose -f docker-compose_dev.yml up &
.github/utils/wait_for_it.sh localhost:${{ env.PORT }} -t 120
# Sleep for longer, since it takes a while to install `oteapi-core`
# And the port will be available as soon as the CMD is reached in the Dockerfile.
sleep 60
curl -X "GET" -i "http://localhost:${{ env.PORT }}${{ env.OTEAPI_prefix }}/session"
env:
PATH_TO_OTEAPI_CORE: ${{ env.LOCAL_OTEAPI_PATH }}
- name: Start the Docker services with plugins
run: |
docker compose -f docker-compose_dev.yml down
docker compose -f .github/utils/docker-compose_ci_plugins.yml up &
.github/utils/wait_for_it.sh localhost:${{ env.PORT }} -t 120
# Sleep for longer, since it takes a while to install `oteapi-core[dev]`
# And the port will be available as soon as the CMD is reached in the Dockerfile.
sleep 90
curl -X "GET" -i "http://localhost:${{ env.PORT }}${{ env.OTEAPI_prefix }}/session"
env:
CONTAINER_PLUGIN_PATH: /special-plugin
OTEAPI_PLUGIN_PACKAGES: "-v -e /special-plugin[dev]|oteapi-dlite"
LOCAL_TARGET_PLUGIN_PATH: ${{ env.LOCAL_OTEAPI_PATH }}