ci: similar jobs use a single cache for Nix stores

Jobs that use the setup-nix action will share a single cache, which is created by a previous warm up Job.
This commit is contained in:
Andrei Dziahel
2023-12-12 18:46:40 -05:00
committed by Laurence Isla
parent 1cebc03313
commit c92f16a2cb
3 changed files with 30 additions and 38 deletions
+1 -2
View File
@@ -20,10 +20,9 @@ runs:
- name: Restore and cache Nix store
uses: nix-community/cache-nix-action@v4.0.3
with:
key: cache-nix-${{ runner.os }}-id-${{ inputs.cache-id }}-${{ hashFiles('nix/**/*.nix') }}
key: cache-nix-${{ runner.os }}-id-${{ inputs.cache-id }}-${{ hashFiles('nix/**/*.nix', '.github/actions/setup-nix/*') }}
restore-keys: |
cache-nix-${{ runner.os }}-common-
restore-key-hit: true
- uses: cachix/cachix-action@v13
with:
name: postgrest
+27 -34
View File
@@ -13,16 +13,32 @@ on:
- rel-*
jobs:
Lint-Style:
name: Lint & check code style
Prepopulate-Nix-Cache-Linux:
name: Prepopulate Nix cache for Linux runners
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
cache-id: common
- name: Put all tools to store to be cached afterwards
run: |
# shellcheck disable=SC2046
nix-store -v --realize $( nix-instantiate default.nix )
shell: bash
Lint-Style:
name: Lint & check code style
runs-on: ubuntu-latest
needs: [Prepopulate-Nix-Cache-Linux]
steps:
- uses: actions/checkout@v4
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
tools: style
cache-id: style
cache-id: common
- name: Run linter (check locally with `nix-shell --run postgrest-lint`)
run: postgrest-lint
- name: Run style check (auto-format with `nix-shell --run postgrest-style`)
@@ -32,6 +48,7 @@ jobs:
Test-Nix:
name: Test (Nix)
runs-on: ubuntu-latest
needs: [Prepopulate-Nix-Cache-Linux]
defaults:
run:
# Hack for enabling color output, see:
@@ -43,7 +60,7 @@ jobs:
uses: ./.github/actions/setup-nix
with:
tools: tests
cache-id: test-pg
cache-id: common
- name: Run coverage (IO tests and Spec tests against PostgreSQL 15)
run: postgrest-coverage
@@ -68,6 +85,7 @@ jobs:
pgVersion: [9.6, 10, 11, 12, 13, 14, 15, 16]
name: Test PG ${{ matrix.pgVersion }} (Nix)
runs-on: ubuntu-latest
needs: [Prepopulate-Nix-Cache-Linux]
defaults:
run:
# Hack for enabling color output, see:
@@ -81,7 +99,7 @@ jobs:
tools: tests withTools
# It seems like they are installing the same set of derivations, so we can assign them the same cache id.
# This would decrease the amount of caches dowloaded on merge cache step and will prevent disk space issues.
cache-id: test-pg
cache-id: common
- name: Run spec tests
if: always()
@@ -95,13 +113,14 @@ jobs:
Test-Memory-Nix:
name: Test memory (Nix)
runs-on: ubuntu-latest
needs: [Prepopulate-Nix-Cache-Linux]
steps:
- uses: actions/checkout@v4
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
tools: memory
cache-id: test-memory
cache-id: common
- name: Run memory tests
run: postgrest-test-memory
@@ -109,13 +128,14 @@ jobs:
Build-Static-Nix:
name: Build Linux static (Nix)
runs-on: ubuntu-latest
needs: [Prepopulate-Nix-Cache-Linux]
steps:
- uses: actions/checkout@v4
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
tools: tests
cache-id: static-nix
cache-id: common
- name: Build static executable
run: nix-build -A postgrestStatic
@@ -137,33 +157,6 @@ jobs:
path: postgrest-docker.tar.gz
if-no-files-found: error
# TODO: Enable this again in a PR by PostgREST admins, because regular users don't have permission to delete cache entries, which this job does.
#
# merge-nix-caches-linux:
# name: "Merge Nix caches (Linux)"
# needs: [Test-Nix, Test-Pg-Nix, Test-Memory-Nix, Build-Static-Nix, Lint-Style]
# runs-on: ubuntu-latest
# strategy:
# max-parallel: 1
# matrix:
# cache-id: ['static-nix', 'test-pg', 'style', 'test-memory']
# steps:
# - uses: actions/checkout@v4
# - uses: nixbuild/nix-quick-install-action@v26
# with:
# nix_version: '2.13.6'
# - name: Restore and cache Nix store
# uses: nix-community/cache-nix-action@v4
# with:
# key: cache-nix-${{ runner.os }}-common-${{ hashFiles('nix/**/*.nix') }}
# extra-restore-keys: |
# cache-nix-${{ runner.os }}-cid-
# purge: true
# purge-keys: |
# cache-nix-${{ runner.os }}-cid-
# cache-nix-${{ runner.os }}-common-
# purge-created-max-age: 0
Build-Macos-Nix:
name: Build MacOS (Nix)
runs-on: macos-latest
+2 -2
View File
@@ -23,7 +23,7 @@ jobs:
uses: ./.github/actions/setup-nix
with:
tools: loadtest
cache-id: test-pg
cache-id: test-loadtest
- uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
with:
@@ -55,7 +55,7 @@ jobs:
uses: ./.github/actions/setup-nix
with:
tools: loadtest
cache-id: test-pg
cache-id: test-loadtest
- name: Run loadtest
run: |
postgrest-loadtest-against ${{ steps.get-latest-tag.outputs.tag }}