Skip to content

Commit 327c928

Browse files
authored
Merge pull request #9 from pylhc/reuse_workflows
Using the reusable workflows
2 parents 88671dc + 8b0642a commit 327c928

File tree

7 files changed

+23
-218
lines changed

7 files changed

+23
-218
lines changed

.github/workflows/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ They are organised as follows.
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` and `3.10`).
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`.
18+
It reports the coverage results of the test suite to `CodeClimate`.
2019

2120
### Regular Testing
2221

.github/workflows/coverage.yml

Lines changed: 4 additions & 61 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,60 +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: Get full Python version
34-
id: full-python-version
35-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
36-
37-
- name: Upgrade pip, setuptools and wheel
38-
run: python -m pip install --upgrade pip setuptools wheel
39-
40-
- name: Install package
41-
run: python -m pip install '.[test]'
42-
43-
- name: Set up env for CodeClimate (push)
44-
run: |
45-
echo "GIT_BRANCH=${GITHUB_REF/refs\/heads\//}" >> $GITHUB_ENV
46-
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
47-
if: github.event_name == 'push'
48-
49-
- name: Set up env for CodeClimate (pull_request)
50-
env:
51-
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
52-
run: |
53-
echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV
54-
echo "GIT_COMMIT_SHA=$PR_HEAD_SHA" >> $GITHUB_ENV
55-
if: github.event_name == 'pull_request'
56-
57-
- name: Prepare CodeClimate binary
58-
env:
59-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
60-
run: |
61-
curl -LSs 'https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64' >./cc-test-reporter;
62-
chmod +x ./cc-test-reporter
63-
./cc-test-reporter before-build
64-
65-
- name: Run tests
66-
run: python -m pytest --cov-report xml --cov=irnl_rdt_correction
67-
68-
- name: Push Coverage to CodeClimate
69-
if: ${{ success() }} # only if tests were successful
70-
env:
71-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
72-
run: ./cc-test-reporter after-build
12+
uses: pylhc/.github/.github/workflows/coverage.yml@master
13+
with:
14+
src-dir: irnl_rdt_correction
15+
secrets: inherit

.github/workflows/cron.yml

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,11 @@
1-
# Runs all tests on master every week at 3 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-18.04, ubuntu-20.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.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: Get full Python version
33-
id: full-python-version
34-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
35-
36-
- name: Upgrade pip, setuptools and wheel
37-
run: python -m pip install --upgrade pip setuptools wheel
38-
39-
- name: Install package
40-
run: python -m pip install '.[test]'
41-
42-
- name: Run tests
43-
run: python -m pytest --cov-report xml --cov=irnl_rdt_correction
10+
tests:
11+
uses: pylhc/.github/.github/workflows/cron.yml@master
Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,14 @@
1-
# Build and publish documentation
1+
# 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: Get full Python version
33-
id: full-python-version
34-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
35-
36-
- name: Upgrade pip, setuptools and wheel
37-
run: python -m pip install --upgrade pip setuptools wheel
38-
39-
- name: Install package
40-
run: python -m pip install '.[doc]'
41-
42-
- name: Build documentation
43-
run: python -m sphinx -b html doc ./doc_build -d ./doc_build
44-
45-
- name: Upload documentation to gh-pages
46-
if: ${{ success() }}
47-
uses: JamesIves/[email protected]
48-
with:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
BRANCH: gh-pages
51-
FOLDER: doc_build
14+
uses: pylhc/.github/.github/workflows/documentation.yml@master

.github/workflows/publish.yml

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +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 ubuntu-latest
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: Get full Python version
33-
id: full-python-version
34-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
35-
36-
- name: Upgrade pip, setuptools, wheel, build and twine
37-
run: python -m pip install --upgrade pip setuptools wheel build twine
38-
39-
- name: Build and check build
40-
run: |
41-
python -m build
42-
twine check dist/*
43-
44-
- name: Publish
45-
if: ${{ success() }}
46-
env:
47-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
48-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
49-
run: |
50-
twine upload dist/*
10+
uses: pylhc/.github/.github/workflows/publish.yml@master
11+
secrets: inherit

.github/workflows/tests.yml

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,15 @@
1-
# Runs all tests not flagged as "cern_network" 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: # Runs on all push events to any branch that isn't master
8+
on: # Runs on any push event to any branch except master (the coverage workflow takes care of that)
99
push:
1010
branches-ignore:
1111
- 'master'
1212

1313
jobs:
1414
tests:
15-
name: ${{ matrix.os }} / ${{ matrix.python-version }}
16-
runs-on: ${{ matrix.os }}
17-
strategy:
18-
matrix:
19-
os: [ubuntu-18.04, ubuntu-20.04, macos-latest, windows-latest]
20-
# Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser
21-
python-version: [3.7, 3.8, 3.9, "3.10"]
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: Get full Python version
34-
id: full-python-version
35-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
36-
37-
- name: Upgrade pip, setuptools and wheel
38-
run: python -m pip install --upgrade pip setuptools wheel
39-
40-
- name: Install package
41-
run: python -m pip install '.[test]'
42-
43-
- name: Run basic tests
44-
run: python -m pytest --cov-report xml --cov=irnl_rdt_correction
15+
uses: pylhc/.github/.github/workflows/tests.yml@master

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ def about_package(init_posixpath: pathlib.Path) -> dict:
6969
"Natural Language :: English",
7070
"Programming Language :: Python",
7171
"Programming Language :: Python :: 3 :: Only",
72-
"Programming Language :: Python :: 3.7",
7372
"Programming Language :: Python :: 3.8",
7473
"Programming Language :: Python :: 3.9",
7574
"Programming Language :: Python :: 3.10",
75+
"Programming Language :: Python :: 3.11",
7676
"Topic :: Scientific/Engineering :: Physics",
7777
"Topic :: Scientific/Engineering :: Visualization",
7878
],

0 commit comments

Comments
 (0)