enable parallel testing using pytest-xdist #381
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
name: Build and test Python package | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths: | |
- bin/** | |
- src/** | |
- tests/** | |
- setup.py | |
- .github/workflows/build.yml | |
pull_request: | |
branches: | |
- main | |
- dev | |
paths: | |
- bin/** | |
- src/** | |
- tests/** | |
- setup.py | |
- .github/workflows/build.yml | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
jobs: | |
smoke_test: | |
name: Smoke test on ubuntu for python 3.10 | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.draft == false | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
- name: Python info | |
shell: bash -l {0} | |
run: | | |
which python3 | |
python3 --version | |
- name: Upgrade pip and install dependencies | |
run: | | |
python3 -m pip install --upgrade pip setuptools | |
pip install build pytest wheel | |
- name: Build the package | |
run: python -m build | |
- name: Install nplinker | |
run: | | |
pip install $(ls dist/nplinker*.whl) | |
install-nplinker-deps --run-on-github | |
- name: Run unit tests | |
run: pytest -v | |
build: | |
needs: smoke_test | |
name: Build for (${{ matrix.python-version }}, ${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ['ubuntu-latest'] | |
python-version: ['3.9', '3.11'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Python info | |
shell: bash -l {0} | |
run: | | |
which python3 | |
python3 --version | |
- name: Upgrade pip and install dependencies | |
run: | | |
python3 -m pip install --upgrade pip setuptools | |
pip install build pytest wheel | |
- name: Build the package | |
run: python -m build | |
- name: Install nplinker | |
run: | | |
pip install $(ls dist/nplinker*.whl) | |
install-nplinker-deps --run-on-github | |
- name: Run unit tests | |
run: pytest -v | |
sonarcloud: | |
name: SonarCloud | |
needs: smoke_test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
- name: Python info | |
shell: bash -l {0} | |
run: | | |
which python3 | |
python3 --version | |
- name: Upgrade pip and setuptools | |
run: | | |
python3 -m pip install --upgrade pip setuptools wheel | |
- name: Install nplinker and its dependencies | |
run: | | |
python3 -m pip install .[dev] | |
install-nplinker-deps --run-on-github | |
- name: Check style against standards using ruff | |
run: ruff . | |
- name: Run unit tests with coverage | |
run: pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/ | |
- name: Correct coverage paths | |
run: sed -i "s+$PWD/++g" coverage.xml | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{secrets.SONAR_TOKEN }} |