Skip to content

fix: on push to any branch the ci runs and rm: uploading of lint logs #24

fix: on push to any branch the ci runs and rm: uploading of lint logs

fix: on push to any branch the ci runs and rm: uploading of lint logs #24

Workflow file for this run

name: Tests (pytest + coverage)
on:
push:
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
test:
name: Test (pytest + coverage) — ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Show Python info
run: |
python --version
which python
python -m pip --version
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install package & test deps
run: |
python -m pip install --upgrade pip
pip install .
pip install pytest pytest-cov
- name: Show installed packages (top)
run: |
pip freeze | sed -n '1,200p'
- name: Run pytest (verbose) with coverage and generate JUnit XML
run: |
mkdir -p test-output
pytest -vv --maxfail=1 --disable-warnings \
--junitxml=test-output/report.xml \
--cov=user_scanner --cov-report=xml:test-output/coverage.xml --cov-report=term
- name: Show pytest junit xml (head)
if: always()
run: |
echo "==== JUnit report (head) ===="
sed -n '1,200p' test-output/report.xml || true
echo "==== JUnit report (tail) ===="
sed -n '200,400p' test-output/report.xml || true
- name: Show coverage xml (head)
if: always()
run: |
echo "==== Coverage XML (head) ===="
sed -n '1,200p' test-output/coverage.xml || true
- name: Upload test & coverage artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.python-version }}
path: test-output
- name: (Optional) Upload coverage to Codecov
if: success() && env.CODECOV_TOKEN != ''
uses: codecov/codecov-action@v4
with:
files: test-output/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}