Skip to content

Commit 41e37c1

Browse files
Merge pull request #12 from btschwertfeger/8-create-a-release-workflow-for-dev-and-production-releases
Improving workflows - adding release workflow
2 parents 9179527 + eaa20a0 commit 41e37c1

File tree

11 files changed

+354
-91
lines changed

11 files changed

+354
-91
lines changed

.github/codecov.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
coverage:
2+
## Status checks in PR
3+
##
4+
status:
5+
project:
6+
default:
7+
informational: true
8+
## Target coverage is the last one
9+
##
10+
target: auto
11+
## this allows a 2% drop from the previous base commit coverage
12+
##
13+
threshold: 2%
14+
patch:
15+
default:
16+
informational: true
17+
18+
comment:
19+
layout: "reach, diff, flags, files"
20+
behavior: default
21+
require_changes: true # if false: post the comment even if coverage dont change
22+
require_base: no # [yes :: must have a base report to post]
23+
require_head: yes # [yes :: must have a head report to post]

.github/workflows/_build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
3+
# Github: https://github.com/btschwertfeger
4+
#
5+
# Template workflow to build the project for a specific os
6+
# and Python version.
7+
#
8+
9+
name: Build
10+
11+
on:
12+
workflow_call:
13+
inputs:
14+
os:
15+
type: string
16+
required: true
17+
python-version:
18+
type: string
19+
required: true
20+
21+
jobs:
22+
Build:
23+
runs-on: ${{ inputs.os }}
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
28+
- name: Set up Python ${{ inputs.python-version }}
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: ${{ inputs.python-version }}
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
37+
- name: Build the package
38+
run: python -m pip wheel -w dist --no-deps .
39+
40+
- name: Install the package
41+
run: python3 -m pip install dist/python_cmethods*.whl

.github/workflows/codecov.yml renamed to .github/workflows/_codecov.yml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
name: Codecov
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
3+
# Github: https://github.com/btschwertfeger
4+
#
5+
# Template workflow to build the project for a specific os
6+
# and Python version, run the tests and upload the results to codecov.
7+
#
8+
9+
name: CodeCov
210

311
on:
4-
push:
5-
branches:
6-
- "**"
7-
pull_request:
8-
branches:
9-
- "**"
12+
workflow_call:
13+
inputs:
14+
os:
15+
type: string
16+
required: true
17+
python-version:
18+
type: string
19+
required: true
1020

1121
concurrency:
1222
group: codecov-${{ github.ref }}
@@ -15,17 +25,10 @@ concurrency:
1525
jobs:
1626
codecov:
1727
name: Coverage
18-
runs-on: ${{ matrix.os }}
19-
strategy:
20-
fail-fast: false
21-
max-parallel: 1
22-
matrix:
23-
os: [ubuntu-latest]
24-
python-version: ["3.11"]
25-
28+
runs-on: ${{ inputs.os }}
2629
env:
27-
OS: ${{ matrix.os }}
28-
PYTHON: ${{ matrix.python-version }}
30+
OS: ${{ inputs.os }}
31+
PYTHON: ${{ inputs.python-version }}
2932

3033
steps:
3134
- name: Checkout repository
@@ -34,7 +37,7 @@ jobs:
3437
- name: Set up Python ${{ matrix.python-version }}
3538
uses: actions/setup-python@v4
3639
with:
37-
python-version: ${{ matrix.python-version }}
40+
python-version: ${{ inputs.python-version }}
3841

3942
- name: Install dependencies
4043
run: |

.github/workflows/_pre_commit.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
3+
# Github: https://github.com/btschwertfeger
4+
#
5+
# Template workflow to run pre-commit.
6+
#
7+
8+
name: Pre-Commit
9+
10+
on:
11+
workflow_call:
12+
13+
jobs:
14+
Pre-Commit:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
- uses: pre-commit/[email protected]

.github/workflows/_pypi_publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
3+
# Github: https://github.com/btschwertfeger
4+
#
5+
# Template workflow to build the project and publish
6+
# the package to PyPI. It can be used to publish on the
7+
# test index and the "live" PyPI index.
8+
#
9+
10+
name: PyPI Publish
11+
12+
on:
13+
workflow_call:
14+
inputs:
15+
REPOSITORY_URL:
16+
type: string
17+
required: true
18+
secrets:
19+
API_TOKEN:
20+
required: true
21+
22+
jobs:
23+
PyPI-Publish:
24+
name: Upload to ${{ inputs.REPOSITORY_URL }}
25+
runs-on: ubuntu-latest
26+
permissions:
27+
id-token: write # IMPORTANT: this permission is mandatory for OIDC publishing
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v3
32+
with:
33+
fetch-depth: 0 # IMPORTANT: otherwise the current tag does not get fetched and the build version gets worse
34+
35+
- name: Set up Python 3.11
36+
uses: actions/setup-python@v4
37+
with:
38+
python-version: 3.11
39+
40+
- name: Install dependencies
41+
run: |
42+
python -m pip install --upgrade pip
43+
44+
- name: Build the package
45+
run: python -m pip wheel -w dist --no-deps .
46+
47+
- name: Publish package distributions to PyPI (optional - testpypi)
48+
uses: pypa/gh-action-pypi-publish@release/v1
49+
with:
50+
password: ${{ secrets.API_TOKEN }}
51+
repository-url: ${{ inputs.REPOSITORY_URL }}

.github/workflows/_test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
3+
# Github: https://github.com/btschwertfeger
4+
#
5+
# Template workflow to run the unit tests of the package
6+
#
7+
8+
name: Test Spot
9+
10+
on:
11+
workflow_call:
12+
inputs:
13+
os:
14+
type: string
15+
required: true
16+
python-version:
17+
type: string
18+
required: true
19+
20+
jobs:
21+
Test-Spot:
22+
name: Test ${{ inputs.os }} ${{ inputs.python-version }}
23+
runs-on: ${{ inputs.os }}
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
28+
- name: Set up Python ${{ inputs.python-version }}
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: ${{ inputs.python-version }}
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
37+
- name: Install package
38+
run: python -m pip install ".[dev]"
39+
40+
- name: Testing Spot REST endpoints
41+
run: pytest tests/

.github/workflows/cicd.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
3+
# Github: https://github.com/btschwertfeger
4+
#
5+
# Workflow to apply pre-commit, build, test and upload the package
6+
# to the test index of PyPI.
7+
8+
name: CI/CD
9+
10+
on:
11+
push:
12+
branches:
13+
- "**"
14+
15+
concurrency:
16+
group: CICD-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
## Checks the code logic, style and more
21+
##
22+
Pre-Commit:
23+
uses: ./.github/workflows/_pre_commit.yml
24+
25+
## Builds the package on multiple OS for multiple
26+
## Python versions
27+
##
28+
Build:
29+
needs: [Pre-Commit]
30+
uses: ./.github/workflows/_build.yml
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
os: [ubuntu-latest, macos-latest] # todo: windows-latest
35+
python-version: ["3.8", "3.9", "3.10", "3.11"]
36+
with:
37+
os: ${{ matrix.os }}
38+
python-version: ${{ matrix.python-version }}
39+
40+
## Run the unit tests for Python 3.8 until 3.11
41+
##
42+
Test:
43+
needs: [Build]
44+
uses: ./.github/workflows/_test.yml
45+
strategy:
46+
matrix:
47+
os: [ubuntu-latest]
48+
python-version: ["3.8", "3.9", "3.10", "3.11"]
49+
with:
50+
os: ${{ matrix.os }}
51+
python-version: ${{ matrix.python-version }}
52+
53+
## Uploads the package to test.pypi.org on master if triggered by
54+
## a regular commit/push.
55+
##
56+
UploadTestPyPI:
57+
if: success() && github.ref == 'refs/heads/master'
58+
needs: [Test]
59+
name: Upload current development version to Test PyPI
60+
uses: ./.github/workflows/_pypi_publish.yml
61+
with:
62+
REPOSITORY_URL: https://test.pypi.org/legacy/
63+
secrets:
64+
API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
65+
66+
## Generates and uploads the coverage statistics to codecov
67+
##
68+
CodeCov:
69+
needs: [Test]
70+
uses: ./.github/workflows/_codecov.yml
71+
with:
72+
os: "ubuntu-latest"
73+
python-version: "3.11"
74+
secrets: inherit

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/python-package.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)