-
Notifications
You must be signed in to change notification settings - Fork 6
178 lines (156 loc) · 5.01 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: CI
on:
pull_request:
push:
branches:
- master
release:
types:
- created
env:
DEBIAN_FRONTEND: noninteractive
jobs:
flake8:
name: Check python linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: |
echo "${{ github.event_name }}! ${{ github.event.action }}"
python -m pip install --upgrade pip
python -m pip install flake8
- name: Lint with flake8
run: |
flake8 georiviere
- name: Not evaluated values in migration files
run: |
test $(ls georiviere/*/migrations/*.py | xargs grep -l srid | xargs grep -L SRID | wc -l) -eq 0
doc_build:
name: Sphinx doc is building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: |
pip install -r docs/requirements.txt
- name: Build html docs
run: |
cd docs
make html
unittests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare tests settings
run: |
cp .env.dist .env
sed -i 's/^\(POSTGRES_PASSWORD=\).*/\1ci_test/' .env
sed -i 's/^\(POSTGRES_DB=\).*/\1ci_test/' .env
sed -i 's/^\(POSTGRES_USER=\).*/\1ci_test/' .env
cat .env
- name: Build Docker image
run: |
docker-compose build --build-arg UID=$UID
- name: Check no pending migrations
run: |
docker-compose run --rm web ./manage.py makemigrations --check
- name: Run tests
run: |
docker-compose run --rm web ./manage.py compilemessages
docker-compose run --rm web coverage run ./manage.py test
docker-compose run --rm web coverage xml
- uses: codecov/codecov-action@v2
with:
verbose: true
fail_ci_if_error: true # optional (default = false)
build-and-push-dev-image:
runs-on: ubuntu-latest
permissions:
packages: write # required to publish docker image
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
if: ${{(github.base_ref == 'develop')}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push-image:
runs-on: ubuntu-latest
needs: [flake8, doc_build, unittests]
permissions:
packages: write # required to publish docker image
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
if: ${{ (github.event_name == 'release' && github.event.action == 'created') || (github.ref == 'refs/heads/master' && github.event_name != 'pull_request')}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
attach_install_release:
runs-on: ubuntu-latest
needs: [ build-and-push-image ]
permissions:
contents: write # required to attach zip to release
if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare install.zip
run: |
cd install
mkdir -p georiviere/var
cp * ./georiviere 2>/dev/null || :
cp .env.dist ./georiviere
zip -r ../install.zip georiviere/
- name: Attach zip archive as release binary
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'install.zip'