-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (125 loc) · 4.25 KB
/
ci.yaml
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: Run CI
# Run this workflow every time a new commit pushed to your repository
on:
push:
branches:
- main
tags:
- '*'
pull_request:
workflow_dispatch:
env:
IMAGE_NAME: openformulieren/open-forms-ext-token-exchange
jobs:
tests:
name: Run the Django test suite
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
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
--name postgres
redis:
image: redis:6
ports:
- 6379:6379
steps:
- name: Checkout Open Forms
uses: actions/checkout@v3
with:
repository: open-formulieren/open-forms
path: open-forms
- name: Checkout Token Exchange extension
uses: actions/checkout@v3
with:
path: extension
- name: Set up backend environment
uses: maykinmedia/[email protected]
with:
apt-packages: 'libxml2-dev libxmlsec1-dev libxmlsec1-openssl gettext postgresql-client gdal-bin'
python-version: '3.10'
optimize-postgres: 'yes'
pg-service: 'postgres'
setup-node: 'yes'
nvmrc-custom-dir: 'open-forms'
npm-ci-flags: '--legacy-peer-deps'
working-directory: ${{ github.workspace }}/open-forms
- name: Make symlink in OF to the extension
run: |
ln -s ${{ github.workspace }}/extension/token_exchange ${{ github.workspace }}/open-forms/src
- name: Run tests
run: |
export OPEN_FORMS_EXTENSIONS=token_exchange
python src/manage.py compilemessages
coverage run --source=token_exchange src/manage.py test token_exchange
coverage combine
coverage xml -o coverage-extension.xml
env:
DJANGO_SETTINGS_MODULE: openforms.conf.ci
SECRET_KEY: dummy
DB_USER: postgres
DB_PASSWORD: ''
working-directory: ${{ github.workspace }}/open-forms
- name: Publish coverage report
uses: codecov/[email protected]
with:
root_dir: ${{ github.workspace }}/extension
working-directory: ${{ github.workspace }}/open-forms
files: ./coverage-extension.xml
docker_build:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set tag
id: vars
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name (if present at all)
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
# PRs result in version 'merge' -> transform that into 'latest'
[ "$VERSION" == "merge" ] && VERSION=latest
echo ::set-output name=tag::${VERSION}
- name: Build the Docker image
run: |
docker build . \
--tag $IMAGE_NAME:$RELEASE_VERSION
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
- run: docker image save -o image.tar $IMAGE_NAME:${{ steps.vars.outputs.tag }}
- name: Store image artifact
uses: actions/upload-artifact@v3
with:
name: docker-image
path: image.tar
retention-days: 1
publish:
name: Publish package to PyPI
runs-on: ubuntu-latest
needs:
- tests
- docker_build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build sdist and wheel
run: |
pip install pip setuptools wheel --upgrade
python setup.py sdist bdist_wheel
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}