8000 Sam/pgrx 0 11 3 support (#943) · GQAdonis/postgres@67a5c31 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67a5c31

Browse files
authored
Sam/pgrx 0 11 3 support (supabase#943)
* fix: bring cargo pgrx 0.11.2 support into the build for pg_graphql * fix: add some vars for clang paths * fix: inputs on package * fix: refacto * feat: pgrx 0.11.3 * fix: use pgrx 0.11.3 on pg_graphql * feat: working x86_64-linux with new versions * feat: update nix gh actions to use our runners to do builds * fix: gh action syntax * fix: permissions on this workflow so thay nix will install * fix: update versions of actions being used potentially related to DeterminateSystems/nix-installer-action#57 (comment) * fix: adjust permissions in action * fix: try without magic cache for now to see if build will proceed * fix: uninstall nix before proceeding * fix: refactor nix build action * chore: debugging workflow * chore: get command in right place * feat: user local Dockerfile for nix builds on runners * feat: refine command * feat: build image, run container * fix: large runner for x86 * fix: get the right tag for runner * tests: doing a test run of both build, and docker image copy to registry * tests: working out some changes to push to docker registry * chore: deprecate push to registry for now, after confirming it works * feat: inject aws into container, and signing key for binary cache upload cache if build succeeds, on every run * feat: refactor a bit to fix the workflow * fix: copy to binary cache * fix: refer to correct vars * fix: target correct branch on merge * feat: try to use cache for paths that have been built already * fix: fzakaria cache not needed * feat: include test (nix flake check -L)
1 parent c27fc66 commit 67a5c31

17 files changed

+122
-140
lines changed

.github/workflows/nix-build.yml

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,44 @@ name: Nix CI
33
on:
44
push:
55
branches:
6-
- main
6+
- develop
77
pull_request:
88

9-
permissions: read-all
10-
9+
permissions:
10+
contents: read
11+
id-token: write
12+
1113
jobs:
12-
build:
14+
build-run-image:
1315
strategy:
1416
fail-fast: false
1517
matrix:
16-
os: [ ubuntu-latest ]
17-
cmd: [ "nix flake check -L --show-trace", "nix build .#psql_15/bin .#psql_15/docker"]
18-
runs-on: ${{ matrix.os }}
19-
name: nix-build
18+
include:
19+
- runner: larger-runner-4cpu
20+
arch: amd64
21+
- runner: arm-runner
22+
arch: arm64
23+
runs-on: ${{ matrix.runner }}
24+
2025
steps:
21-
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
26+
27+
- name: Check out code
28+
uses: actions/checkout@v3
29+
- name: aws-creds
30+
uses: aws-actions/configure-aws-credentials@v4
2231
with:
23-
fetch-depth: 0
24-
- uses: DeterminateSystems/nix-installer-action@65d7c888b2778e8cf30a07a88422ccb23499bfb8
25-
- uses: DeterminateSystems/magic-nix-cache-action@749fc5bbc9fa49d60c2b93f6c4bc867b82e1d295
26-
- run: ${{ matrix.cmd }}
32+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
33+
aws-region: "us-east-1"
34+
output-credentials: true
35+
- name: write secret key
36+
# use python so we don't interpolate the secret into the workflow logs, in case of bugs
37+
run: |
38+
python -c "import os; file = open('nix-secret-key', 'w'); file.write(os.environ['NIX_SIGN_SECRET_KEY']); file.close()"
39+
env:
40+
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
41+
42+
- name: Build docker images
43+
run: docker build -t base_nix -f docker/nix/Dockerfile .
44+
- name: Run build psql bundle
45+
run: docker run -e AWS_ACCESS_KEY_ID=${{ env.AWS_ACCESS_KEY_ID }} -e AWS_SECRET_ACCESS_KEY=${{ env.AWS_SECRET_ACCESS_KEY }} -e AWS_SESSION_TOKEN=${{ env.AWS_SESSION_TOKEN }} base_nix bash -c "./workspace/docker/nix/build.sh"
46+
name: build psql bundle on ${{ matrix.arch }}

.github/workflows/nix-cache-upload.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ jobs:
1414
build:
1515
strategy:
1616
fail-fast: false
17-
runs-on: ubuntu-latest
17+
matrix:
18+
include:
19+
- runner: [self-hosted, X64]
20+
arch: amd64
21+
- runner: arm-runner
22+
arch: arm64
23+
runs-on: ${{ matrix.runner }}
1824
name: nix-build
1925
steps:
2026
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

.github/workflows/nix-docker-image.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ __pycache__/
1313

1414
#nix related
1515
result*
16+
.env-local
17+
.history

docker/nix/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM nixpkgs/nix-flakes
2+
3+
RUN echo "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" >> /etc/nix/nix.conf
4+
5+
RUN echo "trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=%" >> /etc/nix/nix.conf
6+
7+
8+
USER $USER
9+
10+
RUN mkdir -p /workspace
11+
12+
COPY ./ /workspace
13+
14+
RUN chmod +x /workspace/docker/nix/build.sh
15+
16+
RUN chown -R $USER:$USER /workspace
17+
18+

docker/nix/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/env bash
2+
set -eou pipefail
3+
4+
nix --version
5+
cd /workspace
6+
nix build .#psql_15/bin -o psql_15
7+
nix build .#psql_15/docker
8+
nix flake check -L --all-systems
9+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_15
10+
11+
#a future step nix run .#psql_15/docker.copyToRegistry

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@
6060
# pull them from the overlays/ directory automatically, but we don't
6161
# want to have an arbitrary order, since it might matter. being
6262
# explicit is better.
63-
(import ./nix/overlays/cargo-pgrx.nix)
64-
(import ./nix/overlays/cargo-pgrx-0-10-2.nix)
65-
(import ./nix/overlays/gdal-small.nix)
63+
(import ./nix/overlays/cargo-pgrx-0-11-3.nix)
64+
#(import ./nix/overlays/gdal-small.nix)
6665

6766
];
6867
};
@@ -89,6 +88,7 @@
8988
# may also bring in new versions of the extensions.
9089
psqlExtensions = [
9190
/* pljava */
91+
"postgis"
9292
];
9393

