Update unit_tests.yml to the workflow on windows, ubuntu, and macos. #138
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: Tests and Lint | |
on: [ push ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, windows-latest, macos-latest ] | |
python-version: [ "3.9", "3.10", "3.11" ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Update pip and setuptools | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade setuptools | |
- name: Install dependencies | |
run: | | |
pip install --no-cache-dir ruff pytest coverage | |
pip install --no-cache-dir -r requirements.txt | |
- name: Lint with ruff | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 . | |
# default set of ruff rules with GitHub Annotations | |
ruff --format=github --target-version=py37 . | |
continue-on-error: true | |
- name: List files in workspace | |
run: | | |
ls "${{ github.workspace }}" | |
- name: Run unit tests with coverage | |
env: # Add the env section with GITHUB_TOKEN | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
coverage run -m pytest tests/ | |
if [ "${{ matrix.os }}" == "ubuntu-latest" ] && [ "${{ matrix.python-version }}" == "3.10" ]; then | |
coverage xml -o coverage.xml | |
fi | |
- name: Upload coverage report (only for ubuntu-latest and python 3.10) | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report | |
path: coverage.xml | |
- name: Run Coveralls (only for ubuntu-latest and python 3.10) | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
uses: coverallsapp/github-action@v2 |