-
-
Notifications
You must be signed in to change notification settings - Fork 192
247 lines (211 loc) · 8.02 KB
/
main.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
name: Test, Build, and Publish
on:
push:
branches:
- main
- develop/**
tags:
- 'v*'
pull_request:
branches:
- main
- develop/**
jobs:
test-python:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
streamlit-version: [null]
include:
# Test with streamlit <1.4.0 and >=1.4.0. See https://github.com/whitphx/streamlit-webrtc/issues/598
- python-version: 3.9
streamlit-version: 1.0.0
- python-version: 3.9
streamlit-version: 1.4.0
# Test with streamlit >=1.6.0. See https://github.com/whitphx/streamlit-webrtc/issues/709
- python-version: 3.9
streamlit-version: 1.6.0
# Test with streamlit >=1.8.0. See https://github.com/whitphx/streamlit-webrtc/issues/759
- python-version: 3.9
streamlit-version: 1.8.0
# Test with streamlit >=1.12.0. See https://github.com/whitphx/streamlit-webrtc/issues/1004
- python-version: 3.9
streamlit-version: 1.12.0
# Test with streamlit >=1.12.1. See https://github.com/whitphx/streamlit-webrtc/issues/1024
- python-version: 3.9
streamlit-version: 1.12.1
# Test with streamlit >=1.14.0. See https://github.com/whitphx/streamlit-webrtc/pull/1189
- python-version: 3.9
streamlit-version: 1.14.0
# Test with streamlit >=1.18.0. See https://github.com/whitphx/streamlit-webrtc/issues/1187
- python-version: 3.9
streamlit-version: 1.18.0
# Test with streamlit >=1.27.0. See https://github.com/whitphx/streamlit-webrtc/pull/1393
- python-version: 3.9
streamlit-version: 1.27.0
# Test with streamlit >=1.34.0. See https://github.com/whitphx/streamlit-webrtc/pull/1627
- python-version: 3.9
streamlit-version: 1.34.0
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv
- name: Install a specific version of Streamlit
if: ${{ matrix.streamlit-version }}
run: poetry add -D streamlit=="${STREAMLIT_VERSION}" setuptools
env:
STREAMLIT_VERSION: ${{ matrix.streamlit-version }}
- name: Install dependencies
run: poetry install
- name: Run Ruff
run: |
poetry run ruff check --output-format=github .
poetry run ruff format . --check
- name: Type checking with mypy
run: |
poetry run mypy .
- name: Release check
run: python scripts/release_check.py streamlit_webrtc/component.py
# Frontend build is necessary for the package to be importable, in the tests
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
cache-dependency-path: streamlit_webrtc/frontend/package-lock.json
- name: Install the frontend dependencies
run: npm ci
working-directory: streamlit_webrtc/frontend
- name: Build the frontend
run: npm run build --if-present
working-directory: streamlit_webrtc/frontend
- name: Test with pytest
run: |
poetry run pytest
test-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: streamlit_webrtc/frontend
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
cache-dependency-path: streamlit_webrtc/frontend/package-lock.json
- run: npm ci
- name: Lint
run: |
npm run check:eslint
npm run check:prettier
- run: npm run build --if-present
- run: npm test
build:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
needs: [test-python, test-frontend]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
# The following steps are based on https://github.com/python-poetry/poetry/blob/def1ee8f3ae00c307ca028da53d2347615c5c32b/.github/workflows/main.yml#L51-L84
- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s pip --version || rm -rf .venv
- name: Install Python dependencies
run: poetry install
- name: Install fronend dependencies
run: npm ci
working-directory: streamlit_webrtc/frontend
- name: Build
run: make pkg/build
- name: Upload the built artifacts
uses: actions/upload-artifact@v4
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
with:
path: dist
name: streamlit-webrtc-${{ github.sha }}
- name: Upload the built artifacts (when pushed with a version tag)
uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/v')
with:
path: dist
name: streamlit-webrtc-${{ github.ref_name }}
publish:
if: ${{ !failure() && startsWith(github.ref, 'refs/tags/v') }} # `!failure()` is necessary to avoid skipping this job after successful build: https://github.com/actions/runner/issues/491
needs: [build]
permissions:
contents: write # Necessary for creating releases: https://github.com/softprops/action-gh-release#permissions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- uses: actions/download-artifact@v4
with:
name: streamlit-webrtc-${{ github.ref_name }}
path: dist
- name: Publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: poetry publish -u __token__ -p ${PYPI_TOKEN}
- name: Create a new release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true