-
Notifications
You must be signed in to change notification settings - Fork 6
112 lines (97 loc) · 3.12 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
name: ci
on:
push:
branches:
- master
tags:
- '**'
pull_request:
workflow_dispatch:
env:
IMAGE_NAME: maykinmedia/objecttypes-api
jobs:
changed-files:
runs-on: ubuntu-latest
name: Determine changed files
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get changed PY files
id: changed-py-files
uses: tj-actions/changed-files@v45
with:
files: src/{,**/}*.py
- name: Get changed requirements files
id: changed-requirements
uses: tj-actions/changed-files@v45
with:
files: requirements/*.txt
outputs:
changed-py-files: ${{ steps.changed-py-files.outputs.any_changed }}
changed-requirements: ${{ steps.changed-requirements.outputs.any_changed }}
tests:
name: Run the Django test suite
runs-on: ubuntu-latest
needs:
- changed-files
if: ${{ needs.changed-files.outputs.changed-py-files == 'true'|| needs.changed-files.outputs.changed-requirements == 'true'|| github.event_name == 'push' }}
services:
postgres:
image: postgres:12
env:
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up backend environment
uses: maykinmedia/[email protected]
with:
apt-packages: 'libgdal-dev gdal-bin'
python-version: '3.11'
setup-node: true
- name: Run tests
run: |
python src/manage.py collectstatic --noinput --link
coverage run src/manage.py test src
env:
DJANGO_SETTINGS_MODULE: objecttypes.conf.ci
SECRET_KEY: dummy
DB_USER: postgres
DB_PASSWORD: ''
- name: Publish coverage report
uses: codecov/codecov-action@v4
store-reusable-workflow-vars:
name: create values which can be passed through a reusable workflow
runs-on: ubuntu-latest
outputs:
image-name: ${{ steps.image-name.outputs.image-name }}
steps:
- run: echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT
name: 'Store the docker image name'
id: image-name
open-api-ci:
uses: maykinmedia/open-api-workflows/.github/workflows/[email protected]
needs:
- store-reusable-workflow-vars
with:
main-branch: 'master'
python-version: '3.11'
docker-image-name: ${{ needs.store-reusable-workflow-vars.outputs.image-name }}
django-settings-module: objecttypes.conf.ci
run-docs: false
open-api-publish:
uses: maykinmedia/open-api-workflows/.github/workflows/[email protected]
needs:
- store-reusable-workflow-vars
- open-api-ci
- tests
with:
docker-image-name: ${{ needs.store-reusable-workflow-vars.outputs.image-name }}
repository-owner: 'maykinmedia'
secrets:
docker-username: ${{ secrets.DOCKER_USERNAME }}
docker-token: ${{ secrets.DOCKER_TOKEN }}