Open Taehyun-Alex opened 3 weeks ago
I think we can use GitHub Actions Matrix to test on different Runner OS's.
.github/workflows/tests.yml
name: Tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies for Linux or macOS
if: ${{ (runner.os == 'Linux') || (runner.os == 'macOS') }}
run: |
python -m pip install --upgrade pip
pip install pytest-cov pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install dependencies for Windows
if: runner.os == 'Windows'
run: |
python -m pip install --upgrade pip
pip install pytest-cov pytest
if (Test-Path "requirements.txt") { pip install -r requirements.txt }
- name: Test with pytest
run: pytest --cov-report term-missing --cov=app tests
We can simplify if: ${{ (runner.os == 'Linux') || (runner.os == 'macOS') }}
with if: runner.os != 'Windows'
.
Optionally, we can add python-version
as another dimension for matrix to test for versions 3.10, 3.11, and 3.12.
name: Tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [ '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies for Linux or macOS
if: ${{ (runner.os == 'Linux') || (runner.os == 'macOS') }}
run: |
python -m pip install --upgrade pip
pip install pytest-cov pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install dependencies for Windows
if: runner.os == 'Windows'
run: |
python -m pip install --upgrade pip
pip install pytest-cov pytest
if (Test-Path "requirements.txt") { pip install -r requirements.txt }
- name: Test with pytest
run: pytest --cov-report term-missing --cov=app tests
User story: As Alice, I want the program's interface to be consistent across my Macbook and Windows desktop, so that I can have a uniform learning experience despite my visual impairment.
Notes: