8000 Sam/sync versions by samrose · Pull Request #925 · supabase/postgres · GitHub
[go: up one dir, main page]

Skip to content

Sam/sync versions #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: WIP tooling that will update versions, source and cargovendor sha
  • Loading branch information
samrose committed Mar 29, 2024
commit 4939b1f9df17d1eac807474a6344e0a541ecdb6e
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@
substitute ${./nix/tools/sync-exts-versions.sh.in} $out/bin/sync-exts-versions \
--subst-var-by 'YQ' '${pkgs.yq}/bin/yq' \
--subst-var-by 'JQ' '${pkgs.jq}/bin/jq' \
--subst-var-by 'NIX_EDITOR' '${nix-editor}/bin/nix-editor' \
--subst-var-by 'NIX_EDITOR' '${nix-editor.packages.${system}.nix-editor}/bin/nix-editor' \
--subst-var-by 'NIXPREFETCHURL' '${pkgs.nixVersions.nix_2_14}/bin/nix-prefetch-url' \
--subst-var-by 'NIX' '${pkgs.nixVersions.nix_2_14}/bin/nix'
chmod +x $out/bin/sync-exts-versions
Expand Down
8 changes: 4 additions & 4 deletions nix/ext/pg_graphql.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

buildPgrxExtension rec {
pname = "pg_graphql";
version = "unstable-1.5.0";
version = "1.5.1";
inherit postgresql;

src = fetchFromGitHub {
10000 owner = "supabase";
repo = pname;
rev = "v1.5.0";
hash = "sha256-28ANRZyF22qF2YAxNAAkPfGOM3+xiO6IHdXsTp0CTQE=";
rev = "v${version}";
hash = "sha256-cAiD2iSFmZwC+Zy0x+MABseWCxXRtRY74Dj0oBKet+o=";
};

cargoHash = "sha256-CUiGs0m9aUeqjpdPyOSjz91cP7TT6kjJqnw7ImGnQuo=";
cargoHash = "sha256-BOw4SafWD8z2Oj8KPVv7GQEOQ1TCShhcG7XmQiM9W68=";

# FIXME (aseipp): disable the tests since they try to install .control
# files into the wrong spot, aside from that the one main test seems
Expand Down
69 changes: 61 additions & 8 deletions nix/tools/sync-exts-versions.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,53 @@ fetch_source_url() {
echo "$source_url"

# Run nix-prefetch-url command
local val=$($prefetchurl --type sha256 "$source_url" | cut -d ' ' -f 2)
echo "$val"
local initial_hash=$($prefetchurl --type sha256 "$source_url" --unpack | cut -d ' ' -f 2)
#once we can bump up nix version, we can use nix hash convert --hash-algo sha256
local final_hash=$($_nix hash to-sri --type sha256 $initial_hash)
echo "$final_hash"
}

sync_version() {

local package_name=$1
local version="\"$2\""
local hash="\"$3\""


# Update the version and hash in the Nix expression
$editor $PWD/nix/ext/$package_name.nix version --inplace -v "$version"
$editor $PWD/nix/ext/$package_name.nix src.hash --inplace -v $hash
}

run_sync() {
local varname=$1
local package_name=$2

version=$(echo $ansible_vars | $jq -r '.'$varname'')
echo "$key: $version"
url=$($_nix eval .#psql_16/exts/$package_name.src.url)
hash=$(fetch_source_url $url | tail -n 1)
$(sync_version $package_name $version $hash)
echo "synced $package_name to version $version with hash $hash"


}

update_cargo_vendor_hash() {
local package_name=$1
output=$($_nix build .#psql_16/exts/$package_name 2>&1)

# Check if the command exited with an error
if [ $? -ne 0 ]; then
# Extract the hash value after "got: "
hash_value_scraped=$(echo "$output" | grep "got:" | awk '{for (i=1; i<=NF; i++) if ($i ~ /^sha/) print $i}')
hash_value="\"$hash_value_scraped\""
# Continue using the captured hash value
$editor $PWD/nix/ext/$package_name.nix cargoHash --inplace -v $hash_value
echo "Updated cargoHash for $package_name to $hash_value"
else
echo "$package_name builds successfully, moving on..."
fi
}

#iterate values in ansible vars, case statement
Expand All @@ -34,12 +79,20 @@ keys=$(echo "$ansible_vars" | $jq -r 'keys[]')
for key in $keys; do
case $key in
"pgvector_release")
value=$(echo $ansible_vars | $jq -r '.pgvector_release')
echo "$key: $value"
url=$($_nix eval .#psql_16/exts/pgvector.src.url)
hash=$(fetch_source_url $url | tail -n 1)
echo "$hash"

varname="pgvector_release"
package_name="pgvector"
run_sync $varname $package_name
;;
"hypopg_release")
varname="hypopg_release"
package_name="hypopg"
run_sync $varname $package_name
;;
"pg_graphql_release")
varname="pg_graphql_release"
package_name="pg_graphql"
run_sync $varname $package_name
update_cargo_vendor_hash $package_name
;;
*)
;;
Expand Down
0