-
Notifications
You must be signed in to change notification settings - Fork 19
143 lines (133 loc) · 4.12 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# 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:
enable-workflow:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'schedule' && github.repository == 'apriha/snps') }}
steps:
- name: Enable workflow based on preconditions
run: echo "Workflow enabled."
lint:
needs: [enable-workflow]
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:
needs: [enable-workflow]
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', '3.9', '3.10', '3.11']
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