Skip to content

Commit bf520bb

Browse files
authored
Add lerna and pip caching (#106)
* Add lerna caching * Add pip caching * Set pip cache action after Python installation
1 parent 5f0ccbd commit bf520bb

File tree

1 file changed

+194
-132
lines changed

1 file changed

+194
-132
lines changed

.github/workflows/main.yml

Lines changed: 194 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ on:
44
push:
55
branches: master
66
pull_request:
7-
branches: '*'
7+
branches: "*"
88

99
jobs:
10-
1110
build_extensions:
1211
runs-on: ${{ matrix.os }}
1312
strategy:
@@ -32,51 +31,72 @@ jobs:
3231
- widget-tracker/widgets
3332
os: [ubuntu-latest, macos-latest, windows-latest]
3433
steps:
35-
- name: Checkout
36-
uses: actions/checkout@v2
37-
- name: Check config files
38-
run: |
39-
diff basics/hello-world/tsconfig.json ${EXAMPLE_FOLDER}/tsconfig.json
40-
diff basics/hello-world/.eslintignore ${EXAMPLE_FOLDER}/.eslintignore
41-
diff basics/hello-world/.eslintrc.js ${EXAMPLE_FOLDER}/.eslintrc.js
42-
diff basics/hello-world/.gitignore ${EXAMPLE_FOLDER}/.gitignore
43-
env:
44-
EXAMPLE_FOLDER: ${{ matrix.example }}
45-
shell: bash
46-
- name: Install node
47-
uses: actions/setup-node@v1
48-
with:
49-
node-version: '12.x'
50-
- name: Install Python
51-
uses: actions/setup-python@v1
52-
with:
53-
python-version: '3.7'
54-
architecture: 'x64'
55-
- name: Install the Python dependencies
56-
run: python -m pip install jupyterlab
57-
- name: Install the NPM dependencies
58-
run: |
59-
cd ${EXAMPLE_FOLDER}
60-
jlpm
61-
env:
62-
EXAMPLE_FOLDER: ${{ matrix.example }}
63-
shell: bash
64-
- name: Lint the files
65-
run: |
66-
cd ${EXAMPLE_FOLDER}
67-
jlpm run eslint:check
68-
env:
69-
EXAMPLE_FOLDER: ${{ matrix.example }}
70-
shell: bash
71-
- name: Build and check by extension
72-
run: |
73-
cd ${EXAMPLE_FOLDER}
74-
jlpm run build
75-
jupyter labextension install .
76-
python -m jupyterlab.browser_check
77-
env:
78-
EXAMPLE_FOLDER: ${{ matrix.example }}
79-
shell: bash
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
- name: Cache lerna
37+
uses: actions/cache@v2
38+
with:
39+
path: |
40+
node_modules
41+
*/*/node_modules
42+
key: ${{ runner.os }}-lerna-${{ hashFiles('**/package.json') }}
43+
restore-keys: |
44+
${{ runner.os }}-lerna-
45+
- name: Check config files
46+
run: |
47+
diff basics/hello-world/tsconfig.json ${EXAMPLE_FOLDER}/tsconfig.json
48+
diff basics/hello-world/.eslintignore ${EXAMPLE_FOLDER}/.eslintignore
49+
diff basics/hello-world/.eslintrc.js ${EXAMPLE_FOLDER}/.eslintrc.js
50+
diff basics/hello-world/.gitignore ${EXAMPLE_FOLDER}/.gitignore
51+
env:
52+
EXAMPLE_FOLDER: ${{ matrix.example }}
53+
shell: bash
54+
- name: Install node
55+
uses: actions/setup-node@v1
56+
with:
57+
node-version: "12.x"
58+
- name: Install Python
59+
uses: actions/setup-python@v1
60+
with:
61+
python-version: "3.7"
62+
architecture: "x64"
63+
- name: Get pip cache dir
64+
id: pip-cache
65+
run: |
66+
echo "::set-output name=dir::$(pip cache dir)"
67+
shell: bash
68+
- name: Cache pip
69+
uses: actions/cache@v2
70+
with:
71+
path: ${{ steps.pip-cache.outputs.dir }}
72+
key: ${{ runner.os }}-pip-${{ hashFiles('**/environment.yml') }}
73+
restore-keys: |
74+
${{ runner.os }}-pip-
75+
- name: Install the Python dependencies
76+
run: python -m pip install jupyterlab
77+
- name: Install the NPM dependencies
78+
run: |
79+
cd ${EXAMPLE_FOLDER}
80+
jlpm
81+
env:
82+
EXAMPLE_FOLDER: ${{ matrix.example }}
83+
shell: bash
84+
- name: Lint the files
85+
run: |
86+
cd ${EXAMPLE_FOLDER}
87+
jlpm run eslint:check
88+
env:
89+
EXAMPLE_FOLDER: ${{ matrix.example }}
90+
shell: bash
91+
- name: Build and check by extension
92+
run: |
93+
cd ${EXAMPLE_FOLDER}
94+
jlpm run build
95+
jupyter labextension install .
96+
python -m jupyterlab.browser_check
97+
env:
98+
EXAMPLE_FOLDER: ${{ matrix.example }}
99+
shell: bash
80100

81101
build_serverextension:
82102
runs-on: ${{ matrix.os }}
@@ -85,70 +105,91 @@ jobs:
85105
matrix:
86106
os: [ubuntu-latest, macos-latest, windows-latest]
87107
steps:
88-
- name: Checkout
89-
uses: actions/checkout@v2
90-
- name: Install node
91-
uses: actions/setup-node@v1
92-
with:
93-
node-version: '12.x'
94-
- name: Check config files
95-
run: |
96-
diff basics/hello-world/tsconfig.json advanced/server-extension/tsconfig.json
97-
diff basics/hello-world/.eslintignore advanced/server-extension/.eslintignore
98-
diff basics/hello-world/.eslintrc.js advanced/server-extension/.eslintrc.js
99-
shell: bash
100-
- name: Install Python
101-
uses: actions/setup-python@v1
102-
with:
103-
python-version: '3.7'
104-
architecture: 'x64'
105-
- name: Install the Python dependencies
106-
run: |
107-
python -m pip install jupyter_packaging
108-
python -m pip install jupyterlab
109-
- name: Install the NPM dependencies
110-
run: |
111-
cd advanced/server-extension
112-
jlpm
113-
- name: Lint the files
114-
run: |
115-
cd advanced/server-extension
116-
jlpm run eslint:check
117-
- name: Build extension as user
118-
# Force the usage of the source distribution (good practice)
119-
run: |
120-
cd advanced/server-extension
121-
python setup.py sdist
122-
pip install jlab_ext_example --pre --find-links=dist --no-cache-dir
123-
jupyter lab build
124-
python -m jupyterlab.browser_check
125-
- name: Check extension as dev
126-
if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS')
127-
run: |
128-
jupyter serverextension list 1>serverextensions 2>&1
129-
cat serverextensions | grep "jlab_ext_example.*OK"
130-
jupyter labextension list 1>labextensions 2>&1
131-
cat labextensions | grep "@jupyterlab-examples/server-extension.*OK"
132-
- name: Clean extension installation
133-
run: |
134-
pip uninstall -y jlab_ext_example
135-
jupyter lab clean
136-
jupyter serverextension list
137-
jupyter labextension list
138-
- name: Build extension as dev
139-
run: |
140-
cd advanced/server-extension
141-
pip install -e .
142-
jupyter serverextension enable --py jlab_ext_example
143-
jupyter labextension install .
144-
- name: Check extension as dev
145-
if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS')
146-
run: |
147-
jupyter serverextension list 1>serverextensions 2>&1
148-
cat serverextensions | grep "jlab_ext_example.*OK"
149-
jupyter labextension list 1>labextensions 2>&1
150-
cat labextensions | grep "@jupyterlab-examples/server-extension.*OK"
151-
python -m jupyterlab.browser_check
108+
- name: Checkout
109+
uses: actions/checkout@v2
110+
- name: Cache lerna
111+
uses: actions/cache@v2
112+
with:
113+
path: |
114+
node_modules
115+
*/*/node_modules
116+
key: ${{ runner.os }}-lerna-${{ hashFiles('**/package.json') }}
117+
restore-keys: |
118+
${{ runner.os }}-lerna-
119+
- name: Install node
120+
uses: actions/setup-node@v1
121+
with:
122+
node-version: "12.x"
123+
- name: Check config files
124+
run: |
125+
diff basics/hello-world/tsconfig.json advanced/server-extension/tsconfig.json
126+
diff basics/hello-world/.eslintignore advanced/server-extension/.eslintignore
127+
diff basics/hello-world/.eslintrc.js advanced/server-extension/.eslintrc.js
128+
shell: bash
129+
- name: Install Python
130+
uses: actions/setup-python@v1
131+
with:
132+
python-version: "3.7"
133+
architecture: "x64"
134+
- name: Get pip cache dir
135+
id: pip-cache
136+
run: |
137+
echo "::set-output name=dir::$(pip cache dir)"
138+
shell: bash
139+
- name: Cache pip
140+
uses: actions/cache@v2
141+
with:
142+
path: ${{ steps.pip-cache.outputs.dir }}
143+
key: ${{ runner.os }}-pip-${{ hashFiles('**/environment.yml') }}
144+
restore-keys: |
145+
${{ runner.os }}-pip-
146+
- name: Install the Python dependencies
147+
run: |
148+
python -m pip install jupyter_packaging
149+
python -m pip install jupyterlab
150+
- name: Install the NPM dependencies
151+
run: |
152+
cd advanced/server-extension
153+
jlpm
154+
- name: Lint the files
155+
run: |
156+
cd advanced/server-extension
157+
jlpm run eslint:check
158+
- name: Build extension as user
159+
# Force the usage of the source distribution (good practice)
160+
run: |
161+
cd advanced/server-extension
162+
python setup.py sdist
163+
pip install jlab_ext_example --pre --find-links=dist --no-cache-dir
164+
jupyter lab build
165+
python -m jupyterlab.browser_check
166+
- name: Check extension as dev
167+
if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS')
168+
run: |
169+
jupyter serverextension list 1>serverextensions 2>&1
170+
cat serverextensions | grep "jlab_ext_example.*OK"
171+
jupyter labextension list 1>labextensions 2>&1
172+
cat labextensions | grep "@jupyterlab-examples/server-extension.*OK"
173+
- name: Clean extension installation
174+
run: |
175+
pip uninstall -y jlab_ext_example
176+
jupyter lab clean
177+
jupyter serverextension list
178+
jupyter labextension list
179+
- name: Build extension as dev
180+
run: |
181+
cd advanced/server-extension
182+
pip install -e .
183+
jupyter serverextension enable --py jlab_ext_example
184+
jupyter labextension install .
185+
- name: Check extension as dev
186+
if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS')
187+
run: |
188+
jupyter serverextension list 1>serverextensions 2>&1
189+
cat serverextensions | grep "jlab_ext_example.*OK"
190+
jupyter labextension list 1>labextensions 2>&1
191+
cat labextensions | grep "@jupyterlab-examples/server-extension.*OK"
192+
python -m jupyterlab.browser_check
152193
153194
build_all:
154195
runs-on: ${{ matrix.os }}
@@ -157,24 +198,45 @@ jobs:
157198
matrix:
158199
os: [ubuntu-latest, macos-latest, windows-latest]
159200
steps:
160-
- name: Checkout
161-
uses: actions/checkout@v2
162-
- name: Install node
163-
uses: actions/setup-node@v1
164-
with:
165-
node-version: '12.x'
166-
- name: Install Python
167-
uses: actions/setup-python@v1
168-
with:
169-
python-version: '3.7'
170-
architecture: 'x64'
171-
- name: Install the Python dependencies
172-
run: python -m pip install jupyterlab
173-
- name: Bootstrap the jlpm deps
174-
run: jlpm
175-
- name: Build all the extensions
176-
run: |
177-
jlpm build-ext
178-
jlpm lint:check
179-
jlpm install-ext
180-
jlpm build-jlab
201+
- name: Checkout
202+
uses: actions/checkout@v2
203+
- name: Cache lerna
204+
uses: actions/cache@v2
205+
with:
206+
path: |
207+
node_modules
208+
*/*/node_modules
209+
key: ${{ runner.os }}-lerna-${{ hashFiles('**/package.json') }}
210+
restore-keys: |
211+
${{ runner.os }}-lerna-
212+
- name: Install node
213+
uses: actions/setup-node@v1
214+
with:
215+
node-version: "12.x"
216+
- name: Install Python
217+
uses: actions/setup-python@v1
218+
with:
219+
python-version: "3.7"
220+
architecture: "x64"
221+
- name: Get pip cache dir
222+
id: pip-cache
223+
run: |
224+
echo "::set-output name=dir::$(pip cache dir)"
225+
shell: bash
226+
- name: Cache pip
227+
uses: actions/cache@v2
228+
with:
229+
path: ${{ steps.pip-cache.outputs.dir }}
230+
key: ${{ runner.os }}-pip-${{ hashFiles('**/environment.yml') }}
231+
restore-keys: |
232+
${{ runner.os }}-pip-
233+
- name: Install the Python dependencies
234+
run: python -m pip install jupyterlab
235+
- name: Bootstrap the jlpm deps
236+
run: jlpm
237+
- name: Build all the extensions
238+
run: |
239+
jlpm build-ext
240+
jlpm lint:check
241+
jlpm install-ext
242+
jlpm build-jlab

0 commit comments

Comments
 (0)