Skip to content

CI/CD

CI/CD #93

Workflow file for this run

# -*- coding: utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
# GitHub: https://github.com/btschwertfeger
#
# Workflow to apply pre-commit, build, test and upload the package
# to the test index of PyPI.
name: CI/CD
on:
push:
branches: [master]
schedule:
- cron: "20 16 */7 * *"
release:
types: [created]
pull_request:
types: [opened, synchronize, reopened]
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
## ===========================================================================
## Checks the code logic, style and more
##
Pre-Commit:
uses: ./.github/workflows/_pre_commit.yaml
## ===========================================================================
## Discover vulnerabilities
##
CodeQL:
uses: ./.github/workflows/_codeql.yaml
## ===========================================================================
## Builds the package on multiple OS for multiple
## Python versions
##
Build:
needs: [Pre-Commit]
uses: ./.github/workflows/_build.yaml
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.11", "3.12", "3.13"]
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
## ===========================================================================
## Build the Docker image
##
Build-Docker:
needs: [Pre-Commit]
uses: ./.github/workflows/_build_docker.yaml
## ===========================================================================
## Build the documentation
##
Build-Doc:
needs: [Pre-Commit]
uses: ./.github/workflows/_build_doc.yaml
with:
os: "ubuntu-latest"
python-version: "3.11"
## ===========================================================================
## Run the unit and integration tests
##
Test:
needs: [Pre-Commit]
uses: ./.github/workflows/_test.yaml
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.11", "3.12", "3.13"]
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
## ===========================================================================
## Generates and uploads the coverage statistics to codecov
##
CodeCov:
if: |
success()
&& github.actor == 'btschwertfeger'
&& github.event_name != 'schedule'
needs: [Pre-Commit]
uses: ./.github/workflows/_codecov.yaml
with:
os: "ubuntu-latest"
python-version: "3.11"
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
## ===========================================================================
## Uploads the package to test.pypi.org on master if triggered by
## a regular commit/push.
##
UploadTestPyPI:
if: |
success()
&& github.ref == 'refs/heads/master'
&& (github.event_name == 'push' || github.event_name == 'release')
needs:
- Build
- Build-Doc
- Build-Docker
- CodeCov
- CodeQL
- Test
uses: ./.github/workflows/_pypi_test_publish.yaml
secrets:
API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
## ===========================================================================
## Upload the package to PyPI
##
UploadPyPI:
if: |
success()
&& github.actor == 'btschwertfeger'
&& github.event_name == 'release'
needs:
- Build
- Build-Doc
- Build-Docker
- CodeCov
- CodeQL
- Test
uses: ./.github/workflows/_pypi_publish.yaml
secrets:
API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
## ===========================================================================
## Upload the package GitHub's Docker registry
##
UploadDockerImage:
if: |
success()
&& github.actor == 'btschwertfeger'
&& (
(github.event_name == 'push' && github.ref == 'refs/heads/master')
|| github.event_name == 'release'
)
needs:
- Build
- Build-Doc
- Build-Docker
- CodeCov
- CodeQL
- Test
uses: ./.github/workflows/_docker_publish.yaml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}