add build cache action
Some checks failed
Nix CI / Merge similar caches ([ubuntu-latest]) (pull_request) Has been cancelled
Nix CI / Check a `common` cache is restored correctly ([ubuntu-latest]) (pull_request) Has been cancelled
Check flake.lock / Check health of `flake.lock` (pull_request) Successful in 18s
Check Nix flake / Build nix outputs (ubuntu-latest) (pull_request) Has been cancelled
Check Nix flake / Perform Nix flake checks (ubuntu-latest) (pull_request) Has been cancelled
Check Nix formatting / Perform Nix format checks (pull_request) Has been cancelled
Some checks failed
Nix CI / Merge similar caches ([ubuntu-latest]) (pull_request) Has been cancelled
Nix CI / Check a `common` cache is restored correctly ([ubuntu-latest]) (pull_request) Has been cancelled
Check flake.lock / Check health of `flake.lock` (pull_request) Successful in 18s
Check Nix flake / Build nix outputs (ubuntu-latest) (pull_request) Has been cancelled
Check Nix flake / Perform Nix flake checks (ubuntu-latest) (pull_request) Has been cancelled
Check Nix formatting / Perform Nix format checks (pull_request) Has been cancelled
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
89
.github/workflows/cache-merge.yml
vendored
Normal file
89
.github/workflows/cache-merge.yml
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
name: Nix CI
|
||||
on:
|
||||
push:
|
||||
# don't run on tags, run on commits
|
||||
# https://github.com/orgs/community/discussions/25615
|
||||
tags-ignore:
|
||||
- "**"
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
merge_group:
|
||||
schedule:
|
||||
- cron: 0 0 * * *
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
# Merge similar `individual` caches
|
||||
# Purge `individual` caches and old `common` caches
|
||||
# Save new `common` caches
|
||||
merge-similar-caches:
|
||||
name: Merge similar caches
|
||||
needs: make-similar-caches
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout this repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install nix
|
||||
uses: https://github.com/DeterminateSystems/nix-installer-action@main
|
||||
|
||||
- uses: nix-community/cache-nix-action@v6
|
||||
name: create and purge common cache
|
||||
with:
|
||||
primary-key: similar-cache-${{ matrix.os }}-common-${{ hashFiles('flake.lock') }}
|
||||
# if no hit on the primary key, restore individual caches that match `ci.yaml`
|
||||
restore-prefixes-all-matches: |
|
||||
similar-cache-${{ matrix.os }}-individual-${{ hashFiles('flake.lock', '*.nix') }}
|
||||
# do purge caches
|
||||
purge: true
|
||||
# purge old versions of the `common` cache and any versions of individual caches
|
||||
purge-prefixes: |
|
||||
similar-cache-${{ matrix.os }}-common-
|
||||
# created more than 0 seconds ago relative to the start of the `Post Restore` phase
|
||||
purge-created: 0
|
||||
# except the version with the `primary-key`, if it exists
|
||||
purge-primary-key: never
|
||||
|
||||
- uses: nix-community/cache-nix-action@v6
|
||||
name: purge some individual caches
|
||||
with:
|
||||
primary-key: similar-cache-${{ matrix.os }}-common-${{ hashFiles('flake.lock') }}
|
||||
# if no hit on the primary key, restore individual caches that match `ci.yaml`
|
||||
restore-prefixes-all-matches: |
|
||||
similar-cache-${{ matrix.os }}-individual-${{ hashFiles('flake.lock', '*.nix') }}
|
||||
# do purge caches
|
||||
purge: true
|
||||
# purge old versions of the `common` cache and any versions of individual caches
|
||||
purge-prefixes: |
|
||||
similar-cache-${{ matrix.os }}-individual-
|
||||
# created more than 0 seconds ago relative to the start of the `Post Restore` phase
|
||||
purge-created: 259200
|
||||
# except the version with the `primary-key`, if it exists
|
||||
purge-primary-key: never
|
||||
|
||||
# Check that the `common` cache is restored correctly
|
||||
merge-similar-caches-check:
|
||||
name: Check a `common` cache is restored correctly
|
||||
needs: merge-similar-caches
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout this repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install nix
|
||||
uses: https://github.com/DeterminateSystems/nix-installer-action@main
|
||||
|
||||
- name: Restore Nix store
|
||||
- uses: nix-community/cache-nix-action@v6
|
||||
with:
|
||||
primary-key: similar-cache-${{ matrix.os }}-common-${{ hashFiles('flake.lock') }}
|
||||
Reference in New Issue
Block a user