-
Notifications
You must be signed in to change notification settings - Fork 28
147 lines (145 loc) · 4.35 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Build & Test
on: [push, pull_request]
jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: false
- name: Setup Python 3.8
id: setup-python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- uses: actions/setup-node@v2
with:
node-version: "14"
- name: Get node version
id: node-version
run: echo "::set-output name=node-version::$(node --version)"
- uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true
- name: Cache poetry venv
id: cache-poetry
uses: actions/cache@v2
with:
path: django/.venv
key: "poetry-${{ runner.os }}-\
${{ steps.setup-python.outputs.python-version }}-\
${{ hashFiles('django/poetry.lock') }}"
restore-keys: |
poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install poetry dependencies
run: |
cd django/
poetry install
- name: Cache pre-commit cache
uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: "pre-commit-${{ runner.os }}-\
${{ steps.setup-python.outputs.python-version }}-\
${{ steps.node-version.outputs.node-version }}-\
${{ hashFiles('.pre-commit-config.yaml') }}"
- name: Run pre-commit
run: |
cd django/
poetry run pre-commit run --show-diff-on-failure --color=always --all-files
build:
name: Build docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: false
- name: Build Docker image
run: docker build --pull -t thunderstore:${GITHUB_SHA} .
- name: Export Docker image
run: docker save --output /tmp/thunderstore.tar thunderstore:${GITHUB_SHA}
- name: Upload Docker image
uses: actions/upload-artifact@v3
with:
name: docker-image
path: /tmp/thunderstore.tar
test-pytest:
name: Test pytest
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
group: [1, 2, 3]
env:
PYTEST_SPLITS: 3
PYTEST_GROUP: ${{ matrix.group }}
PYTEST_NUM_WORKERS: auto
steps:
- uses: actions/checkout@v3
with:
submodules: false
- name: Download Docker image
uses: actions/download-artifact@v3
with:
name: docker-image
path: /tmp
- name: Load Docker image
run: docker load --input /tmp/thunderstore.tar
- name: Run pytest
run: |
DJANGO_IMAGE="thunderstore:${GITHUB_SHA}" docker-compose -f docker/docker-compose.pytest.yml up --exit-code-from django
docker-compose -f docker/docker-compose.pytest.yml down -f
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v1
with:
file: ./coverage_results/coverage.xml
test-mypy:
name: Test mypy
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
with:
submodules: false
- name: Download Docker image
uses: actions/download-artifact@v3
with:
name: docker-image
path: /tmp
- name: Load Docker image
run: docker load --input /tmp/thunderstore.tar
- name: Run mypy
run: >
docker run --rm
--entrypoint mypy
-e SECRET_KEY=hunter2
--no-healthcheck
thunderstore:${GITHUB_SHA}
/app/
|| :
test-missing-migrations:
name: Test missing migrations
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
with:
submodules: false
- name: Download Docker image
uses: actions/download-artifact@v3
with:
name: docker-image
path: /tmp
- name: Load Docker image
run: docker load --input /tmp/thunderstore.tar
- name: Check for missing migrations
run: >
docker run --rm
--entrypoint python
-e SECRET_KEY=hunter2
-e DATABASE_URL=sqlite://django.db
--no-healthcheck
thunderstore:${GITHUB_SHA}
manage.py makemigrations --check