Skip to content

move the coverage to python-tests and use secret token as the trigger #1

move the coverage to python-tests and use secret token as the trigger

move the coverage to python-tests and use secret token as the trigger #1

Workflow file for this run

name: Python Tests

Check failure on line 1 in .github/workflows/python-tests.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/python-tests.yml

Invalid workflow file

(Line: 90, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.codecov_token != '', (Line: 94, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.codecov_token == '', (Line: 98, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.codecov_token != '', (Line: 107, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.codecov_token != '', (Line: 114, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.codecov_token != ''
on:
workflow_call:
inputs:
python-version:
required: false
type: string
default: "3.12"
os:
required: false
type: string
default: "ubuntu-latest"
pytest-args:
required: false
type: string
default: "-v -ra -W error"
codecov-flags:
required: false
type: string
default: ""
jupyter-platform-dirs:
required: false
type: string
default: "1"
qt-qpa-platform:
required: false
type: string
default: "offscreen"
qt-api:
required: false
type: string
default: ""
qt-binding:
required: false
type: string
default: ""
display:
required: false
type: string
default: "0"
secrets:
codecov_token:
required: false
jobs:
test:
runs-on: ${{ inputs.os }}
steps:
- uses: ewoks-kit/.github/.github/actions/setup-python-package@main
with:
python-version: ${{ inputs.python-version }}
install-extras: "test"
- name: Install Qt runtime libraries
if: startsWith(inputs.os, 'ubuntu') && (inputs.qt-api != '' || inputs.qt-binding != '')
run: |
sudo apt-get update
sudo apt-get install -y libegl1
- name: Configure test environment
shell: bash
run: |
if [ -n "${{ inputs.jupyter-platform-dirs }}" ]; then
echo "JUPYTER_PLATFORM_DIRS=${{ inputs.jupyter-platform-dirs }}" >> "$GITHUB_ENV"
fi
if [ -n "${{ inputs.qt-qpa-platform }}" ]; then
echo "QT_QPA_PLATFORM=${{ inputs.qt-qpa-platform }}" >> "$GITHUB_ENV"
fi
if [ -n "${{ inputs.qt-api }}" ]; then
echo "QT_API=${{ inputs.qt-api }}" >> "$GITHUB_ENV"
fi
if [ -n "${{ inputs.display }}" ]; then
echo "DISPLAY=${{ inputs.display }}" >> "$GITHUB_ENV"
fi
if [ -n "${{ inputs.qt-binding }}" ]; then
echo "QT_BINDING=${{ inputs.qt-binding }}" >> "$GITHUB_ENV"
fi
- name: Resolve distribution name
shell: bash
env:
REPO_NAME: ${{ github.event.repository.name }}
run: |
DISTRO_NAME="${REPO_NAME//-/_}"
echo "DISTRO_NAME=$DISTRO_NAME" >> "$GITHUB_ENV"
- name: Install coverage tooling
if: ${{ secrets.codecov_token != '' }}
run: pip install pytest-cov "coverage[toml]"
- name: Run pytest
if: ${{ secrets.codecov_token == '' }}
run: pytest ${{ inputs.pytest-args }} --pyargs "$DISTRO_NAME"
- name: Run pytest with coverage
if: ${{ secrets.codecov_token != '' }}
run: |
pytest ${{ inputs.pytest-args }} \
--cov="$DISTRO_NAME" \
--cov-report=term \
--cov-report=xml \
--pyargs "$DISTRO_NAME"
- name: Upload coverage artifact
if: ${{ secrets.codecov_token != '' }}
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
- name: Upload coverage to Codecov
if: ${{ secrets.codecov_token != '' }}
uses: codecov/codecov-action@v5
with:
files: coverage.xml
flags: ${{ inputs.codecov-flags }}
token: ${{ secrets.codecov_token }}
fail_ci_if_error: false