-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.48 KB
/
build.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
name: Build Server
on: [push]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12-alpine
ports:
- 5432:5432
env:
POSTGRES_USER: testuser
POSTGRES_DB: testdb
POSTGRES_HOST_AUTH_METHOD: trust
steps:
- uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1
- uses: actions/cache@a505c2e7a6652a1d5727baf1c2dc5a5b2d1ecc60 # v1
id: cache
with:
path: cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Load Cache
run: |
if [ -f "cache/image.tar" ]; then
docker load -i cache/image.tar
rm -rf cache/
fi
- name: Build Image
env:
IMAGE_TAG: ${{ github.sha }}
run: |
docker build --cache-from website -t website -t $IMAGE_TAG .
mkdir -p cache
docker save website > cache/image.tar
- name: Run Linting
env:
IMAGE_TAG: ${{ github.sha }}
run: |
docker run $IMAGE_TAG black --check .
docker run $IMAGE_TAG flake8
- name: Run Tests
env:
IMAGE_TAG: ${{ github.sha }}
run: |
docker run --net host --env DJANGO_SETTINGS_MODULE=config.settings.testing --env DATABASE_URL=postgres://testuser@localhost/testdb -v $PWD/test-reports:/app/test-reports $IMAGE_TAG pytest apps