Skip to content

Commit

Permalink
#296 - refactor to reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamforka committed Oct 1, 2023
1 parent 998dfb9 commit b11b934
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 51 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/_build-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: build-package
on:
workflow_call:
jobs:
build:
name: Build wheel and sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install build dependencies
run: pip install --no-cache-dir -U pip .['build']
- name: Build package
run: ./scripts/cd.py --build
- name: Upload built distributions
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: integration-tests [experimental]
name: integration-tests
on:
pull_request:
workflow_call:
secrets:
DOCKER_TOKEN:
required: true
jobs:
integration_tests:
integration-tests:
name: Run integration tests
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: static-checks
on:
pull_request:
workflow_call:
jobs:
build:
static-checks:
name: Run static checks
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/_upload-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: upload-package
on:
workflow_call:
secrets:
PYPI_TOKEN:
required: true
jobs:
upload:
name: Upload wheel and sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Compare tag and package version
run: |
TAG=${GITHUB_REF#refs/*/}
VERSION=$(grep -Po '(?<=version = ")[^"]*' pyproject.toml)
if [ "$TAG" != "$VERSION" ]; then
echo "Tag value and package version are different: ${TAG} != ${VERSION}"
exit 1
fi
- name: Download built distributions
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install build dependencies
run: pip install --no-cache-dir -U pip .['build']
# - name: Upload to PyPI
# run: ./scripts/cd.py --upload
# env:
# TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
45 changes: 0 additions & 45 deletions .github/workflows/build-upload.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/main-cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: cicd
on:
push:
tags:
- "*"
pull_request:

jobs:
static-checks:
uses: ./.github/workflows/_static-checks.yml
integration-tests:
uses: ./.github/workflows/_integration-tests.yml
secrets:
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
build-package:
uses: ./.github/workflows/_build-package.yml
upload-package:
uses: ./.github/workflows/_upload-package.yml
if: startsWith(github.ref, 'refs/tags/')
needs: [static-checks, integration-tests, build-package]
secrets:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

0 comments on commit b11b934

Please sign in to comment.