-
Notifications
You must be signed in to change notification settings - Fork 8
80 lines (66 loc) · 2.11 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
75
76
77
78
79
80
name: Test suite
on:
pull_request:
push:
branches: [ main ]
jobs:
test:
name: Run test suite
runs-on: ubuntu-latest
steps:
- name: Checkout code
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 DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Caches
- name: Cache
id: cache
uses: actions/cache@v4
with:
path: |
var-cache-apt
var-lib-apt
root-.cache
key: cache-${{ hashFiles('Dockerfile') }}
- name: inject cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"var-cache-apt": "/var/cache/apt",
"var-lib-apt": "/var/lib/apt",
"root-.cache": "/root/.cache"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Create docker network
run: docker network create openhexa
- name: Copy .env file
run: cp .env.dist .env
- name: Build docker app image
env:
DOCKER_BUILDKIT: 1
run: docker compose build --build-arg DJANGO_SETTINGS_MODULE="config.settings.dev"
- name: Run Django tests
run: docker compose run -e DEBUG=false app coveraged-test
# Push on main
- name: Build and push (on main)
uses: docker/build-push-action@v6
with:
push: ${{ github.event_name != 'pull_request' }}
context: .
target: app
file: Dockerfile
build-args: |
DJANGO_SETTINGS_MODULE=config.settings.dev
cache-from: type=registry,ref=blsq/openhexa-app:buildcache
cache-to: type=registry,ref=blsq/openhexa-app:buildcache,mode=max
tags: |
blsq/openhexa-app:main
blsq/openhexa-app:latest