-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (64 loc) · 2.4 KB
/
Copy pathtests.yaml
File metadata and controls
75 lines (64 loc) · 2.4 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
on:
# Workflow dispatch is used for manual triggers
workflow_dispatch:
# Workflow call is used for called from another workflow
workflow_call:
secrets:
ACR_SECRET:
required: false
permissions:
contents: read
env:
IMAGE_REGISTRY: datamodelingtool.azurecr.io
API_IMAGE: datamodelingtool.azurecr.io/dm-job
jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up python
id: setup-python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install pre-commit
run: pip install pre-commit
# Caches the venv at the end of the job and reloads for quicker pre-commit.
# Uses pyproject.toml and pre-commit-config file to create hash.
- name: Cache venv
uses: actions/cache@v6
id: cache
with:
path: |
~/work/dm-job/dm-job/.venv
~/.cache/pre-commit
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Set up venv
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install poetry
poetry config virtualenvs.in-project true
poetry install
- name: Run pre-commit
run: pre-commit run --all-files --verbose
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build API image
run: |
if [ -n "$ACR_SECRET" ]; then
echo "$ACR_SECRET" | docker login $IMAGE_REGISTRY -u datamodelingtool --password-stdin
docker pull $API_IMAGE
DOCKER_BUILDKIT=1 docker build --target development --tag job-api-development --cache-from $API_IMAGE .
else
DOCKER_BUILDKIT=1 docker build --target development --tag job-api-development .
fi
env:
ACR_SECRET: ${{ secrets.ACR_SECRET }}
- name: Pytest tests
run: |
docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d
sleep 50 # Wait for database to be ready
docker compose -f docker-compose.yml -f docker-compose.ci.yml run job-api dm --url http://dmss:5000 reset ../app
docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm job-api pytest -c ../pyproject.toml --integration --capture=tee-sys