Skip to content

Commit 09f0567

Browse files
authored
Migrate to common workflows (#123)
1 parent d54620a commit 09f0567

File tree

6 files changed

+32
-203
lines changed

6 files changed

+32
-203
lines changed

.github/workflows/README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
# Continuous Integration Workflows
1+
# Continous Integration Workflows
22

3-
This package implements different workflows for CI.
4-
They are organized as follows.
3+
This package implements different workflows for CI, based on our organisation's common workflows.
4+
They are organised as follows.
55

66
### Documentation
77

88
The `documentation` workflow triggers on any push to master, builds the documentation and pushes it to the `gh-pages` branch (if the build is successful).
9-
It runs on `ubuntu-latest` and our lowest supported Python version, `Python 3.7`.
109

1110
### Testing Suite
1211

1312
Tests are ensured in the `tests` workflow, which triggers on all pushes.
14-
It runs on a matrix of all supported operating systems (ubuntu-18.04, ubuntu-20.04, windows-latest and macos-latest) for all supported Python versions (currently `3.7`, `3.8`, `3.9`, `3.10` and `3.11`).
13+
It runs on a matrix of all supported operating systems for all supported Python versions.
1514

1615
### Test Coverage
1716

1817
Test coverage is calculated in the `coverage` wokflow, which triggers on pushes to `master` and any push to a `pull request`.
19-
It runs on `ubuntu-latest` & the lowest supported Python version (`Python 3.7`), and reports the coverage results of the test suite to `CodeClimate`,
20-
18+
It reports the coverage results of the test suite to `CodeClimate`.
2119

2220
### Regular Testing
2321

2422
A `cron` workflow triggers every Monday at 3am (UTC time) and runs the full testing suite, on all available operating systems and supported Python versions.
25-
It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically detected.
23+
It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically included.
2624

2725
### Publishing
2826

.github/workflows/coverage.yml

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Runs all tests and pushes coverage report to codeclimate
22
name: Coverage
33

4-
defaults:
5-
run:
6-
shell: bash
7-
84
on: # Runs on all push events to master branch and any push related to a pull request
95
push:
106
branches:
@@ -13,56 +9,7 @@ on: # Runs on all push events to master branch and any push related to a pull r
139

1410
jobs:
1511
coverage:
16-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
matrix: # only lowest supported Python on latest ubuntu
20-
os: [ubuntu-latest]
21-
python-version: [3.7]
22-
23-
steps:
24-
- uses: actions/checkout@v3
25-
26-
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v4
28-
with:
29-
python-version: ${{ matrix.python-version }}
30-
cache: 'pip'
31-
cache-dependency-path: '**/setup.py'
32-
33-
- name: Upgrade pip, setuptools and wheel
34-
run: python -m pip install --upgrade pip setuptools wheel
35-
36-
- name: Install package
37-
run: python -m pip install '.[test,hdf5]'
38-
39-
- name: Set up env for CodeClimate (push)
40-
run: |
41-
echo "GIT_BRANCH=${GITHUB_REF/refs\/heads\//}" >> $GITHUB_ENV
42-
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
43-
if: github.event_name == 'push'
44-
45-
- name: Set up env for CodeClimate (pull_request)
46-
env:
47-
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
48-
run: |
49-
echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV
50-
echo "GIT_COMMIT_SHA=$PR_HEAD_SHA" >> $GITHUB_ENV
51-
if: github.event_name == 'pull_request'
52-
53-
- name: Prepare CodeClimate binary
54-
env:
55-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
56-
run: |
57-
curl -LSs 'https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64' >./cc-test-reporter;
58-
chmod +x ./cc-test-reporter
59-
./cc-test-reporter before-build
60-
61-
- name: Run tests
62-
run: python -m pytest --cov-report xml --cov=tfs
63-
64-
- name: Push Coverage to CodeClimate
65-
if: ${{ success() }} # only if tests were successful
66-
env:
67-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
68-
run: ./cc-test-reporter after-build
12+
uses: pylhc/.github/.github/workflows/coverage.yml@master
13+
with:
14+
src-dir: tfs
15+
secrets: inherit

.github/workflows/cron.yml

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,13 @@
1-
# Runs all tests on master everyday at 10 am (UTC time)
1+
# Runs all tests on master on Mondays at 3 am (UTC time)
22
name: Cron Testing
33

4-
defaults:
5-
run:
6-
shell: bash
74

8-
on: # Runs on master branch on Mondays at 3am UTC time
5+
on:
96
schedule:
107
- cron: '* 3 * * mon'
118

129
jobs:
13-
tests:
14-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
15-
runs-on: ${{ matrix.os }}
16-
strategy:
17-
matrix:
18-
os: [ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest]
19-
# Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser
20-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", 3.x] # crons should always run latest python hence 3.x
21-
22-
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: 'pip'
30-
cache-dependency-path: '**/setup.py'
31-
32-
- name: Upgrade pip, setuptools and wheel
33-
run: python -m pip install --upgrade pip setuptools wheel
34-
35-
- name: Install package
36-
run: python -m pip install '.[test,hdf5]'
37-
38-
- name: Run tests
39-
run: python -m pytest
10+
tests:
11+
uses: pylhc/.github/.github/workflows/cron.yml@master
12+
with:
13+
extra-dependencies: test,hdf5
Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,14 @@
11
# Build documentation
2+
# The build is uploaded as artifact if the triggering event is a push for a pull request
3+
# The build is published to github pages if the triggering event is a push to the master branch (PR merge)
24
name: Build and upload documentation
35

4-
defaults:
5-
run:
6-
shell: bash
7-
8-
on: # Runs on any push event to master
6+
on: # Runs on any push event in a PR or any push event to master
7+
pull_request:
98
push:
109
branches:
1110
- 'master'
1211

1312
jobs:
1413
documentation:
15-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
16-
runs-on: ${{ matrix.os }}
17-
strategy:
18-
matrix: # only lowest supported Python on latest ubuntu
19-
os: [ubuntu-latest]
20-
python-version: [3.7]
21-
22-
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: 'pip'
30-
cache-dependency-path: '**/setup.py'
31-
32-
- name: Upgrade pip, setuptools and wheel
33-
run: python -m pip install --upgrade pip setuptools wheel
34-
35-
- name: Install package
36-
run: python -m pip install '.[doc]'
37-
38-
- name: Build documentation
39-
run: python -m sphinx -b html doc ./doc_build -d ./doc_build
40-
41-
- name: Upload documentation to gh-pages
42-
if: ${{ success() }}
43-
uses: JamesIves/[email protected]
44-
with:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
BRANCH: gh-pages
47-
FOLDER: doc_build
14+
uses: pylhc/.github/.github/workflows/documentation.yml@master

.github/workflows/publish.yml

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,11 @@
11
# Publishes to PyPI upon creation of a release
22
name: Upload Package to PyPI
33

4-
defaults:
5-
run:
6-
shell: bash
7-
84
on: # Runs everytime a release is added to the repository
95
release:
106
types: [created]
117

128
jobs:
139
deploy:
14-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
15-
runs-on: ${{ matrix.os }}
16-
strategy:
17-
matrix: # only lowest supported Python on latest ubuntu
18-
os: [ubuntu-latest]
19-
python-version: [3.7]
20-
21-
22-
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: 'pip'
30-
cache-dependency-path: '**/setup.py'
31-
32-
- name: Upgrade pip, setuptools, wheel, build and twine
33-
run: python -m pip install --upgrade pip setuptools wheel build twine
34-
35-
- name: Build and check build
36-
run: |
37-
python -m build
38-
twine check dist/*
39-
40-
- name: Publish
41-
if: ${{ success() }}
42-
env:
43-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
44-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
45-
run: |
46-
twine upload dist/*
10+
uses: pylhc/.github/.github/workflows/publish.yml@master
11+
secrets: inherit

.github/workflows/tests.yml

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,17 @@
1-
# Runs all tests not flagged as "extended" with a pytest marker
2-
name: Tests
1+
# Runs all tests
2+
name: All Tests
33

44
defaults:
55
run:
66
shell: bash
77

8-
on: [push] # Runs on all push events to any branch
9-
8+
on: # Runs on any push event to any branch except master (the coverage workflow takes care of that)
9+
push:
10+
branches-ignore:
11+
- 'master'
1012

1113
jobs:
1214
tests:
13-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
14-
runs-on: ${{ matrix.os }}
15-
strategy:
16-
matrix:
17-
os: [ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest]
18-
# Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser
19-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
20-
fail-fast: false
21-
22-
steps:
23-
- uses: actions/checkout@v3
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: 'pip'
30-
cache-dependency-path: '**/setup.py'
31-
32-
- name: Upgrade pip, setuptools and wheel
33-
run: python -m pip install --upgrade pip setuptools wheel
34-
35-
- name: Install package
36-
run: python -m pip install '.[test,hdf5]'
37-
38-
- name: Run tests
39-
run: python -m pytest
15+
uses: pylhc/.github/.github/workflows/tests.yml@master
16+
with:
17+
extra-dependencies: test,hdf5

0 commit comments

Comments
 (0)