forked from ploomber/ploomber
256 lines (210 loc) · 7.92 KB
/
ci-integration-linux.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
on:
pull_request:
push:
schedule:
- cron: '0 0 * * *'
repository_dispatch:
types: [ok-to-test-command]
name: Linux integration tests
jobs:
# Branch-based pull request
integration-trusted-linux:
runs-on: ubuntu-latest
name: Linux-integration
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'schedule' || github.event_name == 'push'
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Branch based PR checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up R
uses: r-lib/actions/setup-r@v2
- name: Config
run: |
conda create -q -n conda-env python=${{ matrix.python-version }}
# for the tests that depend on git repos
git config --global user.email "someone@example.com"
git config --global user.name "Someone"
- name: Install dependencies
run: |
eval "$(conda shell.bash hook)"
conda activate conda-env
# make the build fail quickly on flake8 errors
pip install flake8
flake8
# for some reason, conda does not resolve the env correctly and
# installs and old version of pygraphviz (1.3) which breaks in
# Python 3.7
# To support python 3.10, installing only for other versions.
VERSION=$(python -c 'import sys; print(".".join(map(str, sys.version_info[1:2])))')
if [ $VERSION!="10" ]; then
echo "installing pygraphviz"
conda install -y "pygraphviz>=1.6" -c conda-forge
else
echo "skipping pygraphviz installation"
fi
# Test vanilla installation, make sure core modules are importable
pip install .
python -c 'import ploomber'
python -c 'import ploomber.tasks'
python -c 'import ploomber.products'
python -c 'import ploomber.clients'
python -c 'import ploomber.io'
# install dev requirements
pip install .[dev]
# install IR kernel
echo "install.packages('IRkernel', repos='http://cran.us.r-project.org'); IRkernel::installspec()" | Rscript -
# install sample package for tests
pip install --editable tests/assets/test_pkg
- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLOOMBER_CLOUD_KEY: ${{ secrets.PLOOMBER_CLOUD_KEY }}
PLOOMBER_STATS_ENABLED: false
run: |
eval "$(conda shell.bash hook)"
conda activate conda-env
# doc tests
export PY_IGNORE_IMPORTMISMATCH=1
pytest src/ploomber --doctest-modules --ignore src/ploomber/resources
unset PY_IGNORE_IMPORTMISMATCH
pytest tests/cli/test_cloud_execution.py --cov=ploomber
pytest tests/cli/test_cloud.py --cov=ploomber
pytest tests/cloud --cov=ploomber
pytest tests/telemetry --cov=ploomber
# Repo owner has commented /ok-to-test on a (fork-based) pull request
Linux-integration-forked:
runs-on: ubuntu-latest
name: Linux-integration-forked
if:
github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.sha != '' &&
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.sha)
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
# Check out merge commit
- name: Fork based /ok-to-test checkout
uses: actions/checkout@v2
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up R
uses: r-lib/actions/setup-r@v2
- name: Config
run: |
conda create -q -n conda-env python=${{ matrix.python-version }}
# for the tests that depend on git repos
git config --global user.email "someone@example.com"
git config --global user.name "Someone"
- name: Install dependencies
run: |
eval "$(conda shell.bash hook)"
conda activate conda-env
# make the build fail quickly on flake8 errors
pip install flake8
flake8
# for some reason, conda does not resolve the env correctly and
# installs and old version of pygraphviz (1.3) which breaks in
# Python 3.7
# To support python 3.10, installing only for other versions.
VERSION=$(python -c 'import sys; print(".".join(map(str, sys.version_info[1:2])))')
if [ $VERSION!="10" ]; then
echo "installing pygraphviz"
conda install -y "pygraphviz>=1.6" -c conda-forge
else
echo "skipping pygraphviz installation"
fi
# Test vanilla installation, make sure core modules are importable
pip install .
python -c 'import ploomber'
python -c 'import ploomber.tasks'
python -c 'import ploomber.products'
python -c 'import ploomber.clients'
python -c 'import ploomber.io'
# install dev requirements
pip install .[dev]
# install IR kernel
echo "install.packages('IRkernel', repos='http://cran.us.r-project.org'); IRkernel::installspec()" | Rscript -
# install sample package for tests
pip install --editable tests/assets/test_pkg
- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLOOMBER_CLOUD_KEY: ${{ secrets.PLOOMBER_CLOUD_KEY }}
PLOOMBER_STATS_ENABLED: false
run: |
eval "$(conda shell.bash hook)"
conda activate conda-env
# doc tests
export PY_IGNORE_IMPORTMISMATCH=1
pytest src/ploomber --doctest-modules --ignore src/ploomber/resources
unset PY_IGNORE_IMPORTMISMATCH
pytest tests/cli/test_cloud_execution.py --cov=ploomber
pytest tests/cli/test_cloud.py --cov=ploomber
pytest tests/cloud --cov=ploomber
pytest tests/telemetry --cov=ploomber
- run: |
echo "Integration tests... success! ;-)"
# Update check run called "integration-fork"
- uses: actions/github-script@v5
id: update-check-run
if: ${{ always() }}
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;