Skip to content

Commit

Permalink
Try simplifying "Determine SCM revision" part of build (geldata#8353)
Browse files Browse the repository at this point in the history
The only genuinely conditional code is the url determining.

There was caching done on the distro paths, but not the other ones.
If it becomes a problem we can add back the caching for all of them.
  • Loading branch information
msullivan authored Feb 19, 2025
1 parent 70c2baf commit 245c0e5
Show file tree
Hide file tree
Showing 3 changed files with 417 additions and 418 deletions.
57 changes: 15 additions & 42 deletions .github/workflows.src/build.inc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,30 @@
run: |
rev=$(git rev-parse HEAD)
jq_filter='.packages[] | select(.basename == "gel-server") | select(.architecture == $ARCH) | .version_details.metadata.scm_revision | . as $rev | select(($rev != null) and ($REV | startswith($rev)))'
<% for tgt in targets.linux %>
<% for tgt in targets.linux + targets.macos %>
val=true

<% if tgt.family == "debian" %>
idx_file=<< tgt.platform_version >>.nightly.json
if [ ! -e "/tmp/$idx_file" ]; then
curl --fail -o /tmp/$idx_file -s https://packages.edgedb.com/apt/.jsonindexes/$idx_file || true
fi
if [ -e "/tmp/$idx_file" ]; then
out=$(cat /tmp/$idx_file | jq -r --arg REV "$rev" --arg ARCH "<< tgt.arch >>" "$jq_filter")
if [ -n "$out" ]; then
echo 'Skip rebuilding existing << tgt.name >>'
val=false
fi
fi
url=https://packages.edgedb.com/apt/.jsonindexes/<< tgt.platform_version >>.nightly.json

<% elif tgt.family == "redhat" %>
idx_file=el<< tgt.platform_version >>.nightly.json
if [ ! -e "/tmp/$idx_file" ]; then
curl --fail -o /tmp/$idx_file -s https://packages.edgedb.com/rpm/.jsonindexes/$idx_file || true
fi
if [ -e "/tmp/$idx_file" ]; then
out=$(cat /tmp/$idx_file | jq -r --arg REV "$rev" --arg ARCH "<< tgt.arch >>" "$jq_filter")
if [ -n "$out" ]; then
echo 'Skip rebuilding existing << tgt.name >>'
val=false
fi
fi
url=https://packages.edgedb.com/rpm/.jsonindexes/el<< tgt.platform_version >>.nightly.json

<% elif tgt.family == "generic" %>
out=$(curl --fail -s https://packages.edgedb.com/archive/.jsonindexes/<< tgt.platform_version >>-unknown-linux-<< "{}".format(tgt.platform_libc) if tgt.platform_libc else "gnu" >>.nightly.json | jq -r --arg REV "$rev" --arg ARCH "<< tgt.arch >>" "$jq_filter" || true)
if [ -n "$out" ]; then
echo 'Skip rebuilding existing << tgt.name >>'
val=false
fi
url=https://packages.edgedb.com/archive/.jsonindexes/<< tgt.platform_version >>-unknown-linux-<< "{}".format(tgt.platform_libc) if tgt.platform_libc else "gnu" >>.nightly.json

<% elif tgt.platform == "macos" %>
url=https://packages.edgedb.com/archive/.jsonindexes/<< tgt.platform_version >>-apple-darwin.nightly.json

<% endif %>
echo if_<< tgt.name.replace('-', '_') >>="$val" >> $GITHUB_OUTPUT
<% endfor %>
<% for tgt in targets.macos %>
val=true
<% if tgt.platform == "macos" %>
out=$(curl --fail -s https://packages.edgedb.com/archive/.jsonindexes/<< tgt.platform_version >>-apple-darwin.nightly.json | jq -r --arg REV "$rev" --arg ARCH "<< tgt.arch >>" "$jq_filter" || true)
if [ -n "$out" ]; then
echo 'Skip rebuilding existing << tgt.platform >>-<< tgt.platform_version >>'
val=false
fi
<% elif tgt.platform == "win" %>
out=$(curl --fail -s https://packages.edgedb.com/archive/.jsonindexes/<< tgt.platform_version >>-pc-windows-msvc.nightly.json | jq -r --arg REV "$rev" --arg ARCH "<< tgt.arch >>" "$jq_filter" || true)

out=$(curl --fail -s "$url" | jq -r --arg REV "$rev" --arg ARCH "<< tgt.arch >>" "$jq_filter" || true)
if [ -n "$out" ]; then
echo 'Skip rebuilding existing << tgt.platform >>-<< tgt.platform_version >>'
echo 'Skip rebuilding existing << tgt.name >>'
val=false
fi
<% endif %>
echo if_<< tgt.name.replace('-', '_') >>="$val" >> $GITHUB_OUTPUT

<% endfor %>
<% endif %>

Expand Down
Loading

0 comments on commit 245c0e5

Please sign in to comment.