[pre-commit.ci] pre-commit autoupdate #1271
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: hatch-tests | |
on: | |
pull_request: | |
branches: [ "master", "main" ] | |
paths-ignore: [ "docs/**" ] | |
push: | |
branches: [ "master", "main" ] | |
paths-ignore: [ "docs/**" ] | |
schedule: | |
- cron: '0 12 * * 0' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.10", "3.12"] | |
django-version: ["4.2", "5.0"] | |
backend: ["sqlite", "mysql"] | |
mariadb-version: ["10.6"] # What we're currently running with. | |
include: | |
- python-version: "3.12" # Unbuntu 24.04.01 upgrade. | |
django-version: "4.2" | |
backend: "mysql" | |
mariadb-version: "10.11" | |
exclude: | |
- python-version: "3.8" # Django 5.0 is not supported on Python 3.8. | |
django-version: "5.0" | |
name: "py${{ matrix.python-version }}-dj${{ matrix.django-version }}-${{ matrix.backend }}-${{ matrix.mariadb-version }}" | |
runs-on: ubuntu-latest | |
env: | |
PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures. | |
TEST_ENV: "test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}" | |
services: | |
database: | |
image: mariadb:${{ matrix.mariadb-version }} | |
env: | |
MYSQL_ROOT_PASSWORD: rootpw | |
MYSQL_DATABASE: test | |
ports: | |
- 3306:3306 | |
options: --tmpfs /var/lib/mysql | |
steps: | |
- uses: actions/[email protected] | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install hatch | |
run: python -m pip install --upgrade hatch | |
- name: Set environment variables | |
if: ${{ matrix.backend == 'mysql' }} | |
run: | | |
echo "DBNAME=test" >> $GITHUB_ENV | |
echo "DBUSER=root" >> $GITHUB_ENV | |
echo "DBPASSWORD=rootpw" >> $GITHUB_ENV | |
echo "DBHOST=127.0.0.1" >> $GITHUB_ENV | |
- name: Run Tests | |
run: hatch run $TEST_ENV:cov | |
- name: Rename coverage file | |
run: | | |
ls -la .coverage* | |
mv .coverage.* coverage-${{ strategy.job-index }} | |
- name: Upload coverage data | |
uses: actions/[email protected] | |
with: | |
name: coverage-data-${{ strategy.job-index }} | |
path: coverage-${{ strategy.job-index }} | |
if-no-files-found: error | |
coverage: | |
name: Check coverage. | |
runs-on: "ubuntu-latest" | |
needs: [test] | |
steps: | |
- uses: actions/[email protected] | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: "3.12" | |
- name: Install hatch | |
run: python -m pip install --upgrade hatch | |
- name: Download coverage data | |
uses: actions/[email protected] | |
with: | |
path: ./artifacts/ | |
- name: Combine coverage data | |
run: | | |
ls -la ./artifacts/coverage-data* | |
hatch run cov:combine ./artifacts/coverage-data*/coverage-* | |
ls -la .coverage* | |
- name: Create coverage xml file | |
run: | | |
hatch run cov:xml | |
ls -la . | |
- name: Upload coverage to Codecov | |
uses: codecov/[email protected] | |
with: | |
fail_ci_if_error: true # optional (default = false) | |
token: ${{ secrets.CODECOV_TOKEN }} |