CI #278
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
# https://docs.github.com/en/actions | |
# https://github.com/codecov/example-python | |
# https://stackoverflow.com/a/3237883 | |
# https://stackoverflow.com/a/5688592 | |
# https://stackoverflow.com/a/6270803 | |
# https://github.com/actions/virtual-environments/issues/1341 | |
name: CI | |
on: | |
schedule: | |
- cron: '37 4 * * 0' | |
push: | |
branches: '**' | |
pull_request: | |
branches: '**' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install Black | |
run: | | |
pip install black | |
- name: Lint with Black | |
run: | | |
black --check --diff . | |
build-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install Sphinx | |
run: | | |
pip install -r docs/requirements.txt | |
pip install . | |
- name: Build docs with Sphinx | |
run: | | |
sphinx-build -W --keep-going -T -E -D language=en docs docs/_build | |
test: | |
needs: [lint, build-docs] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
include: | |
- os: macos-latest | |
python-version: '3.12' | |
- os: windows-latest | |
python-version: '3.12' | |
env: | |
JOB_ID: ${{ strategy.job-index }} | |
NUM_JOBS: ${{ strategy.job-total }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Ensure Python and source code are on same drive (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
shell: cmd | |
run: | | |
mkdir C:\a | |
xcopy D:\a C:\a /s /e | |
- name: Determine if downloads are enabled for this job | |
# for testing, limit downloads from the resource servers to only the selected job for | |
# PRs and the master branch; note that the master branch is tested weekly via `cron`, | |
# so this ensures all Python versions will be periodically integration tested with the | |
# resource servers | |
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/master' }} | |
shell: bash | |
run: | | |
SELECTED_JOB=$((10#$(date +%V) % $NUM_JOBS)) | |
if [[ $SELECTED_JOB == $JOB_ID ]]; then | |
# set environment variable to download resources for selected job | |
echo "DOWNLOADS_ENABLED=true" >> $GITHUB_ENV | |
fi | |
- name: Install dependencies | |
run: | | |
pip install pytest-cov | |
pip install . | |
- name: Test with pytest (Ubuntu & macOS) | |
if: ${{ matrix.os != 'windows-latest' }} | |
run: | | |
pytest --cov=snps tests | |
- name: Test with pytest (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
working-directory: C:\a\snps\snps | |
run: | | |
pytest --cov=snps tests | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
test-extras: | |
needs: [lint, build-docs] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ['3.8'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip setuptools wheel | |
pip install pytest-cov | |
pip install .[ezancestry] | |
- name: Test with pytest | |
run: | | |
pytest --cov=snps tests |