Skip to content

Commit

Permalink
Make GitHub unit/execution test actions callable
Browse files Browse the repository at this point in the history
  • Loading branch information
soininen committed Oct 9, 2024
1 parent 01d4410 commit 128b8b9
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 48 deletions.
55 changes: 7 additions & 48 deletions .github/workflows/test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,17 @@ on:
- "execution_tests/**"

jobs:
unit-tests:
name: Unit tests
runs-on: ${{ matrix.os }}
call-unit-tests:
strategy:
fail-fast: true
fail-fast: false
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
os: [windows-latest, ubuntu-22.04]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Version from Git tags
run: git describe --tags
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
pyproject.toml
requirements.txt
dev-requirements.txt
- name: Display Python version
run:
python -c "import sys; print(sys.version)"
- name: Install additional packages for Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y libegl1
- name: Install dependencies
env:
PYTHONUTF8: 1
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r dev-requirements.txt
- name: List packages
run:
python -m pip list
- name: Run tests
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
export QT_QPA_PLATFORM=offscreen
fi
coverage run -m unittest discover --verbose
shell: bash
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: ./.github/workflows/unit_tests.yml
with:
host-os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
secrets: inherit
execution-tests:
name: Execution tests
runs-on: ${{ matrix.os }}
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Unit tests

on:
workflow_call:
inputs:
host-os:
required: true
type: string
python-version:
required: true
type: string
repository:
required: false
type: string
default: ${{ github.repository }}
coverage:
required: false
type: boolean
default: true
post-installation-command:
required: false
type: string
default: ""
secrets:
CODECOV_TOKEN:
required: true

jobs:
unit-tests:
name: Unit tests
runs-on: ${{ inputs.host-os }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
fetch-depth: 0
- name: Version from Git tags
run: git describe --tags
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: pip
cache-dependency-path: |
pyproject.toml
requirements.txt
dev-requirements.txt
- name: Display Python version
run:
python -c "import sys; print(sys.version)"
- name: Install additional packages for Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y libegl1
- name: Install dependencies
env:
PYTHONUTF8: 1
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r dev-requirements.txt
- name: Install specific Spine-Database-API branch
if: ${{ inputs.post-installation-command }}
run:
${{ inputs.post-installation-command }}
- name: List packages
run:
python -m pip list
- name: Run tests
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
export QT_QPA_PLATFORM=offscreen
fi
${{ inputs.coverage && "coverage run" || "python" }} -m unittest discover --verbose
shell: bash
- name: Upload coverage report to Codecov
if: ${{ inputs.coverage }}
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 128b8b9

Please sign in to comment.