-
Notifications
You must be signed in to change notification settings - Fork 8
170 lines (144 loc) · 4.63 KB
/
build.yml
File metadata and controls
170 lines (144 loc) · 4.63 KB
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
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions
name: Build
on:
push:
pull_request:
jobs:
# https://github.com/pre-commit/action
pre-commit:
name: Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- uses: pre-commit/action@v3.0.1
# Due to complications in the build process when trying to support both JupyterLab
# 2 and 3 we build the pypi packages with JupyterLab 3, but test on 2 and 3
build:
name: Build dist
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.13'
cache: pip
cache-dependency-path: 'dev-requirements*'
- uses: actions/setup-node@v6
with:
node-version: '24.x'
cache: yarn
- name: Install dependencies
run: python -mpip install -r dev-requirements-jl4.txt
- name: Build dist
run: |
python -mbuild
ls dist/*tar.gz dist/*.whl
- name: Javascript format
run: |
jlpm install
jlpm run format:check
- name: Javascript package
run: |
mkdir jsdist
jlpm pack --filename jsdist/jupyter-offlinenotebook-jlpmpack.tgz
- uses: actions/upload-artifact@v5
with:
name: dist
path: dist
if-no-files-found: error
- uses: actions/upload-artifact@v5
with:
name: jsdist
path: jsdist
if-no-files-found: error
test:
name: Pytest
needs: build
strategy:
# Keep running so we can see if other tests pass
fail-fast: false
matrix:
include:
- python-version: '3.10'
jupyterlab-major: '4'
- python-version: '3.13'
jupyterlab-major: '4'
runs-on: ubuntu-24.04
# Includes geckdriver and firefox
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: 'dev-requirements*'
- uses: actions/setup-node@v6
with:
node-version: '24.x'
cache: yarn
- name: Download artifacts from build
uses: actions/download-artifact@v6
- name: Install dependencies
run: python -mpip install -r dev-requirements-jl${{ matrix.jupyterlab-major }}.*
- name: Install plugin
run: |
python -mpip install dist/*.whl
- name: Run pytest (firefox)
run: python -mpytest -vs tests --browser=firefox
- name: Run pytest (chrome)
run: python -mpytest -vs tests --browser=chrome
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
publish-pypi:
needs:
# Only publish if other jobs passed
- pre-commit
- test
runs-on: ubuntu-24.04
permissions:
id-token: write
steps:
- name: Download artifacts from build
uses: actions/download-artifact@v6
with:
name: dist
path: dist
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.13.0
# https://docs.github.com/en/actions/language-and-framework-guides/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
publish-npm:
needs:
# Only publish if other jobs passed
- pre-commit
- test
runs-on: ubuntu-24.04
permissions:
id-token: write
steps:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v6
with:
node-version: '24.x'
registry-url: https://registry.npmjs.org
- name: Should this be set as latest
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
NPM_TAG=latest
else
NPM_TAG=dev
fi
echo "NPM_TAG=$NPM_TAG" >> "$GITHUB_ENV"
- name: Download artifacts from build
uses: actions/download-artifact@v6
with:
name: jsdist
path: jsdist
- run: npm publish --tag "$NPM_TAG" --dry-run ./jsdist/jupyter-offlinenotebook-jlpmpack.tgz
# Uses trusted publisher
- run: npm publish --tag "$NPM_TAG" ./jsdist/jupyter-offlinenotebook-jlpmpack.tgz
if: startsWith(github.ref, 'refs/tags')