-
Notifications
You must be signed in to change notification settings - Fork 48
243 lines (226 loc) · 8.44 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
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
name: CI
on:
workflow_dispatch:
push:
branches: ['main', 'dev-*']
pull_request:
release:
types: [published]
jobs:
checks:
name: "Checks"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8]
requirements: ['-r requirements.txt']
include:
# historical requirements
- name: "2020-mid dependencies"
python-version: 3.8
requirements: numpy~=1.19.1 pandas~=1.1.0 SQLAlchemy~=1.3.18 psycopg2~=2.8.5 PyMySQL==1.0.2
- name: "2021-mid dependencies"
python-version: 3.8
requirements: numpy~=1.19.1 pandas~=1.1.0 SQLAlchemy~=1.4.13 psycopg2~=2.8.5 PyMySQL==1.0.2
latest: true
- name: "2022-early dependencies"
python-version: 3.8
requirements: numpy~=1.22.0 pandas~=1.3.5 SQLAlchemy~=1.4.29 psycopg2-binary~=2.9.3 PyMySQL==1.0.2
latest: true
- name: "2022-early dependencies"
python-version: 3.10.1
requirements: numpy~=1.22.0 pandas~=1.3.5 SQLAlchemy~=1.4.29 psycopg2-binary~=2.9.3 PyMySQL==1.0.2
latest: true
steps:
- uses: actions/checkout@v2
- name: Run docker-compose
run: |
docker-compose up --build -d
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install $REQUIREMENTS
python -m pip install -r requirements-test.txt
# step to test duckdb
# TODO: move these requirements into the test matrix
pip install duckdb_engine
python -m pip install .
env:
REQUIREMENTS: ${{ matrix.requirements }}
- name: Test with pytest
run: |
make test-travis
env:
SB_TEST_PGPORT: 5433
PYTEST_FLAGS: ${{ matrix.pytest_flags }}
# optional step for running bigquery tests ----
- name: Set up Cloud SDK
if: ${{(contains(github.ref, 'bigquery') || contains(github.ref, 'refs/tags')) && matrix.latest}}
uses: google-github-actions/setup-gcloud@v0
with:
project_id: siuba-tests
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Test bigquery
if: ${{(contains(github.ref, 'bigquery') || contains(github.ref, 'refs/tags')) && matrix.latest}}
run: |
pip install git+https://github.com/googleapis/python-bigquery-sqlalchemy.git pandas-gbq==0.15.0
test-bigquery:
name: "Test BigQuery"
runs-on: ubuntu-latest
if: ${{ contains('bigquery', github.ref) || !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r requirements-test.txt
python -m pip install pytest-parallel
python -m pip install sqlalchemy-bigquery==1.3.0 pandas-gbq==0.15.0
python -m pip install .
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: siuba-tests
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Test with pytest
run: |
# tests are mostly waiting on http requests to bigquery api
# note that test backends can cache data, so more processes
# is not always faster
pytest siuba -m bigquery --workers 2 --tests-per-worker 20
env:
SB_TEST_BQDATABASE: "ci_github"
test-snowflake:
name: "Test snowflake"
runs-on: ubuntu-latest
if: ${{ contains('snowflake', github.ref) || !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r requirements-test.txt
python -m pip install pytest-parallel
python -m pip install snowflake-sqlalchemy==1.3.3
python -m pip install .
- name: Test with pytest
run: |
pytest siuba -m snowflake --workers 2 --tests-per-worker 20
env:
SB_TEST_SNOWFLAKEPASSWORD: ${{ secrets.SB_TEST_SNOWFLAKEPASSWORD }}
SB_TEST_SNOWFLAKEHOST: ${{ secrets.SB_TEST_SNOWFLAKEHOST }}
build-docs:
name: "Build Documentation"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || contains(github.ref, 'docs')
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
python -m pip install .
- uses: r-lib/actions/setup-pandoc@v1
with:
pandoc-version: '2.17.0.1'
- name: Make docs
run: |
make docs-build
# push to netlify -------------------------------------------------------
# set release name ----
- name: Configure pull release name
if: ${{github.event_name == 'pull_request'}}
run: |
echo "RELEASE_NAME=pr-${PR_NUMBER}" >> $GITHUB_ENV
env:
PR_NUMBER: ${{ github.event.number }}
- name: Configure branch release name
if: ${{github.event_name != 'pull_request'}}
run: |
# use branch name, but replace slashes. E.g. feat/a -> feat-a
echo "RELEASE_NAME=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV
# deploy ----
- name: Create Github Deployment
uses: bobheadxi/deployments@v0.4.3
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.RELEASE_NAME }}
ref: ${{ github.head_ref }}
transient: true
logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
- name: Netlify docs preview
run: |
npm install -g netlify-cli
# push main branch to production, others to preview --
if [ "${ALIAS}" == "main" ]; then
netlify deploy --dir=docs/_build/html --prod
else
netlify deploy --dir=docs/_build/html --alias="${ALIAS}"
fi
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
ALIAS: ${{ steps.deployment.outputs.env }}
- name: Update Github Deployment
uses: bobheadxi/deployments@v0.4.3
if: ${{ always() }}
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: 'https://${{ steps.deployment.outputs.env }}--siuba.netlify.app'
logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
deploy:
name: "Deploy to PyPI"
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [checks, test-bigquery, test-snowflake]
steps:
- uses: actions/checkout@v2
- name: "Set up Python 3.8"
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: "Build Package"
run: |
pip install wheel
python setup.py build sdist bdist_wheel
# test deploy ----
- name: "Test Deploy to PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.event.release.name, 'TEST')
with:
user: __token__
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
# prod deploy ----
- name: "Deploy to PyPI"
uses: pypa/gh-action-pypi-publish@master
if: "!startsWith(github.event.release.name, 'TEST')"
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}