Skip to content
Draft
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
42 changes: 20 additions & 22 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,32 @@ on:

permissions:
id-token: write
# required by testinfra-ami-build dependent workflows
# required by dependent workflows
contents: write
packages: write

jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"

build-run-image:
name: ${{ matrix.name }} (${{ matrix.system }})
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- runner: blacksmith-32vcpu-ubuntu-2404
arch: amd64
- runner: blacksmith-32vcpu-ubuntu-2404-arm
arch: arm64
- runner: macos-latest-xlarge
arch: arm64
runs-on: ${{ matrix.runner }}
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
timeout-minutes: 180
steps:
- name: Checkout Repo
Expand Down Expand Up @@ -104,23 +113,12 @@ jobs:
sudo rm -rf /tmp/* 2>/dev/null || true
echo "=== AFTER CLEANUP ==="
df -h
- name: Build psql bundle
run: >
nix run "github:Mic92/nix-fast-build?rev=b1dae483ab7d4139a6297e02b6de9e5d30e43d48"
-- --skip-cached --no-nom ${{ matrix.runner == 'macos-latest-xlarge' && '--max-jobs 1' || '' }}
--flake ".#checks.$(nix eval --raw --impure --expr 'builtins.currentSystem')"
- run: nix build -L '.#${{ matrix.attr }}'
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ env.AWS_SESSION_TOKEN }}

run-testinfra:
needs: build-run-image
if: ${{ success() }}
uses: ./.github/workflows/testinfra-ami-build.yml
secrets:
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}

run-tests:
needs: build-run-image
if: ${{ success() }}
Expand Down
21 changes: 21 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs-go124.url = "github:Nixos/nixpkgs/d2ac4dfa61fba987a84a0a81555da57ae0b9a2b0";
nix-github-actions.url = "github:nix-community/nix-github-actions";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
};

outputs =
Expand All @@ -36,6 +38,7 @@
nix/nixpkgs.nix
nix/packages
nix/overlays
nix/github-actions.nix
];
});
}
90 changes: 90 additions & 0 deletions nix/ext/update_versions_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 git nix-prefetch-git python3Packages.packaging

import subprocess
import json
import argparse
from pathlib import Path
from typing import Dict, List, Union
from packaging.version import parse as parse_version, InvalidVersion

Schema = Dict[str, Dict[str, Dict[str, Union[List[str], str, bool]]]]

POSTGRES_VERSIONS: List[str] = ["15", "17"]
VERSIONS_JSON_PATH = "versions.json"


def run(cmd: List[str]) -> str:
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
return result.stdout.strip()


def get_tags(url: str) -> Dict[str, str]:
output = run(["git", "ls-remote", "--tags", url])
tags: Dict[str, str] = {}
for line in output.splitlines():
if "^{}" not in line:
parts = line.split("\t")
if len(parts) == 2:
commit_hash, ref = parts
if ref.startswith("refs/tags/"):
tag = ref.removeprefix("refs/tags/")
try:
parse_version(tag)
except InvalidVersion:
continue
tags[tag] = commit_hash
return tags


def get_sri_hash(url: str, commit_hash: str) -> str:
output = run(["nix-prefetch-git", "--quiet", "--url", url, "--rev", commit_hash])
nix_hash = json.loads(output)["sha256"]
return "sha256-" + run(["nix", "hash", "to-base64", "--type", "sha256", nix_hash])


def load() -> Schema:
if not Path(VERSIONS_JSON_PATH).exists():
return {}
with open(VERSIONS_JSON_PATH, "r", encoding="utf-8") as f:
return json.load(f)


def build(name: str, url: str, data: Schema, ignore: bool = False) -> Schema:
tags = get_tags(url)
versions = data.get(name, {})
for tag, commit_hash in tags.items():
if tag in versions:
continue
if ignore:
versions[tag] = {"ignore": True}
else:
sri_hash = get_sri_hash(url, commit_hash)
versions[tag] = {"postgresql": POSTGRES_VERSIONS, "hash": sri_hash}
data[name] = versions
return data


def save(data: Schema) -> None:
sorted_data = {}
for name, versions in data.items():
sorted_data[name] = dict(
sorted(versions.items(), key=lambda item: parse_version(item[0]))
)
with open(VERSIONS_JSON_PATH, "w", encoding="utf-8") as f:
json.dump(sorted_data, f, indent=2)
f.write("\n")


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("extension_name")
parser.add_argument("git_repo_url")
parser.add_argument("--ignore", action="store_true")
args = parser.parse_args()

save(build(args.extension_name, args.git_repo_url, load(), ignore=args.ignore))


if __name__ == "__main__":
main()
88 changes: 87 additions & 1 deletion nix/ext/versions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,92 @@
{
"wrappers": {
"0.5.4": {
"0.3.0": {
"postgresql": [
"15"
],
"hash": "sha256-ogpF8NJ7kW3Ut8jaKMDiKYIXnI38nfRq2mMK4rqFAIA=",
"pgrx": "0.11.3",
"rust": "1.76.0"
},
"0.4.1": {
"postgresql": [
"15"
],
"hash": "sha256-AU9Y43qEMcIBVBThu+Aor1HCtfFIg+CdkzK9IxVdkzM=",
"pgrx": "0.11.3",
"rust": "1.76.0"
},
"0.4.2": {
"postgresql": [
"15"
],
"hash": "sha256-ut3IQED6ANXgabiHoEUdfSrwkuuYYSpRoeWdtBvSe64=",
"pgrx": "0.11.3",
"rust": "1.76.0"
},
"0.4.3": {
"postgresql": [
"15"
],
"hash": "sha256-CkoNMoh40zbQL4V49ZNYgv3JjoNWjODtTpHn+L8DdZA=",
"pgrx": "0.12.6",
"rust": "1.80.0"
},
"0.4.4": {
"postgresql": [
"15",
"17"
],
"hash": "sha256-QoGFJpq8PuvMM8SS+VZd7MlNl56uFivRjs1tCtwX+oE=",
"pgrx": "0.12.6",
"rust": "1.80.0"
},
"0.4.5": {
"postgresql": [
"15",
"17"
],
"hash": "sha256-IgDfVFROMCHYLZ/Iqj12MsQjPPCdRoH+3oi3Ki/iaRI=",
"pgrx": "0.12.9",
"rust": "1.81.0"
},
"0.4.6": {
"postgresql": [
"15",
"17"
],
"hash": "sha256-hthb3qEXT1Kf4yPoq0udEbQzlyLtI5tug6sK4YAPFjU=",
"pgrx": "0.12.9",
"rust": "1.84.0"
},
"0.5.0": {
"postgresql": [
"15",
"17"
],
"hash": "sha256-FbRTUcpEHBa5DI6dutvBeahYM0RZVAXIzIAZWIaxvn0=",
"pgrx": "0.12.9",
"rust": "1.84.0"
},
"0.5.1": {
"postgresql": [
"15",
"17"
],
"hash": "sha256-3GfN3vZMFWf4FV/fSOe9ZN6KETmjoNw3Paz+JRzaH3c=",
"pgrx": "0.12.9",
"rust": "1.87.0"
},
"0.5.2": {
"postgresql": [
"15",
"17"
],
"hash": "sha256-9VqQHduoAWnY8gtfRZLDOKiibfwuSTzyVFbH0uhsfCU=",
"pgrx": "0.14.3",
"rust": "1.87.0"
},
"0.5.3": {
"postgresql": [
"15",
"17",
Expand Down
Loading
Loading