-
Notifications
You must be signed in to change notification settings - Fork 308
180 lines (167 loc) · 5.63 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
name: Tests master
on:
# This avoids having duplicate builds for a pull request
push:
branches:
- master
- "*-maintenance"
tags:
- "v*"
pull_request:
branches:
- master
- "*-maintenance"
jobs:
############################################################################
# Lint jobs
############################################################################
lint:
name: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "lts/*"
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Install node dependencies
run: make frontend/node_modules
- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
cache-dependency-path: "**/pyproject.toml"
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install python dependencies
id: pip
run: |
python -m pip install --upgrade pip
python -m pip install tox pre-commit
python -m pip freeze --local
- name: Run pylint
run: tox -e lint
- name: Run pre-commit
# run pre-commit check even if pylint check fails
if: steps.pip.outcome == 'success'
run: pre-commit run --show-diff-on-failure --color=always --all-files
############################################################################
# Node tests
############################################################################
node-tests:
name: ${{ matrix.os}} node-${{ matrix.node }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node: ["lts/*"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
include:
- node: "current"
os: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Build frontend
run: make
- name: Typecheck and run frontend tests
run: make test-js
############################################################################
# Python tests
############################################################################
python-tests:
name: ${{ matrix.os }} py${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
exclude:
- os: "macos-latest"
python: "3.9"
- os: "macos-latest"
python: "3.10"
- os: "macos-latest"
python: "3.11"
- os: "windows-latest"
python: "3.9"
- os: "windows-latest"
python: "3.10"
- os: "windows-latest"
python: "3.11"
include:
- python: "3.12"
install-ffmpeg: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: "pip"
cache-dependency-path: "**/pyproject.toml"
- name: Install Linux system dependencies
if: runner.os == 'Linux' && matrix.install-ffmpeg
run: |
sudo apt-get update
sudo apt-get -y install ffmpeg
- name: Install macOS system dependencies
if: runner.os == 'macOS' && matrix.install-ffmpeg
run: brew install ffmpeg
- name: Install Windows system dependencies
if: runner.os == 'Windows' && matrix.install-ffmpeg
run: choco install --no-progress --timeout 600 ffmpeg
continue-on-error: true
- name: Workaround for UnicodeDecodeError from tox on Windows
# Refs:
# https://github.com/lektor/lektor/pull/933#issuecomment-923107580
# https://github.com/tox-dev/tox/issues/1550
if: runner.os == 'Windows'
run: Out-File $env:GITHUB_ENV utf8 -Append -InputObject 'PYTHONIOENCODING=utf-8'
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions coverage[toml]
- name: Run python tests
run: tox
- name: Publish coverage data to codecov
uses: codecov/codecov-action@v3
############################################################################
# Package and (Possibly) Publish to PyPI
############################################################################
deploy:
needs: ["lint", "node-tests", "python-tests"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: python -m pip install build
- name: Build release artifacts
env:
HATCH_BUILD_CLEAN: "true"
run: python -m build
- name: Save release artifacts (for inspection)
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*
- name: Publish release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PASSWORD }}