Address CodeQL warnings #263
Workflow file for this run
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
# Copyright (C) 2024 Roberto Rossini <roberros@uio.no> | |
# | |
# SPDX-License-Identifier: MIT | |
name: CI | |
on: | |
push: | |
branches: [main] | |
paths: | |
- ".github/workflows/cache-test-datasets.yml" | |
- ".github/workflows/ci.yml" | |
- "src/**" | |
- "test/**" | |
- ".gitignore" | |
- "pyproject.toml" | |
pull_request: | |
paths: | |
- ".github/workflows/cache-test-datasets.yml" | |
- ".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 | |
permissions: | |
contents: read | |
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.13"] | |
if ("${{github.event_name}}" != "pull_request") { | |
python_versions = python_versions.concat(["3.10", "3.11", "3.12"]) | |
} | |
var includes = [] | |
for (const plat of platforms) { | |
for (const ver of python_versions) { | |
includes.push({os: plat, python_version: ver}) | |
} | |
} | |
return { include: includes } | |
cache-test-datasets: | |
name: Cache test datasets | |
uses: paulsengroup/StripePy/.github/workflows/cache-test-datasets.yml@main | |
ci: | |
name: CI | |
needs: [cache-test-datasets, matrix-factory] | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.matrix-factory.outputs.matrix) }} | |
runs-on: ${{ matrix.os }} | |
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 (Unix) | |
if: runner.os != 'Windows' | |
run: | | |
python -m venv venv | |
python -m venv venv-core | |
venv/bin/pip install '.[all,test]' | |
venv-core/bin/pip install '.' pytest pytest-cov | |
echo "STRIPEPY_ROOT=venv/bin" >> "$GITHUB_ENV" | |
echo "STRIPEPY_CORE_ROOT=venv-core/bin" >> "$GITHUB_ENV" | |
- name: Install package (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
python -m venv venv | |
python -m venv venv-core | |
venv/Scripts/pip install '.[all,test]' | |
venv-core/Scripts/pip install '.' pytest pytest-cov | |
echo "STRIPEPY_ROOT=venv/Scripts" >> "$GITHUB_ENV" | |
echo "STRIPEPY_CORE_ROOT=venv-core/Scripts" >> "$GITHUB_ENV" | |
- name: Run simple CLI tests | |
run: | | |
"$STRIPEPY_ROOT/stripepy" --help | |
"$STRIPEPY_ROOT/stripepy" --version | |
- name: Run simple CLI tests (core) | |
run: | | |
"$STRIPEPY_CORE_ROOT/stripepy" --help | |
"$STRIPEPY_CORE_ROOT/stripepy" --version | |
- name: Restore test dataset | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ needs.cache-test-datasets.outputs.cache-key }} | |
path: test/data/ | |
fail-on-cache-miss: true | |
enableCrossOsArchive: true | |
- name: Run unit tests | |
run: | | |
"$STRIPEPY_ROOT/python" -m pytest \ | |
--cov=stripepy \ | |
--verbose \ | |
--cov-report=xml \ | |
--cov-report=term \ | |
test/ \ | |
-m unit | |
- name: Upload unit test coverage report to Codecov | |
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2 | |
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 unit tests (core) | |
run: | | |
rm -f coverage.xml | |
"$STRIPEPY_CORE_ROOT/python" -m pytest \ | |
--cov=stripepy \ | |
--verbose \ | |
--cov-report=xml \ | |
--cov-report=term \ | |
test/ \ | |
-m unit | |
- name: Upload unit test coverage report to Codecov (core) | |
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2 | |
with: | |
flags: "tests | unit | python-${{ matrix.python_version }} | core" | |
disable_search: true | |
files: coverage.xml | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
- name: Run integration tests | |
run: | | |
rm -f coverage.xml | |
"$STRIPEPY_ROOT/python" -m pytest \ | |
--cov=stripepy \ | |
--verbose \ | |
--cov-report=xml \ | |
--cov-report=term \ | |
test/ \ | |
-m end2end | |
- name: Upload end2end test coverage report to Codecov | |
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2 | |
with: | |
flags: "tests | integration | python-${{ matrix.python_version }}" | |
disable_search: true | |
files: coverage.xml | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
- name: Run integration tests (core) | |
run: | | |
rm -f coverage.xml | |
"$STRIPEPY_CORE_ROOT/python" -m pytest \ | |
--cov=stripepy \ | |
--verbose \ | |
--cov-report=xml \ | |
--cov-report=term \ | |
test/ \ | |
-m end2end | |
- name: Upload end2end test coverage report to Codecov (core) | |
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2 | |
with: | |
flags: "tests | integration | python-${{ matrix.python_version }} | core" | |
disable_search: true | |
files: coverage.xml | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
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 |