Skip to content

Commit

Permalink
Adds running tests to release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
erikhuck committed Apr 18, 2024
1 parent 9332ce7 commit b62943a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 27 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
name: Build and Publish Documentation
name: Publish Documentation

on:
workflow_call:

jobs:
build:
publish-documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Upgrade pip, install package, install requirements, build docs
run: |
pip install --upgrade pip
Expand All @@ -37,11 +35,9 @@ jobs:
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git clone "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" --branch gh-pages --single-branch gh-pages
cp -r docs/_build/html/* gh-pages/
cd gh-pages
touch .nojekyll
git add .
git commit -m "Update documentation." -a || true
# The above command will fail if no changes were present, so we ignore
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/package_release.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
name: Release the Next Version of the Package
name: Package and Documentation Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
deploy:
release-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
- id: parse-version
name: Parse release version
run: |
python3 -m pip install --upgrade pip
python3 -m pip install build
python3 -m pip install twine
- name: Build package
run: python -m build
- name: Check package
run: python3 -m twine check dist/*
- name: Publish package to Test-PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
echo "version=${RELEASE_VERSION/v/}" >> "$GITHUB_OUTPUT"
env:
RELEASE_VERSION: ${{ github.event.release.tag_name }}
outputs:
version: ${{ steps.parse-version.outputs.version }}
publish-test-pypi:
uses: ./.github/workflows/pypi.yml
with:
repository_url: https://test.pypi.org/legacy/
secrets:
PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
test-test-pypi:
needs: [release-version, publish-test-pypi]
uses: ./.github/workflows/tests.yml
with:
install_command: "python3 -m pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple gpu-tracker==${{ needs.release-version.outputs.version }}"

# - name: Publish package to PyPi
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish package

on:
workflow_call:
inputs:
repository_url:
description: The URL of the PyPi distribution
required: true
type: string
secrets:
PYPI_API_TOKEN:
required: true

jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install build
- name: Build package
run: python3 -m build
- name: Publish package to a PyPi distribution
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
repository-url: ${{ inputs.repository_url }}
35 changes: 35 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run Tests

on:
workflow_call:
inputs:
install_command:
description: The command for installing the package to test.
required: true
type: string

jobs:
run-tests:
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ ubuntu-latest, windows-latest, macOS-latest ]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install testing environment
run: |
python3 -m pip install --upgrade pip
python3 -m pip install pytest pytest-mock pytest-cov
- name: Install package
uses: Wandalen/wretry.action@master
with:
command: ${{ inputs.install_command }}
attempt_limit: 10
attempt_delay: 10000
- name: Run tests on package
run: python3 -m pytest tests --cov --cov-branch --cov-report=term-missing

0 comments on commit b62943a

Please sign in to comment.