-
Notifications
You must be signed in to change notification settings - Fork 20
158 lines (147 loc) · 4.87 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
name: CI
on:
workflow_dispatch:
push:
branches: ["main", "dev-*"]
pull_request:
release:
types: [published]
jobs:
test:
name: "Test"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Checks based on python versions ---
python-version: ["3.9", "3.10"]
requirements: [""]
include:
- name: "pydantic v1"
requirements: "pydantic<2.0.0"
python-version: "3.10"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "${{ matrix.python-version }}"
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
# include requirements if specified
if [ -n "$REQUIREMENTS" ]; then
python -m pip install $REQUIREMENTS '.[dev]'
else
python -m pip install '.[dev]'
fi
env:
REQUIREMENTS: ${{ matrix.requirements }}
- name: Run tests
run: |
pytest --cov
- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
pre-commit:
name: "pre-commit checks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ".[dev]"
- uses: pre-commit/[email protected]
release-pypi:
name: "Release to pypi"
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [test]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
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 }}
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install ".[dev]"
# TODO: temporary installs for examples
# once quartodoc is stable we should move into their own libraries
python -m pip install shiny shinylive
python -m pip install --no-deps dascore==0.0.8
- uses: quarto-dev/quarto-actions/setup@v2
- name: Build 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/[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 }}"
- 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 --alias="main"
else
netlify deploy --dir=docs/_build --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/[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 }}--quartodoc.netlify.app"
logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- uses: peaceiris/actions-gh-pages@v3
if: github.event_name == 'release'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_build