Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: merge cached Nix stores #3071

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/actions/setup-nix/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ runs:
- name: Restore and cache Nix store
uses: nix-community/[email protected]
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
develop7 marked this conversation as resolved.
Show resolved Hide resolved
- uses: cachix/cachix-action@v13
with:
name: postgrest
Expand Down
57 changes: 25 additions & 32 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,32 @@ on:
- rel-*

jobs:
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`)
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -95,27 +113,29 @@ 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


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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/loadtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand Down
Loading