-
Notifications
You must be signed in to change notification settings - Fork 574
175 lines (146 loc) · 5.09 KB
/
python-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
173
174
175
name: Python tests
on:
push:
branches:
- main
- ci_*
paths-ignore:
- "docs/**"
pull_request:
types: [assigned, opened, synchronize, reopened]
paths-ignore:
- "docs/**"
env:
HUGGINGFACE_PRODUCTION_USER_TOKEN: ${{ secrets.HUGGINGFACE_PRODUCTION_USER_TOKEN }}
jobs:
build-ubuntu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
test_name:
[
"Repository only",
"Everything else",
"torch",
]
include:
- python-version: "3.11" # LFS not ran on 3.8
test_name: "lfs"
- python-version: "3.8"
test_name: "fastai" # fastai not supported on 3.11 -> test it on 3.10
- python-version: "3.10"
test_name: "fastai"
- python-version: "3.8"
test_name: "tensorflow" # Tensorflow not supported on 3.11 -> test it on 3.10
- python-version: "3.10"
test_name: "tensorflow"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Install dependencies
- name: Configure and install dependencies
run: |
pip install --upgrade pip
pip install .[testing]
case "${{ matrix.test_name }}" in
"Repository only" | "Everything else")
sudo apt update
sudo apt install -y libsndfile1-dev
;;
lfs)
git config --global user.email "ci@dummy.com"
git config --global user.name "ci"
;;
fastai | torch)
pip install .[${{ matrix.test_name }}]
;;
tensorflow)
sudo apt update
sudo apt install -y graphviz
pip install .[tensorflow]
;;
esac
# Easy debugging if CI is broken
- name: Pip freeze
run: pip freeze
# Run tests
- name: Run tests
working-directory: ./src # For code coverage to work
run: |
PYTEST="python -m pytest --cov=./huggingface_hub --cov-report=xml:../coverage.xml --vcr-record=none --reruns 5 --reruns-delay 1 --only-rerun '(OSError|Timeout|HTTPError.*502|HTTPError.*504||not less than or equal to 0.01)'"
case "${{ matrix.test_name }}" in
"Repository only")
# Run repo tests concurrently
PYTEST="$PYTEST ../tests -k 'TestRepository' -n4"
echo $PYTEST
eval $PYTEST
;;
"Everything else")
PYTEST="$PYTEST ../tests -k 'not TestRepository'"
echo $PYTEST
eval $PYTEST
;;
lfs)
eval "RUN_GIT_LFS_TESTS=1 $PYTEST ../tests -k 'HfLargefilesTest'"
;;
fastai)
eval "$PYTEST ../tests/test_fastai*"
;;
tensorflow)
# Cannot be on same line since '_tf*' checks if tensorflow is NOT imported by default
eval "$PYTEST ../tests/test_tf*"
eval "$PYTEST ../tests/test_keras*"
eval "$PYTEST ../tests/test_serialization.py"
;;
torch)
eval "$PYTEST ../tests/test_hub_mixin*"
eval "$PYTEST ../tests/test_serialization.py"
;;
esac
# Upload code coverage
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
verbose: true
build-windows:
# (almost) Duplicate config compared to `build-ubuntu` but running on Windows.
# Please make sure to keep it updated as well.
# Lighter version of the tests with only 1 test suite running on Python3.8.
runs-on: windows-latest
env:
DISABLE_SYMLINKS_IN_WINDOWS_TESTS: 1
strategy:
fail-fast: false
matrix:
python-version: ["3.8"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Install dependencies
- name: Configure and install dependencies
run: |
pip install --upgrade pip
pip install .[testing]
# sudo apt install -y libsndfile1-dev
# Easy debugging if CI is broken
- name: Pip freeze
run: pip freeze
# Run tests
- name: Run tests
working-directory: ./src # For code coverage to work
run: python -m pytest --cov=./huggingface_hub --cov-report=xml:../coverage.xml --vcr-record=none --reruns 5 --reruns-delay 1 --only-rerun '(OSError|Timeout|HTTPError.*502|HTTPError.*504|not less than or equal to 0.01)' ../tests
# Upload code coverage
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
verbose: true