fix: force use the matrix env #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI-CD | |
# only run on pushes to main or pull requests | |
on: | |
push: | |
# push to any branch * | |
branches: [main] | |
pull_request: | |
branches: [main, development] | |
jobs: | |
################################################################################################ | |
# Unit-Tests: Run unit tests using pytest | |
################################################################################################ | |
Unit-Tests: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 15 # Consider increasing timeout | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, macos-14, windows-latest] | |
env: ["py310", "py311", "py312"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Pixi | |
uses: prefix-dev/setup-pixi@v0.7.0 | |
with: | |
environments: ${{ matrix.env }} | |
pixi-version: v0.22.0 | |
cache: false | |
- name: Run pytest | |
run: | | |
pixi run -e {{ matrix.env }} test | |
- name: Upload coverage report artifact to be used by Codecov | |
# only upload if matrix.os is ubuntu-latest and matrix.python-version is 3.12 | |
if: matrix.os == 'ubuntu-latest' | |
uses: actions/upload-artifact@v2 | |
with: | |
name: coverage-report | |
path: coverage-report | |
################################################################################################ | |
# Codecov: Run codecov to check coverage | |
################################################################################################ | |
Code-Coverage: | |
needs: Unit-Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download coverage.xml artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: coverage-report | |
path: coverage-report | |
- name: Use Codecov to track coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage-report/coverage.xml | |
fail_ci_if_error: true | |
verbose: true | |
name: codecov-umbrella | |
################################################################################################ | |
# Ruff: Run ruff linter | |
################################################################################################ | |
Ruff: | |
runs-on: ubuntu-latest | |
env: | |
PIXI_ENV: "dev" | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Pixi | |
uses: prefix-dev/setup-pixi@v0.7.0 | |
with: | |
environments: ${{ env.PIXI_ENV }} | |
pixi-version: v0.22.0 | |
cache: false | |
# cache-key: pixi-ENV_${{ env.PIXI_ENV }}- | |
- name: Run Ruff | |
run: pixi run lint | |
################################################################################################ | |
# Docs: Build and deploy mkdocs documentation | |
################################################################################################ | |
Docs: | |
runs-on: ubuntu-latest | |
env: | |
PIXI_ENV: "dev" | |
permissions: | |
# Need to give the action permission to write to the repository to deploy the docs | |
contents: write | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
steps: | |
- name: Check-out repository | |
uses: actions/checkout@v4 | |
- name: Configure Git Credentials | |
run: | | |
git config user.name github-actions[bot] | |
git config user.email github-actions[bot]@users.noreply.github.com | |
- name: Install Pixi | |
uses: prefix-dev/setup-pixi@v0.7.0 | |
with: | |
environments: ${{ env.PIXI_ENV }} | |
pixi-version: v0.22.0 | |
cache: false | |
# cache-key: pixi-ENV_${{ env.PIXI_ENV }}- | |
- name: Build and deploy documentation | |
run: pixi run doc-deploy | |
################################################################################################ | |
# Semantic-Release: Run semantic-release to automate versioning and publishing | |
################################################################################################ | |
Semantic-Release: | |
permissions: | |
# Read releases read-all | |
contents: write | |
packages: write | |
issues: write | |
pull-requests: write | |
needs: [Unit-Tests, Ruff, Docs] | |
# if pulling to main, deploy to PyPI | |
if: github.ref == 'refs/heads/main' | |
env: | |
PIXI_ENV: "publish" | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ["3.12"] | |
# Set up operating system | |
runs-on: ${{ matrix.os }} | |
# Concurrency is for preventing multiple runs of the same workflow | |
concurrency: release | |
outputs: | |
released: ${{ steps.release.outputs.released }} | |
version: ${{ steps.release.outputs.version }} | |
tag: ${{ steps.release.outputs.tag }} | |
# Define job steps | |
steps: | |
- name: Check-out repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Install Pixi | |
uses: prefix-dev/setup-pixi@v0.7.0 | |
env: | |
RUNNER_DEBUG: true | |
with: | |
environments: ${{ env.PIXI_ENV }} | |
pixi-version: v0.22.0 | |
cache: false | |
# cache-key: pixi-ENV_${{ env.PIXI_ENV }}- | |
- name: Run semantic-release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
id: release | |
run: pixi run release | |
################################################################################################ | |
# Publish-To-PyPi & Test-PyPi-Installation: Publish to PyPI and test installation | |
################################################################################################ | |
Publish-To-PyPi: | |
needs: Semantic-Release | |
env: | |
PIXI_ENV: "publish" | |
if: needs.Semantic-Release.outputs.released == 'true' | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout the code with tag ${{ needs.Semantic-Release.outputs.tag }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.Semantic-Release.outputs.tag }} | |
- name: Install Pixi | |
uses: prefix-dev/setup-pixi@v0.7.0 | |
with: | |
environments: ${{ env.PIXI_ENV }} | |
pixi-version: v0.22.0 | |
# cache-key: pixi-ENV_${{ env.PIXI_ENV }}- | |
cache: false | |
locked: false # wont be the same because of the tag | |
- name: Publish to PyPI | |
env: | |
HATCH_INDEX_USER: __token__ | |
HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }} | |
HATCH_INDEX_REPO: https://upload.pypi.org/legacy/ | |
run: | | |
pixi run publish-pypi | |
Test-PyPi-Installation: | |
needs: Publish-To-PyPi | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
python-version: ["3.12"] | |
environments: [publish] | |
steps: | |
- name: Checkout the code with tag ${{ needs.Semantic-Release.outputs.tag }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.Semantic-Release.outputs.tag }} | |
- name: setup python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install using PyPI | |
run: | | |
pip install testmypixipkg | |
################################################################################################ | |
# Publish-To-Test-PyPi & Test-TestPypi-Installation: Publish to TestPyPI and test installation | |
################################################################################################ | |
Publish-To-Test-PyPi: | |
needs: Semantic-Release | |
env: | |
PIXI_ENV: "publish" | |
if: needs.Semantic-Release.outputs.released == 'true' | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout the code with tag ${{ needs.Semantic-Release.outputs.tag }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.Semantic-Release.outputs.tag }} | |
- name: Install Pixi | |
uses: prefix-dev/setup-pixi@v0.7.0 | |
with: | |
environments: ${{ env.PIXI_ENV }} | |
pixi-version: v0.22.0 | |
# cache-key: pixi-ENV_${{ env.PIXI_ENV }}- | |
cache: false | |
locked: false # wont be the same because of the tag | |
- name: Publish to TestPyPI | |
env: | |
HATCH_INDEX_USER: __token__ | |
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
run: | | |
pixi run publish-test | |
Test-TestPypi-Installation: | |
needs: Publish-To-Test-PyPi | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
python-version: ["3.12"] | |
environments: [publish] | |
steps: | |
- name: Checkout the code with tag ${{ needs.Semantic-Release.outputs.tag }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.Semantic-Release.outputs.tag }} | |
- name: setup python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install using TestPyPI | |
run: | | |
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ testmypixipkg |