-
Notifications
You must be signed in to change notification settings - Fork 12
250 lines (220 loc) · 7.45 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
244
245
246
247
248
249
250
name: CI
on:
workflow_dispatch:
push:
branches: ['main', 'dev-*']
pull_request:
release:
types: [published]
env:
PINS_ALLOW_RSC_SHORT_NAME: 1
PINS_FEATURE_PREVIEW: 1
jobs:
tests:
name: "Tests"
runs-on: ${{ matrix.os }}
if: ${{ !github.event.pull_request.head.repo.fork }}
strategy:
fail-fast: false
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: ["ubuntu-latest"]
pytest_opts: ["--workers 4 --tests-per-worker 1"]
requirements: [""]
include:
- os: "ubuntu-latest"
python: "3.9"
requirements: "requirements/minimum.txt"
- os: "macos-latest"
python: "3.10"
# ignore doctests, as they involve calls to github, and all mac machines
# use the same IP address
pytest_opts: "--workers 4 --tests-per-worker 1 -k pins/tests"
- os: "windows-latest"
python: "3.10"
# ignore doctests
pytest_opts: "-k pins/tests"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
# optionally install from requirements file
if [ $REQUIREMENTS ]; then
pip install -r $REQUIREMENTS
fi
python -m pip install -e .[test]
- 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: Run tests
shell: bash
run: |
pytest pins -m 'not fs_rsc and not skip_on_github' $PYTEST_OPTS
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "us-east-1"
AZURE_STORAGE_ACCOUNT_NAME: ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }}
AZURE_STORAGE_ACCOUNT_KEY: ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }}
PYTEST_OPTS: ${{ matrix.pytest_opts }}
REQUIREMENTS: ${{ matrix.requirements }}
ACTION_OS: ${{ matrix.os }}
# fixes error on macosx virtual machine with pytest-parallel
# https://github.com/browsertron/pytest-parallel/issues/93
no_proxy: "*"
test-rsconnect:
name: "Test Posit Connect"
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/dev.txt
python -m pip install -e .
- name: run Posit Connect
run: |
docker compose up --build -d
make dev
env:
RSC_LICENSE: ${{ secrets.RSC_LICENSE }}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# NOTE: edited to run checks for python package
- name: Run tests
run: |
pytest pins -m 'fs_rsc and not skip_on_github'
test-fork:
name: "Test a fork PR (no secrets)"
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.head.repo.fork }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[test]
- name: Run tests
run: |
# TODO: better way to disable all cloud backend tests?
pytest pins -m 'not fs_rsc and not fs_s3 and not fs_gcs and not fs_abfs and not skip_on_github'
build-docs:
name: "Build Docs"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/dev.txt
python -m pip install -e .
python -m ipykernel install --user
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: Build docs
run: |
make docs-build
- name: Save docs artifact
uses: actions/upload-artifact@v4
with:
name: docs-html
path: docs/_site
preview-docs:
name: "Preview Docs:"
runs-on: ubuntu-latest
needs: ["build-docs"]
if: "${{github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork }}"
steps:
- uses: actions/download-artifact@v4
with:
name: docs-html
path: docs/_site
# Determine the 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 }}
# create deployment ----
- name: Create Github Deployment
uses: bobheadxi/[email protected]
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 }}'
# push docs ----
- name: Netlify docs preview
run: |
npm install -g netlify-cli
# push main branch to production, others to preview --
netlify deploy --dir=docs/_site --alias="${ALIAS}"
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
ALIAS: ${{ steps.deployment.outputs.env }}
# update deployment ----
- name: Update Github Deployment
uses: bobheadxi/[email protected]
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 }}--pins-python.netlify.app'
logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
publish-docs:
name: "Publish Docs"
runs-on: ubuntu-latest
needs: ["build-docs", "tests", "test-rsconnect"]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/download-artifact@v4
with:
name: docs-html
path: docs/_site
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_site
release-pypi:
name: "Release to pypi"
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [build-docs, tests, test-rsconnect]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: "Build Package"
run: |
python -m pip install build wheel
python -m build --sdist --wheel
- name: "Deploy to Test PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}