Skip to content

Collect test coverage information #101

Collect test coverage information

Collect test coverage information #101

Workflow file for this run

# Copyright (C) 2024 Roberto Rossini <[email protected]>
#
# SPDX-License-Identifier: MIT
name: CI
on:
push:
branches: [main]
paths:
- ".github/workflows/ci.yml"
- "src/**"
- "test/**"
- ".gitignore"
- "pyproject.toml"
pull_request:
paths:
- ".github/workflows/ci.yml"
- "src/**"
- "test/**"
- ".gitignore"
- "pyproject.toml"
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
matrix-factory:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-result.outputs.result }}
steps:
- name: Generate matrix
uses: actions/github-script@v7
id: set-result
with:
script: |
// Documentation
// https://docs.github.com/en/actions/learn-github-actions/contexts#fromjson
// https://github.com/actions/runner/issues/982#issuecomment-809360765
const platforms = ["windows-latest", "macos-latest", "ubuntu-latest"]
var python_versions = ["3.9", "3.12"]
if ("${{github.event_name}}" != "pull_request") {
python_versions = python_versions.concat(["3.10", "3.11"])
}
var includes = []
for (const plat of platforms) {
for (const ver of python_versions) {
includes.push({os: plat, python_version: ver})
}
}
return { include: includes }
ci:
name: CI
needs: [matrix-factory]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix-factory.outputs.matrix) }}
runs-on: ${{ matrix.os }}
env:
TEST_DATASET_ID: 4DNFIOTPSS3L
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install package
run: pip install --verbose '.[test]'
- name: Run unit tests
run: python -m pytest --cov -v --cov-report=xml .
- name: Upload unit test coverage report to Codecov
uses: codecov/codecov-action@v4
with:
flags: "tests | unit | python-${{ matrix.python_version }}"
disable_search: true
files: coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Run simple CLI tests
run: |
stripepy --help
stripepy --version
- name: Cache test dataset
id: cache-dset
uses: actions/cache/restore@v4
with:
key: ${{ env.TEST_DATASET_ID }}
path: ${{ env.TEST_DATASET_ID }}.hic
- name: Download test dataset
if: steps.cache-dset.outputs.cache-hit != 'true'
run: stripepy download --name ${{ env.TEST_DATASET_ID }}
- name: Save test dataset
if: steps.cache-dset.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ env.TEST_DATASET_ID }}
path: ${{ env.TEST_DATASET_ID }}.hic
- name: Test stripepy call
run: |
NPROC="$(python -c 'import multiprocessing as mp; print(mp.cpu_count())')"
stripepy call \
${{ env.TEST_DATASET_ID }}.hic \
100000 \
-o stripepy/ \
--glob-pers-type constant \
--glob-pers-min 0.10 \
--loc-pers-min 0.33 \
--loc-trend-min 0.25 \
--roi middle \
--nproc "$NPROC"
find stripepy/ -type f -exec ls -lah {} +
if [ ! -f stripepy/*/*/results.hdf5 ]; then
1>&2 echo 'results.hdf5 is missing!'
exit 1
fi
ci-status-check:
name: Status Check (CI)
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- ci
steps:
- name: Collect job results
if: needs.ci.result != 'success'
run: exit 1