-
Notifications
You must be signed in to change notification settings - Fork 21
88 lines (83 loc) · 2.62 KB
/
ci.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
name: CI pipeline
on: push
jobs:
linter:
name: run / linter
runs-on: ubuntu-latest
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Set up Python 3.13
uses: actions/setup-python@v4
with:
python-version: "3.13"
- name: Installing flake8
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Run flake8 linter
run: |
flake8 --max-line-length=200 --exclude=*/migrations src/
build:
name: run / build
runs-on: ubuntu-latest
needs: linter
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Build image
run: |
# docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS
docker build . -t jandigarte/django:$GITHUB_SHA
docker save -o docker_image_$GITHUB_SHA jandigarte/django:$GITHUB_SHA
- name: Caching image
uses: actions/cache@v3
with:
key: jandigarte
path: docker_image_${{ github.sha }}
migrations:
name: test / migrations
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Restoring cached image
uses: actions/cache@v3
with:
key: jandigarte
path: docker_image_${{ github.sha }}
- name: Running container
env:
IMAGE_NAME: jandigarte/django:${{ github.sha }}
run: |
cp .envs/.example .envs/.env
docker load -i docker_image_$GITHUB_SHA
docker-compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d
- name: Test migrations
run: |
docker exec jandigarte_${{ github.sha }}_django_1 sh -c "\
poetry run src/manage.py makemigrations --check --dry-run"
test:
name: test / unity
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Restoring cached image
uses: actions/cache@v3
with:
key: jandigarte
path: docker_image_${{ github.sha }}
- name: Running container
env:
IMAGE_NAME: jandigarte/django:${{ github.sha }}
run: |
cp .envs/.example .envs/.env
docker load -i docker_image_$GITHUB_SHA
docker-compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d
- name: Running users tests
run: |
docker exec jandigarte_${{ github.sha }}_django_1 sh -c "\
poetry run src/manage.py test"