Skip to content

Commit

Permalink
Avoid rebuilding nightlies of the same SCM revision (#6814)
Browse files Browse the repository at this point in the history
Port of geldata/gel-cli#913

Co-authored-by: Fantix King <[email protected]>
  • Loading branch information
2 people authored and aljazerzen committed Mar 13, 2024
1 parent 60778b8 commit 934fca7
Show file tree
Hide file tree
Showing 6 changed files with 1,002 additions and 6 deletions.
70 changes: 69 additions & 1 deletion .github/workflows.src/build.inc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.whichver.outputs.branch }}
<% if subdist == "nightly" %>
<% for tgt in targets.linux + targets.macos %>
if_<< tgt.name.replace('-', '_') >>: ${{ steps.scm.outputs.if_<< tgt.name.replace('-', '_') >> }}
<% endfor %>
<% endif %>
steps:
- uses: actions/checkout@v3

Expand All @@ -13,12 +18,72 @@
echo branch="${branch}" >> $GITHUB_OUTPUT
id: whichver

<% if subdist == "nightly" %>
- name: Determine SCM revision
id: scm
shell: bash
run: |
rev=$(git rev-parse HEAD)
jq_filter='.packages[] | select(.basename == "edgedb-server") | select(.architecture == $ARCH) | .version_details.metadata.scm_revision | . as $rev | select(($rev != null) and ($REV | startswith($rev)))'
<% for tgt in targets.linux %>
val=true
<% if tgt.family == "debian" %>
idx_file=<< tgt.platform_version >>.nightly.json
if [ ! -e "/tmp/$idx_file" ]; then
curl -s https://packages.edgedb.com/apt/.jsonindexes/$idx_file > /tmp/$idx_file
fi
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
<% elif tgt.family == "redhat" %>
idx_file=el<< tgt.platform_version >>.nightly.json
if [ ! -e "/tmp/$idx_file" ]; then
curl -s https://packages.edgedb.com/rpm/.jsonindexes/$idx_file > /tmp/$idx_file
fi
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
<% elif tgt.family == "generic" %>
out=$(curl -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")
if [ -n "$out" ]; then
echo 'Skip rebuilding existing << tgt.name >>'
val=false
fi
<% endif %>
echo if_<< tgt.name.replace('-', '_') >>="$val" >> $GITHUB_OUTPUT
<% endfor %>
<% for tgt in targets.macos %>
val=true
<% if tgt.platform == "macos" %>
out=$(curl -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")
if [ -n "$out" ]; then
echo 'Skip rebuilding existing << tgt.platform >>-<< tgt.platform_version >>'
val=false
fi
<% elif tgt.platform == "win" %>
out=$(curl -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")
if [ -n "$out" ]; then
echo 'Skip rebuilding existing << tgt.platform >>-<< tgt.platform_version >>'
val=false
fi
<% endif %>
echo if_<< tgt.name.replace('-', '_') >>="$val" >> $GITHUB_OUTPUT
<% endfor %>
<% endif %>

<%- for tgt in targets.linux %>
<%- set plat_id = tgt.platform + ("{}".format(tgt.platform_libc) if tgt.platform_libc else "") + ("-{}".format(tgt.platform_version) if tgt.platform_version else "") %>

build-<< tgt.name >>:
runs-on: << tgt.runs_on if tgt.runs_on else "ubuntu-latest" >>
needs: prep
<% if subdist == "nightly" %>
if: needs.prep.outputs.if_<< tgt.name.replace('-', '_') >> == 'true'
<% endif %>

steps:
- name: Build
Expand Down Expand Up @@ -55,6 +120,9 @@
build-<< tgt.name >>:
runs-on: << tgt.runs_on if tgt.runs_on else "macos-latest" >>
needs: prep
<% if subdist == "nightly" %>
if: needs.prep.outputs.if_<< tgt.name.replace('-', '_') >> == 'true'
<% endif %>

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -89,7 +157,7 @@
<%- endif %>
PKG_PLATFORM: "<< tgt.platform >>"
PKG_PLATFORM_VERSION: "<< tgt.platform_version >>"
PKG_PLATFORM_ARCH: "<< tgt.platform_arch if tgt.platform_arch else '' >>"
PKG_PLATFORM_ARCH: "<< tgt.arch if tgt.arch else '' >>"
METAPKG_GIT_CACHE: disabled
<%- if tgt.family == "generic" %>
BUILD_GENERIC: true
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows.src/build.targets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,109 +6,130 @@ publications:
targets:
linux:
- name: debian-buster-x86_64
arch: x86_64
platform: debian
platform_version: buster
family: debian
runs_on: [self-hosted, linux, x64]
docker_arch: linux/amd64
- name: debian-buster-aarch64
arch: aarch64
platform: debian
platform_version: buster
family: debian
runs_on: [self-hosted, linux, arm64]
docker_arch: linux/arm64
- name: debian-bullseye-x86_64
arch: x86_64
platform: debian
platform_version: bullseye
family: debian
runs_on: [self-hosted, linux, x64]
- name: debian-bullseye-aarch64
arch: aarch64
platform: debian
platform_version: bullseye
family: debian
runs_on: [self-hosted, linux, arm64]
- name: debian-bookworm-x86_64
arch: x86_64
platform: debian
platform_version: bookworm
family: debian
runs_on: [self-hosted, linux, x64]
- name: debian-bookworm-aarch64
arch: aarch64
platform: debian
platform_version: bookworm
family: debian
runs_on: [self-hosted, linux, arm64]
- name: ubuntu-bionic-x86_64
arch: x86_64
platform: ubuntu
platform_version: bionic
family: debian
runs_on: [self-hosted, linux, x64]
- name: ubuntu-bionic-aarch64
arch: aarch64
platform: ubuntu
platform_version: bionic
family: debian
runs_on: [self-hosted, linux, arm64]
- name: ubuntu-focal-x86_64
arch: x86_64
platform: ubuntu
platform_version: focal
family: debian
runs_on: [self-hosted, linux, x64]
- name: ubuntu-focal-aarch64
arch: aarch64
platform: ubuntu
platform_version: focal
family: debian
runs_on: [self-hosted, linux, arm64]
- name: ubuntu-jammy-x86_64
arch: x86_64
platform: ubuntu
platform_version: jammy
family: debian
runs_on: [self-hosted, linux, x64]
- name: ubuntu-jammy-aarch64
arch: aarch64
platform: ubuntu
platform_version: jammy
family: debian
runs_on: [self-hosted, linux, arm64]
- name: centos-7-x86_64
arch: x86_64
platform: centos
platform_version: 7
family: redhat
runs_on: [self-hosted, linux, x64]
- name: centos-8-x86_64
arch: x86_64
platform: centos
platform_version: 8
family: redhat
runs_on: [self-hosted, linux, x64]
- name: centos-8-aarch64
arch: aarch64
platform: centos
platform_version: 8
family: redhat
runs_on: [self-hosted, linux, arm64]
- name: rockylinux-9-x86_64
arch: x86_64
platform: rockylinux
platform_version: 9
family: redhat
runs_on: [self-hosted, linux, x64]
- name: rockylinux-9-aarch64
arch: aarch64
platform: rockylinux
platform_version: 9
family: redhat
runs_on: [self-hosted, linux, arm64]
- name: linux-x86_64
arch: x86_64
platform: linux
platform_version: x86_64
family: generic
runs_on: [self-hosted, linux, x64]
- name: linux-aarch64
arch: aarch64
platform: linux
platform_version: aarch64
family: generic
runs_on: [self-hosted, linux, arm64]
- name: linuxmusl-x86_64
arch: x86_64
platform: linux
platform_version: x86_64
platform_libc: musl
family: generic
runs_on: [self-hosted, linux, x64]
- name: linuxmusl-aarch64
arch: aarch64
platform: linux
platform_version: aarch64
platform_libc: musl
Expand All @@ -117,12 +138,13 @@ targets:

macos:
- name: macos-x86_64
arch: x86_64
platform: macos
platform_version: x86_64
family: generic
platform_arch: x86_64
runs_on: [self-hosted, macOS, X64]
- name: macos-aarch64
arch: aarch64
platform: macos
platform_version: aarch64
family: generic
Expand Down
Loading

0 comments on commit 934fca7

Please sign in to comment.