-
-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (59 loc) · 1.88 KB
/
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
name: Test
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
tests:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
steps:
- uses: actions/checkout@v4
- name: Create env
run: cp .env.example .env
- name: Load .env file
uses: xom9ikk/dotenv@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.repository == 'opengisch/django-ogcapif'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Django image
uses: docker/build-push-action@v5
with:
context: .
provenance: false
file: docker/django/Dockerfile
push: ${{ github.repository == 'opengisch/django-ogcapif' }}
pull: true
cache-from: type=registry,ref=opengisch/django-oapif:latest
cache-to: type=registry,ref=opengisch/django-oapif:latest,mode=max
tags: opengisch/django-oapif:latest
- name: Setup Compose
run: |
# copy default conf
cp .env.example .env
# start the stack
docker compose --profile testing_integration up --build -d
# migrate database
docker compose exec django python manage.py migrate --no-input
docker compose exec django python manage.py populate_users
docker compose exec django python manage.py populate_data
- name: Run unit tests
run: docker compose exec django python manage.py test tests
- name: Run integration tests
run: docker compose run integration_tests
- name: Failure logs
if: failure()
run: docker-compose logs