9494
#FIXME for now, timescaledb is not included in the orioledb version of supabase extensions, as there is an issue
@@ -118,7 +118,7 @@
118118
./nix/ext/plpgsql-check.nix
119119
./nix/ext/pgjwt.nix
120120
./nix/ext/pgaudit.nix
121-
./nix/ext/postgis.nix
121+
#./nix/ext/postgis.nix
122122
./nix/ext/pgrouting.nix
123123
./nix/ext/pgtap.nix
124124
./nix/ext/pg_cron.nix
@@ -313,7 +313,7 @@
313313
'';
314314
in
315315
nix2img.buildImage {
316-
name = "postgresql-${version}";
316+
name = "nix-experimental-postgresql-${version}-${system}";
317317
tag = "latest";
318318

319319
nixUid = l.toInt uid;
@@ -469,8 +469,8 @@
469469
--subst-var-by 'YQ' '${pkgs.yq}/bin/yq' \
470470
--subst-var-by 'JQ' '${pkgs.jq}/bin/jq' \
471471
--subst-var-by 'NIX_EDITOR' '${nix-editor.packages.${system}.nix-editor}/bin/nix-editor' \
472-
--subst-var-by 'NIXPREFETCHURL' '${pkgs.nixVersions.nix_2_14}/bin/nix-prefetch-url' \
473-
--subst-var-by 'NIX' '${pkgs.nixVersions.nix_2_14}/bin/nix'
472+
--subst-var-by 'NIXPREFETCHURL' '${pkgs.nixVersions.nix_2_20}/bin/nix-prefetch-url' \
473+
--subst-var-by 'NIX' '${pkgs.nixVersions.nix_2_20}/bin/nix'
474474
chmod +x $out/bin/sync-exts-versions
475475
'';
476476
};
@@ -513,8 +513,8 @@
513513
# Any extra packages we might want to include in our package
514514
# set can go here.
515515
inherit (pkgs)
516-
# NOTE: comes from our cargo-pgrx.nix overlay
517-
cargo-pgrx_0_11_0 cargo-pgrx_0_10_2;
516+
# NOTE: comes from our cargo-pgrx-0-11-3.nix overlay
517+
cargo-pgrx_0_11_3;
518518

519519
};
520520

nix/ext/pg_graphql.nix

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
{ lib, stdenv, fetchFromGitHub, postgresql, buildPgrxExtension }:
1+
{ lib, stdenv, fetchFromGitHub, postgresql, buildPgrxExtension_0_11_3, cargo }:
22

3-
buildPgrxExtension rec {
3+
buildPgrxExtension_0_11_3 rec {
44
pname = "pg_graphql";
5-
version = "1.5.1";
5+
version = "1.5.2";
66
inherit postgresql;
77

88
src = fetchFromGitHub {
99
owner = "supabase";
1010
repo = pname;
1111
rev = "v${version}";
12-
hash = "sha256-cAiD2iSFmZwC+Zy0x+MABseWCxXRtRY74Dj0oBKet+o=";
12+
hash = "sha256-npza6cGKyUyufabaUcGzV3knNa7vhR+xbZeaZy5CJ8c= ";
1313
};
1414

15-
cargoHash = "sha256-BOw4SafWD8z2Oj8KPVv7GQEOQ1TCShhcG7XmQiM9W68=";
15+
nativeBuildInputs = [ cargo ];
16+
17+
CARGO="${cargo}/bin/cargo";
18+
19+
cargoHash = "sha256-9XyUJsYptP0KanMJDAzQ4rFSN1vqZnyUdFBPQf6ryS4=";
1620

1721
# FIXME (aseipp): disable the tests since they try to install .control
1822
# files into the wrong spot, aside from that the one main test seems

nix/ext/pg_jsonschema.nix

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
{ lib, stdenv, fetchFromGitHub, postgresql, buildPgrxExtension_0_10_2 }:
1+
{ lib, stdenv, fetchFromGitHub, postgresql, buildPgrxExtension_0_11_3, cargo }:
22

3-
buildPgrxExtension_0_10_2 rec {
3+
buildPgrxExtension_0_11_3 rec {
44
pname = "pg_jsonschema";
5-
version = "0.2.0";
5+
version = "0.3.1";
66
inherit postgresql;
77

88
src = fetchFromGitHub {
99
owner = "supabase";
1010
repo = pname;
1111
rev = "v${version}";
12-
hash = "sha256-57gZbUVi8P4EB8T0P19JBVXcetQcr6IxuIx96NNFA/0=";
12+
hash = "sha256-YdKpOEiDIz60xE7C+EzpYjBcH0HabnDbtZl23CYls6g=";
1313
};
1414

15-
cargoHash = "sha256-XMKZUdubCwPDnrv6yao7GaavoRK6cVyy1WqFBQ6wh3s=";
15+
nativeBuildInputs = [ cargo ];
16+
17+
CARGO="${cargo}/bin/cargo";
18+
19+
20+
cargoHash = "sha256-VcS+efMDppofuFW2zNrhhsbC28By3lYekDFquHPta2g=";
1621

1722
# FIXME (aseipp): testsuite tries to write files into /nix/store; we'll have
1823
# to fix this a bit later.

0 commit comments

Comments
 (0)
0