Skip to content

Commit

Permalink
ci: modularise ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
srfoster65 committed Nov 17, 2023
1 parent b9c9b39 commit fb363fe
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 16 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI

on:
- push
- workflow_call

jobs:
Expand All @@ -21,16 +20,6 @@ jobs:
- name: Install dependencies
run: pdm install -G test

- name: Test with pytest
run: pdm run pytest --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
flags: build
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Build a binary wheel and a source tarball
run: pdm build

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Docs
on:
push:
branches:
- main
- workflow_call

permissions:
contents: write
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Github Release

on:
- workflow_call

jobs:

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v1.2.3
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release create
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
--generate-notes
1 change: 0 additions & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: mypy

on:
- push
- workflow_call

jobs:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PYPI

on:
- workflow_call

jobs:

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/arg-init
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 0 additions & 1 deletion .github/workflows/lint.yml → .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: lint

on:
- push
- workflow_call

jobs:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: test

on:
- workflow_call

jobs:
test:
name: run unittests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: 3.11
cache: true

- name: Install dependencies
run: pdm install -G test

- name: Test with pytest
run: pdm run pytest --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
flags: build
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
- push

jobs:

# Stage 1: Validate Source
test:
name: Test the package
uses: ./.githib/workflows/test.yml

mypy:
name: Static Type Check the package
uses: ./.githib/workflows/mypy.yml

ruff:
name: Lint the package
uses: ./.githib/workflows/ruff.yml


# Stage 2: Build Packages
build:
name: Build the package
uses: ./.github/workflows/build.yml
needs:
- test
- mypy
- ruff

# Stage 3: Release Packages and Build documentation
pypi:
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
uses: ./.github/workflows/pypi.yml
needs:
- build

github:
if: startsWith(github.ref, 'refs/tags/') # only publish to github on tag pushes
uses: ./.github/workflows/github.yml
needs:
- build

docs:
uses: ./.github/workflows/docs.yml
needs:
- build

0 comments on commit fb363fe

Please sign in to comment.