Skip to content

React to Python 3.13.0 Release #66

React to Python 3.13.0 Release

React to Python 3.13.0 Release #66

# It will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see:
# https://py-pkgs.org/08-ci-cd
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: test
# Controls when the workflow will run
on: [push, pull_request]
# A workflow run is made up of one or more jobs that can run
# sequentially or in parallel
jobs:
ci:
# Set up operating system
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.12", "3.11", "3.10", "3.9"]
os: [ubuntu-latest, macOS-latest, windows-latest]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pdm install -dG test
- name: Run Tests
run: |
pdm run pytest
coverage:
needs: ci
# Only run this job if new work is pushed to the "master" branch
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pdm install -dG test
# See: https://remarkablemark.org/blog/2023/10/14/setup-codeclimate-with-github-actions/
- uses: remarkablemark/setup-codeclimate@v2
- name: Run Tests and report to CodeClimate
run: |
cc-test-reporter before-build
pdm run pytest
cc-test-reporter after-build --exit-code $?
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# See: https://martinheinz.dev/blog/69 "Ultimate CI Pipeline for All of Your Python Projects"
- name: Use Codecov to track coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml # coverage report
- name: SonarCloud scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}