-
Notifications
You must be signed in to change notification settings - Fork 17
172 lines (165 loc) · 4.38 KB
/
tests.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Tests
# Controls when the workflow will run
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
tests:
runs-on: ubuntu-latest
strategy:
max-parallel: 20
matrix:
python-version: ['3.9']
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/checkout@v3
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v1
with:
path: ~/.cache/torch
key: ${{ runner.os }}-cache-torch
- uses: actions/cache@v1
with:
path: ~/.torch
key: ${{ runner.os }}-torch
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements.txt
run: |
function retry-with-backoff() {
for BACKOFF in 0 1 2 4 8 16 32 64; do
sleep $BACKOFF
if "$@"; then
return 0
fi
done
return 1
}
python -m pip install --upgrade pip setuptools wheel
retry-with-backoff pip install -r requirements.txt
retry-with-backoff pip install -r requirements_dev.txt
- name: flake8
run: |
flake8 shifthappens
flake8 tests
- name: black
run: |
black --check --verbose .
- name: isort
run: |
isort --check .
- name: Install package
run: |
pip install -e .
- name: Install tests/requirements.txt
run: |
function retry-with-backoff() {
for BACKOFF in 0 1 2 4 8 16 32 64; do
sleep $BACKOFF
if "$@"; then
return 0
fi
done
return 1
}
retry-with-backoff pip install -r tests/requirements.txt
- name: mypy (package)
run: |
mypy --install-types --non-interactive shifthappens/
mypy -p shifthappens
- name: mypy (tests)
run: |
mypy tests/
- name: Test with pytest
run: |
pytest --durations=0 --verbose
docstrings:
runs-on: ubuntu-latest
strategy:
max-parallel: 20
matrix:
python-version: ['3.9']
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/checkout@v3
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements.txt
run: |
function retry-with-backoff() {
for BACKOFF in 0 1 2 4 8 16 32 64; do
sleep $BACKOFF
if "$@"; then
return 0
fi
done
return 1
}
python -m pip install --upgrade pip setuptools wheel
retry-with-backoff pip install -r requirements_dev.txt
- name: interrogate
run: |
interrogate -v -c pyproject.toml .
wheel-tests:
runs-on: ubuntu-latest
strategy:
max-parallel: 20
matrix:
python-version: ['3.9']
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v1
with:
path: ~/.cache/torch
key: ${{ runner.os }}-cache-torch
- uses: actions/cache@v1
with:
path: ~/.torch
key: ${{ runner.os }}-torch
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build pytest
- name: Build wheel
run: |
python -m build --wheel
- name: Install wheel
run: |
wheelname=$(ls dist/shifthappens-*.whl| head -1)
pip install $wheelname
- name: Test with pytest
run: |
pytest --durations=0 --verbose