Skip to content

Commit fc8bfc7

Browse files
committed
Cache deps
1 parent 50db72e commit fc8bfc7

File tree

1 file changed

+55
-13
lines changed

1 file changed

+55
-13
lines changed

.github/workflows/build-native-action.yml

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,36 @@ on:
1010

1111
jobs:
1212

13-
build_linux:
13+
download-dependencies:
14+
runs-on:
15+
- ubuntu-24.04
16+
strategy:
17+
fail-fast: true
18+
env:
19+
RELENV_DATA: ${{ github.workspace }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Set up Python 3.11
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.11'
26+
- name: Install Dependencies
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y python3-virtualenv
30+
virtualenv venv
31+
venv/bin/python3 -m pip install nox ppbt
32+
- name: Download Dependencies
33+
run: |
34+
venv/bin/python3 -m relenv build --download-only
35+
- name: Cache Dependencies
36+
uses: actions/cache@v4
37+
with:
38+
path: ${{ github.workspace }}/download
39+
key: ${{ github.run_id }}-dependencies
1440

41+
42+
build_linux:
1543
strategy:
1644
fail-fast: false
1745
matrix:
@@ -28,14 +56,13 @@ jobs:
2856
target: x86_64
2957
- host: aarch64
3058
target: aarch64
31-
59+
needs:
60+
- download-dependencies
3261
name: "Python ${{ matrix.version }} Linux ${{ matrix.target }} on ${{ matrix.host }}"
3362
runs-on:
3463
- ${{ (contains(matrix.host, 'x86_64') && 'ubuntu-24.04') || 'ubuntu-24.04-arm' }}
35-
3664
env:
3765
RELENV_DATA: ${{ github.workspace }}
38-
3966
steps:
4067
- name: "Throttle Builds"
4168
shell: bash
@@ -61,6 +88,12 @@ jobs:
6188
venv/bin/python3 --version
6289
venv/bin/python3 -c 'import os; print(os.name)'
6390
91+
- name: Restore Cached Dependencies
92+
uses: actions/cache/restore@v4
93+
with:
94+
path: ${{ github.workspace }}/download
95+
key: ${{ github.run_id }}-dependencies
96+
6497
- name: Build
6598
run: |
6699
venv/bin/python3 -m relenv build --no-pretty --arch=${{ matrix.target }} --python=${{ matrix.version }}
@@ -83,9 +116,7 @@ jobs:
83116

84117
build_macos_12_x86_64:
85118
name: "Python macOS"
86-
87119
runs-on: macos-13
88-
89120
strategy:
90121
fail-fast: false
91122
matrix:
@@ -96,10 +127,10 @@ jobs:
96127
- 3.13.5
97128
arch:
98129
- x86_64
99-
100130
env:
101131
RELENV_DATA: ${{ github.workspace }}
102-
132+
needs:
133+
- download-dependencies
103134
steps:
104135
- name: "Throttle Builds"
105136
shell: bash
@@ -126,6 +157,13 @@ jobs:
126157
run: |
127158
pip3 install nox
128159
160+
- name: Restore Cached Dependencies
161+
uses: actions/cache/restore@v4
162+
with:
163+
path: ${{ github.workspace }}/download
164+
key: ${{ github.run_id }}-dependencies
165+
166+
129167
- name: Build
130168
run: |
131169
python3 -m relenv build --no-pretty --python=${{ matrix.version }}
@@ -160,10 +198,10 @@ jobs:
160198
- 3.13.5
161199
arch:
162200
- arm64
163-
164201
env:
165202
RELENV_DATA: ${{ github.workspace }}
166-
203+
needs:
204+
- download-dependencies
167205
steps:
168206
- uses: actions/checkout@v3
169207

@@ -185,6 +223,13 @@ jobs:
185223
run: |
186224
brew install nox
187225
226+
- name: Restore Cached Dependencies
227+
uses: actions/cache/restore@v4
228+
with:
229+
path: ${{ github.workspace }}/download
230+
key: ${{ github.run_id }}-dependencies
231+
232+
188233
- name: Build
189234
run: |
190235
python3 -m relenv build --no-pretty --python=${{ matrix.version }}
@@ -207,7 +252,6 @@ jobs:
207252
build_windows:
208253
name: "Python Windows"
209254
runs-on: windows-latest
210-
211255
strategy:
212256
fail-fast: false
213257
matrix:
@@ -219,10 +263,8 @@ jobs:
219263
arch:
220264
- amd64
221265
- x86
222-
223266
env:
224267
RELENV_DATA: ${{ github.workspace }}
225-
226268
steps:
227269
- name: "Throttle Builds"
228270
shell: bash

0 commit comments

Comments
 (0)