-
Notifications
You must be signed in to change notification settings - Fork 60
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
Update GHA scripts to use bashbrew-buildkit-envs.sh
#70
Update GHA scripts to use bashbrew-buildkit-envs.sh
#70
Conversation
scripts/github-actions/generate.sh
Outdated
( | ||
"# https://github.com/docker-library/bashbrew/pull/43", | ||
if ([ .meta.entries[].builder ] | index("buildkit")) then | ||
"export BASHBREW_ARCH=\(if .os | startswith("windows-") then "windows-" else "" end)amd64", | ||
"printf \"BASHBREW_ARCH=%q\\n\" \"$BASHBREW_ARCH\" >> \"$GITHUB_ENV\"", | ||
"if [ -x ~/oi/.bin/bashbrew-buildkit-envs.sh ]; then", | ||
"\t# https://github.com/docker-library/official-images/pull/14212", | ||
"\tbuildkitEnvs=\"$(~/oi/.bin/bashbrew-buildkit-envs.sh)\"", | ||
"\teval \"$buildkitEnvs\"", | ||
"\tsed <<<\"$buildkitEnvs\" -re \"s/^export[[:space:]]+//\" >> \"$GITHUB_ENV\"", | ||
"else", | ||
"\tBASHBREW_BUILDKIT_SYNTAX=\"$(< ~/oi/.bashbrew-buildkit-syntax)\"; export BASHBREW_BUILDKIT_SYNTAX", | ||
"\tprintf \"BASHBREW_BUILDKIT_SYNTAX=%q\\n\" \"$BASHBREW_BUILDKIT_SYNTAX\" >> \"$GITHUB_ENV\"", | ||
"fi", | ||
empty | ||
else | ||
empty | ||
end | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a little bit hard to read this way, here's the raw version of the final prepare
string this generates:
git clone --depth 1 https://github.com/docker-library/official-images.git -b master ~/oi
# https://github.com/docker-library/bashbrew/pull/43
export BASHBREW_ARCH=amd64
printf "BASHBREW_ARCH=%q\n" "$BASHBREW_ARCH" >> "$GITHUB_ENV"
if [ -x ~/oi/.bin/bashbrew-buildkit-envs.sh ]; then
# https://github.com/docker-library/official-images/pull/14212
buildkitEnvs="$(~/oi/.bin/bashbrew-buildkit-envs.sh)"
eval "$buildkitEnvs"
sed <<<"$buildkitEnvs" -re "s/^export[[:space:]]+//" >> "$GITHUB_ENV"
else
BASHBREW_BUILDKIT_SYNTAX="$(< ~/oi/.bashbrew-buildkit-syntax)"; export BASHBREW_BUILDKIT_SYNTAX
printf "BASHBREW_BUILDKIT_SYNTAX=%q\n" "$BASHBREW_BUILDKIT_SYNTAX" >> "$GITHUB_ENV"
fi
# create a dummy empty image/layer so we can --filter since= later to get a meaningful image list
{ echo FROM busybox:latest; echo RUN :; } | docker build --no-cache --tag image-list-marker -
LOL now that I have this whole PR written up, I'm realizing the generated scripts never invoke |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #70 +/- ##
=======================================
Coverage 73.10% 73.10%
=======================================
Files 7 7
Lines 714 714
=======================================
Hits 522 522
Misses 162 162
Partials 30 30 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Oh, that's not strictly true -- we do use I will adjust this to avoid setting |
09c32e1
to
f98a4a4
Compare
I have tested this successfully on a very janky fork of docker-library/rabbitmq by applying the following: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 70f7d0d..9cbc88e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -19,11 +19,12 @@ jobs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:
- uses: actions/checkout@v3
- - uses: docker-library/bashbrew@HEAD
+ - uses: infosiftr/bashbrew@f98a4a45c7c41911fed1cad0e25c646c7ad06f92 # hack hack hack
- id: generate-jobs
name: Generate Jobs
run: |
strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")"
+ strategy="$(sed <<<"$strategy" -e 's#docker-library/official-images#infosiftr/stackbrew#g' -e 's/master/bashbrew-buildkit-envs/g')" # hack hack hack
strategy="$("$BASHBREW_SCRIPTS/github-actions/munge-i386.sh" -c <<<"$strategy")"
strategy="$(jq -c '.matrix.include |= [ .[] | select(.name | (test("i386") | not) or test("alpine")) ]' <<<"$strategy")" # Ubuntu no longer supports i386 (so we can only build test Alpine there; qemu-user-static is too slow for other arches)
echo "strategy=$strategy" >> "$GITHUB_OUTPUT" |
f98a4a4
to
f6847de
Compare
else | ||
empty | ||
end | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated against the later change to that PR:
git clone --depth 1 https://github.com/docker-library/official-images.git -b master ~/oi
# https://github.com/docker-library/bashbrew/pull/43
if [ -x ~/oi/.bin/bashbrew-buildkit-env-setup.sh ]; then
# https://github.com/docker-library/official-images/pull/14212
buildkitEnvs="$(~/oi/.bin/bashbrew-buildkit-env-setup.sh)"
jq <<<"$buildkitEnvs" -r '
# this converts from the output of ~/oi/.bin/bashbrew-buildkit-env-setup.sh into what GHA expects in $GITHUB_ENV
# (in a separate env to make embedding/quoting easier inside this sub-jq)
to_entries | map(
(.key | if test("[^a-zA-Z0-9_]+") then
error("invalid env key: \(.)")
else . end)
+ "="
+ (.value | if test("[\r\n]+") then
error("invalid env value: \(.)")
else . end)
) | join("\n")
' | tee -a "$GITHUB_ENV"
else
BASHBREW_BUILDKIT_SYNTAX="$(< ~/oi/.bashbrew-buildkit-syntax)"; export BASHBREW_BUILDKIT_SYNTAX
printf "BASHBREW_BUILDKIT_SYNTAX=%q\n" "$BASHBREW_BUILDKIT_SYNTAX" >> "$GITHUB_ENV"
fi
# create a dummy empty image/layer so we can --filter since= later to get a meaningful image list
{ echo FROM busybox:latest; echo RUN :; } | docker build --no-cache --tag image-list-marker -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my comments don't really belong inside there... 😞
Fixed in the latest. 👍
If our DOI checkout includes the new `bashbrew-buildkit-env-setup.sh` script, we should use it to set up our buildkit-related environment variables.
f6847de
to
044742f
Compare
Tested with a very hacky fork of + git clone --depth 1 https://github.com/infosiftr/stackbrew.git -b bashbrew-buildkit-envs /home/runner/oi
Cloning into '/home/runner/oi'...
+ '[' -x /home/runner/oi/.bin/bashbrew-buildkit-env-setup.sh ']'
++ /home/runner/oi/.bin/bashbrew-buildkit-env-setup.sh
+ buildkitEnvs='{"BASHBREW_BUILDKIT_SYNTAX":"docker/dockerfile:1@sha256:39b85bbfa7536a5feceb7372a0817649ecb[27](https://github.com/tianon/hack-hack-hack-rabbitmq/actions/runs/4441998729/jobs/7797766917#step:3:28)24562a38360f4d6a7782a409b14"}'
+ tee -a /home/runner/work/_temp/_runner_file_commands/set_env_6679fb4c-d8f4-418f-abda-4157baa29039
+ jq -r '
to_entries | map(
(.key | if test("[^a-zA-Z0-9_]+") then
error("invalid env key: \(.)")
else . end)
+ "="
+ (.value | if test("[\r\n]+") then
error("invalid env value: \(.)")
else . end)
) | join("\n")
'
BASHBREW_BUILDKIT_SYNTAX=docker/dockerfile:1@sha256:39b85bbfa7536a5feceb7372a0817649ecb2724562a38360f4d6a7782a409b14
+ echo FROM busybox:latest
+ docker build --no-cache --tag image-list-marker -
+ echo RUN :
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM busybox:latest
latest: Pulling from library/busybox
1487bff95222: Pulling fs layer
1487bff95222: Verifying Checksum
1487bff95222: Download complete
1487bff95222: Pull complete
Digest: sha256:c118f538365369207c12e5794c3cbfb7b042d950af590ae6c[28](https://github.com/tianon/hack-hack-hack-rabbitmq/actions/runs/4441998729/jobs/7797766917#step:3:29)7ede74f[29](https://github.com/tianon/hack-hack-hack-rabbitmq/actions/runs/4441998729/jobs/7797766917#step:3:30)b7d4
Status: Downloaded newer image for busybox:latest
---> bab98d58e29e
Step 2/2 : RUN :
---> Running in b1e3dcea67f7
Removing intermediate container b1e3dcea67f7
---> 8[33](https://github.com/tianon/hack-hack-hack-rabbitmq/actions/runs/4441998729/jobs/7797766917#step:3:34)ca898b66e
Successfully built 833ca898b66e
Successfully tagged image-list-marker:latest |
If our DOI checkout includes the new
bashbrew-buildkit-envs.sh
script, we should use it to set up our buildkit-related environment variables.This is a follow-up to docker-library/official-images#14212