Skip to content
Open
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
12 changes: 10 additions & 2 deletions nix/cargo-pgrx/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
"0.6.1": {
"hash": "sha256-O4eHVbJBudybsPab+zr2eXnfheREMqLAHAKm2GDbfrs=",
"rust": {
"1.82.0": {
"1.70.0": {
"cargoHash": "sha256-MucGrA3qXgJOcT2LMNmoNOhQi8QA3LuqgZEHKycLCCo="
}
}
},
"0.7.1": {
"hash": "sha256-t/gdlrBeP6KFkBFJiZUa8KKVJVYMf6753vQGKJdytss=",
"rust": {
"1.82.0": {
"1.70.0": {
"cargoHash": "sha256-muce9wT4LAJmfNLWWEShARnpZgglXe/KrfxlitmGgXk="
}
}
},
"0.8.3": {
"hash": "sha256-1SdGPhyT/m65De3QTpEYAGvzbB6eLH1yUZ8XoN9LaVc=",
"rust": {
"1.70.0": {
"cargoHash": "sha256-uFSv2mwn0dmIo6AG5Wz3THOwdE9B2PQQF10kiG/3qLU="
}
}
},
"0.9.5": {
"hash": "sha256-GpXQUOBuojAqPXyRR+k8AVW2XzBbn6V0+2dhP4w4Vs8=",
"rust": {
Expand Down
90 changes: 90 additions & 0 deletions nix/ext/scripts/update_versions_json.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to move it to nix/ext/scripts instead so that nix/ext only contains the extensions

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a few lines of documentation on what is does and maybe an example of how we can use it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed, should I put that in nix/docs/adding-new-package.md or nix/docs/update-extension.md or both?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding-new-package.md needs a complete rewrite, I would add it in update-extension.md first and do another PR/TODO for improving overall documentation (removing the old way) on how to create/update multi version extensions

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()
145 changes: 141 additions & 4 deletions nix/ext/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,23 @@
],
"hash": "sha256-HnEyijEIkKbJFQjWF1sa5h2qqGzq/aW14454zPbo6wc=",
"pgrx": "0.6.1",
"rust": "1.82.0"
"rust": "1.70.0"
},
"1.1.0": {
"postgresql": [
"15"
],
"hash": "sha256-Vdi9qBjg14/SpZ1TuOvKS0gJjkLmviCzoBLnPOds0pw=",
"pgrx": "0.6.1",
"rust": "1.82.0"
"rust": "1.70.0"
},
"1.2.0": {
"postgresql": [
"15"
],
"hash": "sha256-QnNwKasSvC7o5pHDC/NlqJPvWirKwMpwUmfsLJXDTsg=",
"pgrx": "0.7.1",
"rust": "1.82.0"
"rust": "1.70.0"
},
"1.2.2": {
"postgresql": [
Expand Down Expand Up @@ -360,7 +360,6 @@
"hash": "sha256-QC77AnPGpPQGEWi6JtJdiNsB2su5+aV2pKg5ImR2B0k="
}
},

"pgsodium": {
"3.0.4": {
"postgresql": [
Expand Down Expand Up @@ -540,6 +539,126 @@
}
},
"wrappers": {
"0.1.5": {
"postgresql": [
"15"
],
"hash": "sha256-i6hINjzlyu7lVoAkgBEDhRn1CTrBVI0Zgz33uFyRtjE=",
"pgrx": "0.6.1",
"rust": "1.70.0"
},
"0.1.6": {
"postgresql": [
"15"
],
"hash": "sha256-cYl6pDXV9lFLLhftSw3cYFff2shN+pZpTxWDSq5+P8E=",
"pgrx": "0.6.1",
"rust": "1.70.0"
},
"0.1.7": {
"postgresql": [
"15"
],
"hash": "sha256-aGq46W12XTxGH1KKxk2re0ul+9h0n/OIrFLsylS+Y3U=",
"pgrx": "0.6.1",
"rust": "1.70.0"
},
"0.1.8": {
"postgresql": [
"15"
],
"hash": "sha256-9h5T10mD4W7hEDdbtxkyxiY/pACX1Io33UGetGOlCZA=",
"pgrx": "0.6.1",
"rust": "1.70.0"
},
"0.1.9": {
"postgresql": [
"15"
],
"hash": "sha256-VZxbvPXwOGMbyLHMXFwAMbtzdapDA73qN+2obUdLR5Q=",
"pgrx": "0.6.1",
"rust": "1.70.0"
},
"0.1.10": {
"postgresql": [
"15"
],
"hash": "sha256-472lVh91iqaMNHJk21LUvPIrhm3yIzrvDbNHyUW8aBs=",
"pgrx": "0.6.1",
"rust": "1.70.0"
},
"0.1.11": {
"postgresql": [
"15"
],
"hash": "sha256-3zN8uWeQwVQCQ37+PyLC4wX9oiji6s2L3aIpWYcD28g=",
"pgrx": "0.6.1",
"rust": "1.70.0"
},
"0.1.12": {
"postgresql": [
"15"
],
"hash": "sha256-TScNbX+PBWUYgrBEnFXOaeXXfiOIa488H1oyIAw6v7I=",
"pgrx": "0.8.3",
"rust": "1.70.0"
},
"0.1.14": {
"postgresql": [
"15"
],
"hash": "sha256-w6rijRFUlWmwv4XE0G99ip2GkBF4nGTaX94kQvNRmJs=",
"pgrx": "0.8.3",
"rust": "1.70.0"
},
"0.1.15": {
"postgresql": [
"15"
],
"hash": "sha256-R5MvaCx3BwX8NVDqJPJfCOppC2XtKIshh58Hkbw6VHg=",
"pgrx": "0.9.7",
"rust": "1.70.0"
},
"0.1.16": {
"postgresql": [
"15"
],
"hash": "sha256-pfbTGC/cBgv+YuwJ1qMQpb4jZm6n5uvCFLZLS/ZWcfs=",
"pgrx": "0.9.7",
"rust": "1.70.0"
},
"0.1.17": {
"postgresql": [
"15"
],
"hash": "sha256-Wm4O98ms0/J9z/m4s4eYyxiRwTZhSqd9KpxvY42xyNE=",
"pgrx": "0.10.2",
"rust": "1.76.0"
},
"0.1.18": {
"postgresql": [
"15"
],
"hash": "sha256-E4ql7D/lkb/J3Rr1kMEo37KxbFnqYPCdhuAIpVFLgB8=",
"pgrx": "0.10.2",
"rust": "1.76.0"
},
"0.1.19": {
"postgresql": [
"15"
],
"hash": "sha256-wvsAqDk+1am6mSBCF5uzDArnbBIpLqTylLzF4VZ/p08=",
"pgrx": "0.10.2",
"rust": "1.76.0"
},
"0.2.0": {
"postgresql": [
"15"
],
"hash": "sha256-F+S5uyubL3Tb3RTJ08Zf9gN8oLE/WkCWFA8RcKkDqes=",
"pgrx": "0.11.3",
"rust": "1.76.0"
},
"0.3.0": {
"postgresql": [
"15"
Expand Down Expand Up @@ -608,6 +727,24 @@
"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",
Expand Down
Loading
Loading