Skip to content

Commit

Permalink
ci: Add workflow to seed cachix (PostgREST#2615)
Browse files Browse the repository at this point in the history
  • Loading branch information
robx authored and laurenceisla committed Apr 11, 2023
1 parent 3f14312 commit e27d7c3
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 20 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/cachix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Cachix

# This workflow serves to
# - keep cachix up to date with the main branch
# - incrementally update cachix for large dependency
# updates, e.g. after running postgrest-nixpkgs-upgrade,
# which can cause the main CI workflow to time out

on:
workflow_dispatch:
push:
branches:
- main
- rel-*
tags:
- v*

jobs:
Seed-Cachix:
strategy:
matrix:
include:
- os: Linux
runs-on: ubuntu-latest
- os: MacOS
runs-on: macos-latest
name: Seed ${{ matrix.os }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Install cachix tooling
run: |
nix-env -f default.nix -iA devTools.pushCachix.bin
postgrest-push-cachix
- name: Seed dynamic postgrest build
run: |
nix-build -A postgrestPackage
postgrest-push-cachix
- name: Seed style tools
run: |
nix-build -A style
postgrest-push-cachix
- name: Seed test tools
run: |
nix-build -A tests
postgrest-push-cachix
- name: Seed static toolchain
if: matrix.os == 'Linux'
run: |
nix-build -A packagesStatic.haskellPackages.hello
postgrest-push-cachix
- name: Seed static postgresql build (for libpq)
if: matrix.os == 'Linux'
run: |
nix-build -A packagesStatic.pkgs.postgresql
postgrest-push-cachix
- name: Seed static postgrest build
if: matrix.os == 'Linux'
run: |
nix-build -A postgrestStatic
postgrest-push-cachix
- name: Build and push everything to Cachix
run: |
nix-build
postgrest-push-cachix
16 changes: 0 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ jobs:
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
tools: tests

- name: Build static executable
Expand All @@ -131,13 +130,6 @@ jobs:
path: postgrest-docker.tar.gz
if-no-files-found: error

- name: Build and push everything to Cachix (main branch only)
if: ${{ github.ref == 'refs/heads/main' }}
run: |
nix-build
nix-env -f default.nix -iA devTools
postgrest-push-cachix

Build-Macos-Nix:
name: Build MacOS (Nix)
Expand All @@ -146,18 +138,10 @@ jobs:
- uses: actions/checkout@v3
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Build everything
run: |
nix-build
nix-env -f default.nix -iA devTools
- name: Push to Cachix (main branch only)
if: ${{ github.ref == 'refs/heads/main' }}
run: |
postgrest-push-cachix
Build-Stack:
Expand Down
12 changes: 9 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ let
postgrest =
pkgs.haskell.packages."${compiler}".callCabal2nix name src { };

# Function that derives a fully static Haskell package based on
# Functionality that derives a fully static Haskell package based on
# nh2/static-haskell-nix
staticHaskellPackage =
import nix/static-haskell-package.nix { inherit nixpkgs system compiler patches allOverlays; };

# Static executable.
postgrestStatic =
lib.justStaticExecutables (lib.dontCheck (staticHaskellPackage name src).package);

packagesStatic = (staticHaskellPackage name src).survey;

# Options passed to cabal in dev tools and tests
devCabalOptions =
"-f dev --test-show-detail=direct";
Expand Down Expand Up @@ -152,8 +158,8 @@ rec {
pkgs.callPackage nix/tools/withTools.nix { inherit devCabalOptions postgresqlVersions postgrest; };
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux rec {
# Static executable.
postgrestStatic =
lib.justStaticExecutables (lib.dontCheck (staticHaskellPackage name src));
inherit postgrestStatic;
inherit packagesStatic;

# Docker images and loading script.
docker =
Expand Down
5 changes: 4 additions & 1 deletion nix/static-haskell-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ let
survey =
import "${patched-static-haskell-nix}/survey" { inherit normalPkgs compiler defaultCabalPackageVersionComingWithGhc; };
in
survey.haskellPackages."${name}"
{
inherit survey;
package = survey.haskellPackages."${name}";
}
1 change: 1 addition & 0 deletions nix/tools/devTools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -304,4 +304,5 @@ buildToolbox
hsieGraphModules
hsieGraphSymbols
];
extra = { inherit pushCachix; };
}

0 comments on commit e27d7c3

Please sign in to comment.