-
-
Notifications
You must be signed in to change notification settings - Fork 64
198 lines (169 loc) · 6.04 KB
/
test.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Run tests
on:
schedule:
- cron: '30 3 * * SUN'
pull_request_target:
paths:
# run tests only when the python code has changed
- 'src/**.py'
- 'tests/**.py'
workflow_dispatch:
jobs:
offline-tests:
name: offline
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
python-version: ['3.8', '3.11']
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout merge commit
uses: actions/checkout@v3
if: github.event_name == 'pull_request_target'
with:
ref: 'refs/pull/${{ github.event.number }}/merge'
persist-credentials: false
- name: Checkout head commit
uses: actions/checkout@v3
if: github.event_name != 'pull_request_target'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U .[test]
- name: Test with pytest
run: |
python -m pytest --cov=maestral --cov-report=xml tests/offline
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: pytest
env_vars: OS,PYTHON,TYPE
name: pytests -v
env:
OS: ${{ matrix.platform }}
PYTHON: ${{ matrix.python-version }}
TYPE: 'offline'
linked-unit-tests:
name: Linked unit tests
needs: offline-tests
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
include:
- platform: ubuntu-latest
token: DROPBOX_REFRESH_TOKEN_1
- platform: macos-latest
token: DROPBOX_REFRESH_TOKEN_2
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout merge commit
uses: actions/checkout@v3
if: github.event_name == 'pull_request_target'
with:
ref: 'refs/pull/${{ github.event.number }}/merge'
persist-credentials: false
- name: Checkout head commit
uses: actions/checkout@v3
if: github.event_name != 'pull_request_target'
- name: Set up Python 3.11
uses: actions/[email protected]
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U .[test]
- name: Get short-lived Oauth2 access token
# We generate a short-lived auth token which is passed to the test runner as
# an environment variable. At no point does the test code, potentially from an
# untrusted 3rd party, get access to a long-lived token.
run: |
auth_result=$(curl https://api.dropbox.com/oauth2/token \
-d grant_type=refresh_token \
-d refresh_token=${{ secrets[matrix.token] }} \
-d client_id=2jmbq42w7vof78h)
token=$(echo $auth_result | python -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
echo "::add-mask::$token"
echo "DROPBOX_ACCESS_TOKEN=$token" >> $GITHUB_ENV
- name: Test with pytest
run: |
pytest -v --cov=maestral --cov-report=xml tests/linked/unit
- name: Upload Code Coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: pytest
env_vars: OS,PYTHON,TYPE
name: pytests
env:
OS: ${{ matrix.platform }}
PYTHON: ${{ matrix.python-version }}
TYPE: 'linked-unit-tests'
linked-integration-tests:
name: Linked integration tests
needs: linked-unit-tests
strategy:
fail-fast: false
matrix:
observer: [inotify, fsevents]
include:
- observer: inotify
platform: ubuntu-latest
token: DROPBOX_REFRESH_TOKEN_1
- observer: fsevents
platform: macos-latest
token: DROPBOX_REFRESH_TOKEN_2
# - observer: kqueue
# platform: macos-latest
# token: DROPBOX_REFRESH_TOKEN_3
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout merge commit
uses: actions/checkout@v3
if: github.event_name == 'pull_request_target'
with:
ref: 'refs/pull/${{ github.event.number }}/merge'
persist-credentials: false
- name: Checkout head commit
uses: actions/checkout@v3
if: github.event_name != 'pull_request_target'
- name: Set up Python 3.11
uses: actions/[email protected]
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U .[test]
- name: Get short-lived Dropbox token
# We generate a short-lived auth token which is passed to the test runner as
# an environment variable. At no point does the test code, potentially from a
# malicious PR, get access to a long-lived token.
run: |
auth_result=$(curl https://api.dropbox.com/oauth2/token \
-d grant_type=refresh_token \
-d refresh_token=${{ secrets[matrix.token] }} \
-d client_id=2jmbq42w7vof78h)
token=$(echo $auth_result | python -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
echo "::add-mask::$token"
echo "DROPBOX_ACCESS_TOKEN=$token" >> $GITHUB_ENV
- name: Test with pytest
run: |
pytest --verbose --cov=maestral --cov-report=xml tests/linked/integration --fs-observer ${{ matrix.observer }}
- name: Upload Code Coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: pytest
env_vars: OS,PYTHON,TYPE
name: pytests
env:
OS: ${{ matrix.platform }}
PYTHON: ${{ matrix.python-version }}
TYPE: 'linked-integration-tests'