Skip to content

Commit db3720c

Browse files
authored
Merge pull request #1 from octue/devops/make-tests-work
Add CI workflows
2 parents 5e086ed + cf4e25b commit db3720c

File tree

4 files changed

+76
-35
lines changed

4 files changed

+76
-35
lines changed

.github/workflows/cd.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ jobs:
1515
- name: Checkout repository
1616
uses: actions/checkout@v2
1717

18+
- name: Test package is publishable with PyPI test server
19+
uses: JRubics/[email protected]
20+
with:
21+
python_version: "3.9"
22+
pypi_token: ${{ secrets.TEST_PYPI_TOKEN }}
23+
repository_name: "testpypi"
24+
repository_url: "https://test.pypi.org/legacy/"
25+
1826
- name: Publish latest package to PyPI
1927
uses: JRubics/[email protected]
2028
with:
@@ -36,14 +44,15 @@ jobs:
3644
run: pip install poetry
3745

3846
- name: Get package version
39-
run: echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_ENV
47+
id: version
48+
run: echo "::set-output name=package_version::$(poetry version -s)"
4049

4150
- name: Create release
4251
uses: actions/create-release@v1
4352
env:
4453
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, no need to create your own.
4554
with:
46-
tag_name: ${{ env.PACKAGE_VERSION }}
55+
tag_name: ${{ steps.version.outputs.package_version }}
4756
release_name: ${{ github.event.pull_request.title }}
4857
body: ${{ github.event.pull_request.body }}
4958
draft: false

.github/workflows/ci.yml

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
name: ci
2+
13
on:
24
pull_request:
35
branches:
46
- main
7+
workflow_dispatch:
8+
inputs:
9+
debug_enabled:
10+
description: "Enable tmate debug"
11+
type: boolean
12+
default: "false"
513

614
jobs:
715
check-semantic-version:
@@ -34,23 +42,26 @@ jobs:
3442
strategy:
3543
fail-fast: true
3644
matrix:
37-
python: ["3.6", "3.7", "3.8", "3.9"]
38-
django: ["2.2", "3.0", "3.1"]
45+
python: ["3.8", "3.9", "3.10"]
3946
os: [ubuntu-latest] # [ubuntu-latest, windows-latest, macos-latest] for full coverage but this gets expensive quickly
4047
runs-on: ${{ matrix.os }}
48+
4149
services:
42-
# See: https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers
43-
pg_host:
44-
image: postgres:13.0
50+
postgres:
51+
image: kartoza/postgis:13.0
4552
env:
46-
POSTGRES_DB: pg_db
47-
POSTGRES_USER: pg_user
48-
POSTGRES_PASSWORD: pg_password
53+
POSTGRES_DB: postgres_db
54+
POSTGRES_USER: postgres_user
55+
POSTGRES_PASSWORD: postgres_password
56+
POSTGRES_MULTIPLE_EXTENSIONS: postgis,hstore,postgis_topology,postgis_raster,pgrouting
57+
ports:
58+
- 5432:5432
4959
options: >-
5060
--health-cmd pg_isready
5161
--health-interval 10s
5262
--health-timeout 5s
5363
--health-retries 5
64+
5465
steps:
5566
- name: Checkout Repository
5667
uses: actions/checkout@v2
@@ -67,13 +78,16 @@ jobs:
6778
# For more advanced configuration see https://github.com/ymyzk/tox-gh-actions
6879
- name: Install tox and plugins
6980
run: |
70-
pip install --upgrade pip
71-
pip install tox@^3.24.5 tox-gh-actions@^2.9.1 tox-poetry@^0.4.1
81+
python -m pip install --upgrade pip
82+
python -m pip install tox==3.24.5 tox-gh-actions==2.9.1 tox-poetry==0.4.1
83+
84+
- name: Setup tmate session [DEBUG]
85+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true'}}
86+
uses: mxschmitt/action-tmate@v3
7287

88+
# For more advanced configuration see https://github.com/ymyzk/tox-gh-actions
7389
- name: Run tests using tox
7490
run: tox
75-
env:
76-
DATABASE_URL: postgresql://pg_user:pg_password@pg_host/pg_db
7791

7892
- name: Upload coverage to Codecov
7993
# This seems redundant inside the test matrix but actually isn't, since different
@@ -83,20 +97,3 @@ jobs:
8397
file: coverage.xml
8498
fail_ci_if_error: true
8599
token: ${{ secrets.CODECOV_TOKEN }}
86-
87-
test-publish:
88-
if: "!contains(github.event.head_commit.message, 'skipci')"
89-
runs-on: ubuntu-latest
90-
needs: [check-semantic-version, run-tests]
91-
steps:
92-
- name: Checkout Repository
93-
uses: actions/checkout@v2
94-
95-
- name: Test package is publishable with PyPI test server
96-
uses: JRubics/[email protected]
97-
with:
98-
python_version: "3.9"
99-
pypi_token: ${{ secrets.TEST_PYPI_TOKEN }}
100-
repository_name: "testpypi"
101-
repository_url: "https://test.pypi.org/legacy/"
102-
skip_existing: true

.github/workflows/update_pr.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow updates the pull request description with an auto-generated section containing the categorised commit
2+
# message headers of the commits since the last pull request merged into main. The auto generated section is enveloped
3+
# between two comments: "<!--- START AUTOGENERATED NOTES --->" and "<!--- END AUTOGENERATED NOTES --->". Anything
4+
# outside these in the description is left untouched. Auto-generated updates can be skipped for a commit if
5+
# "skipci" is in the commit message body.
6+
7+
name: update-pr
8+
9+
on: [pull_request]
10+
11+
jobs:
12+
description:
13+
if: "!contains(github.event.head_commit.message, 'skipci')"
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
with:
19+
# Set fetch-depth to 0 to fetch all commit history (necessary for compiling pull request description).
20+
fetch-depth: 0
21+
22+
- name: Install release note compiler
23+
run: pip install git+https://github.com/octue/conventional-commits
24+
25+
- name: Compile new pull request description
26+
run: |
27+
echo 'PULL_REQUEST_NOTES<<EOF' >> $GITHUB_ENV
28+
echo "$(compile-release-notes PULL_REQUEST_START --pull-request-url=${{ github.event.pull_request.url }} --api-token=${{ secrets.GITHUB_TOKEN }})" >> $GITHUB_ENV
29+
echo EOF >> $GITHUB_ENV
30+
31+
- name: Update pull request body
32+
uses: riskledger/update-pr-description@v2
33+
with:
34+
body: ${{ env.PULL_REQUEST_NOTES }}
35+
token: ${{ secrets.GITHUB_TOKEN }}

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = {py37,py38,py39}-dj{31}-channels{30}-{sqlite,postgres}
2+
envlist = {py38,py39,py310}-dj{32}-channels{30}-{sqlite,postgres}
33
isolated_build = True
44

55
[testenv]
@@ -14,12 +14,12 @@ commands =
1414
coverage report --show-missing
1515
coverage xml
1616
deps =
17-
dj31: Django>=3.1,<3.2
17+
dj32: Django>=3.2,<3.3
1818
channels30: channels>=3.0,<=3.1
19-
postgres: psycopg2==2.8.5 --no-binary psycopg2
19+
postgres: psycopg2
2020

2121
[gh-actions]
2222
python =
23-
3.7: py37
2423
3.8: py38
2524
3.9: py39
25+
3.10: py310

0 commit comments

Comments
 (0)