Skip to content

Bepv01

Bepv01 #400

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Run tests
on:
workflow_dispatch:
pull_request_target:
branches: [ main ]
types: [opened, synchronize, reopened, labeled]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, 3.11]
# Only one job at a time to avoid parallel access of test server
max-parallel: 1
if: (contains(github.event.pull_request.labels.*.name, 'safe to test') || (github.event_name == 'workflow_dispatch'))
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update pip
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
python -m pip install --user --upgrade pip
else
pip install --upgrade pip
fi
shell: bash
- name: Install package
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
pip install --user .[test]
else
pip install .[test]
fi
shell: bash
- name: Test with pytest
env:
REDCAP_API_TOKEN: ${{ secrets.REDCAP_API_TOKEN }}
ELAB_API_TOKEN: ${{ secrets.ELAB_API_TOKEN }}
shell: bash
run: |
# change directory to test installed and not local version
ls -lh
pwd
cd ..
pytest ${{ github.event.repository.name }}
run-coverall:
runs-on: [ubuntu-latest]
needs: build
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update pip
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
python -m pip install --user --upgrade pip
else
pip install --upgrade pip
fi
shell: bash
- name: Install package
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
pip install --user .[test]
else
pip install .[test]
fi
shell: bash
- name: Install Python test dependencies
run: pip install --user coveralls
- name: Create coverage
env:
REDCAP_API_TOKEN: ${{ secrets.REDCAP_API_TOKEN }}
ELAB_API_TOKEN: ${{ secrets.ELAB_API_TOKEN }}
shell: bash
run: |
# change directory to test installed and not local version
cd ..
coverage run -m pytest ${{ github.event.repository.name }}
- name: Submit to coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github