Skip to content

Upload coverage only on main #1095

Upload coverage only on main

Upload coverage only on main #1095

Workflow file for this run

name: test
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_call:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
config:
- python: "3.10"
- python: "3.12"
split: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.config.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.python }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies and package
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-optional.txt
pip install -e .[test]
- name: Test with pytest
run: |
pytest --cov=smol --splits 8 --group ${{ matrix.split }} --durations-path tests/.test_durations tests
- name: Upload coverage
if: ${{ matrix.config.python == '3.12' && github.ref == 'refs/heads/main'}}
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
name: .coverage${{ matrix.split }}
path: .coverage
if-no-files-found: error
coverage:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install coverage
run: |
python -m pip install --upgrade pip
pip install coverage
- name: Download all artifacts
# Downloads coverage1, coverage2, etc.
uses: actions/download-artifact@v4
with:
pattern: .coverage*
merge-multiple: true
path: coverage
- name: Run coverage
run: |
coverage combine coverage/.coverage*
coverage xml
# coverage report --fail-under=85
- name: codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml