Skip to content

Commit 9cb1864

Browse files
jfrocheyvan-sraka
authored andcommitted
feat(nix-build): enable sccache only for extension packages
Only mount stickydisk, enable sccache sandbox path, and set max-jobs=1 for packages with postgresql_version (extension packages). Non-extension packages build without sccache and with default max-jobs.
1 parent 4a54c67 commit 9cb1864

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

.github/workflows/nix-build.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
if: ${{ matrix.attr != '' }}
3838
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
3939
- name: Mount sccache disk
40-
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
40+
if: ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
4141
uses: useblacksmith/stickydisk@v1
4242
with:
4343
key: ${{ github.repository }}-sccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.cache_key }}
@@ -47,15 +47,16 @@ jobs:
4747
uses: ./.github/actions/nix-install-ephemeral
4848
with:
4949
push-to-cache: 'true'
50-
enable-sccache-sandbox-path: 'true'
50+
enable-sccache-sandbox-path: ${{ matrix.postgresql_version && 'true' || 'false' }}
51+
max-jobs: ${{ matrix.postgresql_version && '1' || '' }}
5152
env:
5253
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
5354
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
5455
- name: Install nix (self-hosted)
5556
if: ${{ matrix.attr != '' && matrix.runs_on.group == 'self-hosted-runners-nix' }}
5657
uses: ./.github/actions/nix-install-self-hosted
5758
- name: Allow sccache cache write access
58-
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
59+
if: ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
5960
run: |
6061
# With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
6162
sudo chown -R 872415232 /nix/var/cache/sccache
@@ -81,7 +82,7 @@ jobs:
8182
if: ${{ matrix.attr != '' }}
8283
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
8384
- name: Mount sccache disk
84-
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
85+
if: ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
8586
uses: useblacksmith/stickydisk@v1
8687
with:
8788
key: ${{ github.repository }}-sccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.cache_key }}
@@ -91,15 +92,16 @@ jobs:
9192
uses: ./.github/actions/nix-install-ephemeral
9293
with:
9394
push-to-cache: 'true'
94-
enable-sccache-sandbox-path: 'true'
95+
enable-sccache-sandbox-path: ${{ matrix.postgresql_version && 'true' || 'false' }}
96+
max-jobs: ${{ matrix.postgresql_version && '1' || '' }}
9597
env:
9698
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
9799
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
98100
- name: Install nix (self-hosted)
99101
if: ${{ matrix.attr != '' && matrix.runs_on.group == 'self-hosted-runners-nix' }}
100102
uses: ./.github/actions/nix-install-self-hosted
101103
- name: Allow sccache cache write access
102-
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
104+
if: ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
103105
run: |
104106
# With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
105107
sudo chown -R 872415232 /nix/var/cache/sccache
@@ -171,7 +173,7 @@ jobs:
171173
if: ${{ matrix.attr != '' }}
172174
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
173175
- name: Mount sccache disk
174-
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
176+
if: ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
175177
uses: useblacksmith/stickydisk@v1
176178
with:
177179
key: ${{ github.repository }}-sccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.cache_key }}
@@ -180,13 +182,14 @@ jobs:
180182
if: ${{ matrix.attr != '' }}
181183
uses: ./.github/actions/nix-install-ephemeral
182184
with:
183-
enable-sccache-sandbox-path: 'true'
185+
enable-sccache-sandbox-path: ${{ matrix.postgresql_version && 'true' || 'false' }}
186+
max-jobs: ${{ matrix.postgresql_version && '1' || '' }}
184187
push-to-cache: 'true'
185188
env:
186189
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
187190
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
188191
- name: Allow sccache cache write access
189-
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
192+
if: ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
190193
run: |
191194
# With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
192195
sudo chown -R 872415232 /nix/var/cache/sccache
@@ -212,7 +215,7 @@ jobs:
212215
if: ${{ matrix.attr != '' }}
213216
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
214217
- name: Mount sccache disk
215-
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
218+
if: ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
216219
uses: useblacksmith/stickydisk@v1
217220
with:
218221
key: ${{ github.repository }}-sccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.cache_key }}
@@ -221,13 +224,14 @@ jobs:
221224
if: ${{ matrix.attr != '' }}
222225
uses: ./.github/actions/nix-install-ephemeral
223226
with:
224-
enable-sccache-sandbox-path: 'true'
227+
enable-sccache-sandbox-path: ${{ matrix.postgresql_version && 'true' || 'false' }}
228+
max-jobs: ${{ matrix.postgresql_version && '1' || '' }}
225229
push-to-cache: 'true'
226230
env:
227231
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
228232
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
229233
- name: Allow sccache cache write access
230-
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
234+
if: ${{ matrix.attr != '' && matrix.postgresql_version && matrix.runs_on.group != 'self-hosted-runners-nix' }}
231235
run: |
232236
# With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
233237
sudo chown -R 872415232 /nix/var/cache/sccache

0 commit comments

Comments
 (0)