Skip to content

Commit 440ac1a

Browse files
committed
Update bashbrew to 0.1.5 (and use the new bashbrew action)
1 parent c4baf2d commit 440ac1a

8 files changed

Lines changed: 72 additions & 250 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# https://github.com/docker-library/official-images/pull/13556#issuecomment-1319181339 🙈
2+
name: 'Shared Bashbrew Action'
3+
description: 'Install the same version of Bashbrew consistently in all other GitHub Actions'
4+
inputs:
5+
build:
6+
default: 'host' # or 'docker' or 'none'
7+
runs:
8+
using: 'composite'
9+
steps:
10+
11+
# these two version numbers are intentionally as close together as I could possibly get them because no matter what I tried, GitHub will not allow me to DRY them (can't have any useful variables in `uses:` and can't even have YAML references to steal it in `env:` or something)
12+
- shell: 'bash -Eeuo pipefail -x {0}'
13+
run: echo BASHBREW_VERSION=v0.1.5 >> "$GITHUB_ENV"
14+
- uses: docker-library/bashbrew@v0.1.5
15+
if: inputs.build == 'host'
16+
17+
- run: docker build --pull --tag oisupport/bashbrew:base "https://github.com/docker-library/bashbrew.git#$BASHBREW_VERSION"
18+
shell: 'bash -Eeuo pipefail -x {0}'
19+
if: inputs.build == 'docker'

.github/workflows/generate.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ set -Eeuo pipefail
55
# NOTE: this is *not* a good example for integrating these tests into your own repository!
66
# If you want that, check out https://github.com/docker-library/golang/blob/3f2c52653043f067156ce4f41182c2a758c4c857/.github/workflows/ci.yml instead.
77
#
8-
9-
bashbrewDir="$1"; shift
108

11-
dir="$(dirname "$BASH_SOURCE")" # ./.github/workflows
12-
oiDir="$(dirname "$dir")" # ./.github
13-
oiDir="$(dirname "$oiDir")" # ./
14-
bashbrewVersion="$(< "$oiDir/bashbrew-version")"
15-
export bashbrewVersion
9+
[ -d "$BASHBREW_SCRIPTS/github-actions" ]
1610

1711
if [ "$#" -eq 0 ]; then
1812
git fetch --quiet https://github.com/docker-library/official-images.git master
@@ -23,18 +17,17 @@ fi
2317

2418
strategy='{}'
2519
for repo; do
26-
newStrategy="$(GITHUB_REPOSITORY="$repo" GENERATE_STACKBREW_LIBRARY='cat "library/$GITHUB_REPOSITORY"' "$bashbrewDir/scripts/github-actions/generate.sh")"
20+
newStrategy="$(GITHUB_REPOSITORY="$repo" GENERATE_STACKBREW_LIBRARY='cat "library/$GITHUB_REPOSITORY"' "$BASHBREW_SCRIPTS/github-actions/generate.sh")"
2721
newStrategy="$(jq -c --arg repo "$repo" '.matrix.include = [
2822
.matrix.include[]
2923
| ([ .meta.entries[].tags[0] ]) as $tags
3024
| .name = ($tags | join(", "))
3125
# replace "build" steps with something that uses "bashbrew" instead of "docker build"
32-
# https://github.com/docker-library/bashbrew/blob/a40a54d4d81b9fd2e39b4d7ba3fe203e8b022a67/scripts/github-actions/generate.sh#L74-L93
33-
| .runs.prepare += "\ngit clone --depth 1 https://github.com/docker-library/bashbrew.git -b " + ("v" + env.bashbrewVersion | @sh) + " ~/bashbrew\n~/bashbrew/bashbrew.sh --version"
26+
# https://github.com/docker-library/bashbrew/blob/20b5a50a4eafee1e92fadca5f9cbbce6b16d80b1/scripts/github-actions/generate.sh#L79-L105
3427
| .runs.build = (
3528
(if .os | startswith("windows-") then "export BASHBREW_ARCH=windows-amd64 BASHBREW_CONSTRAINTS=" + ([ .meta.entries[].constraints[] ] | join(", ") | @sh) + "\n" else "" end)
3629
+ "export BASHBREW_LIBRARY=\"$PWD/library\"\n"
37-
+ ([ $tags[] | "~/bashbrew/bashbrew.sh build " + @sh ] | join("\n"))
30+
+ ([ $tags[] | "bashbrew build " + @sh ] | join("\n"))
3831
)
3932
# use our local clone of official-images for running tests (so test changes can be tested too, if they live in the PR with the image change)
4033
# https://github.com/docker-library/bashbrew/blob/a40a54d4d81b9fd2e39b4d7ba3fe203e8b022a67/scripts/github-actions/generate.sh#L95

.github/workflows/munge-pr.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Gather Metadata
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2525
with:
2626
# ideally this would be "github.event.pull_request.merge_commit_sha" but according to https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls#get-a-pull-request if "mergeable" is null (meaning there's a background job in-progress to check mergeability), that value is undefined...
2727
ref: ${{ github.event.pull_request.head.sha }}
@@ -90,16 +90,17 @@ jobs:
9090
needs: gather
9191
if: fromJSON(needs.gather.outputs.images).count > 0
9292
steps:
93-
- uses: actions/checkout@v2
93+
- uses: actions/checkout@v3
9494
with:
9595
# again, this would ideally be "github.event.pull_request.merge_commit_sha" but we might not have that yet when this runs, so we compromise by checkout out the latest code from the target branch (so we get the latest "diff-pr.sh" script to run)
9696
ref: ${{ github.event.pull_request.base.ref }}
9797
fetch-depth: 0
98+
- uses: ./.github/workflows/.bashbrew
99+
with:
100+
build: 'docker'
98101
- name: Prepare Environment
99102
run: |
100-
# this mimics "test-pr.sh", but without running repo-local scripts (to avoid CVE-2020-15228 via the scripts being updated to write nasty things to $GITHUB_ENV)
101-
bashbrewVersion="$(< bashbrew-version)"
102-
docker build --pull --tag oisupport/bashbrew:base "https://github.com/docker-library/bashbrew.git#v$bashbrewVersion"
103+
# this avoids running repo-local scripts (to avoid CVE-2020-15228 via the scripts being updated to write nasty things to $GITHUB_ENV)
103104
docker build --tag oisupport/bashbrew:diff-pr .
104105
- name: Gather Maintainers
105106
env:

.github/workflows/test-pr.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,12 @@ jobs:
2525
name: Naughty
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
2929
with:
3030
fetch-depth: 0
31+
- uses: ./.github/workflows/.bashbrew
3132
- name: Check for Common Issues
32-
run: |
33-
bashbrewVersion="$(< bashbrew-version)"
34-
git clone --depth 1 https://github.com/docker-library/bashbrew.git -b "v$bashbrewVersion" ~/bashbrew
35-
~/bashbrew/bashbrew.sh --version > /dev/null
36-
export PATH="$HOME/bashbrew/bin:$PATH"
37-
bashbrew --version
38-
.github/workflows/naughty.sh
33+
run: .github/workflows/naughty.sh
3934

4035
generate-jobs:
4136
name: Generate Jobs
@@ -44,19 +39,18 @@ jobs:
4439
strategy: ${{ steps.generate-jobs.outputs.strategy }}
4540
length: ${{ steps.generate-jobs.outputs.length }}
4641
steps:
47-
- uses: actions/checkout@v2
42+
- uses: actions/checkout@v3
4843
with:
4944
fetch-depth: 0
45+
- uses: ./.github/workflows/.bashbrew
5046
- id: generate-jobs
5147
name: Generate Jobs
5248
run: |
53-
bashbrewVersion="$(< bashbrew-version)"
54-
git clone --depth 1 https://github.com/docker-library/bashbrew.git -b "v$bashbrewVersion" ~/bashbrew
55-
strategy="$(.github/workflows/generate.sh ~/bashbrew)"
49+
strategy="$(.github/workflows/generate.sh)"
50+
echo "strategy=$strategy" >> "$GITHUB_OUTPUT"
5651
jq . <<<"$strategy" # sanity check / debugging aid
57-
echo "::set-output name=strategy::$strategy"
5852
length="$(jq <<<"$strategy" -r '.matrix.include | length')"
59-
echo "::set-output name=length::$length"
53+
echo "length=$length" >> "$GITHUB_OUTPUT"
6054
6155
test:
6256
needs: generate-jobs
@@ -73,7 +67,8 @@ jobs:
7367
echo 'MSYS=winsymlinks:nativestrict' >> "$GITHUB_ENV"
7468
# https://github.com/docker-library/bashbrew/blob/a40a54d4d81b9fd2e39b4d7ba3fe203e8b022a67/scripts/github-actions/generate.sh#L146-L149
7569
if: runner.os == 'Windows'
76-
- uses: actions/checkout@v2
70+
- uses: actions/checkout@v3
71+
- uses: ./.github/workflows/.bashbrew
7772
- name: Prepare Environment
7873
run: ${{ matrix.runs.prepare }}
7974
- name: Pull Dependencies

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# FYI, this base image is built via test-pr.sh (from https://github.com/docker-library/bashbrew/tree/master/Dockerfile)
1+
# FYI, this base image is built via ".github/workflows/.bashbrew/action.yml" (from https://github.com/docker-library/bashbrew/tree/master/Dockerfile)
22
FROM oisupport/bashbrew:base
33

44
RUN set -eux; \

bashbrew-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

pr-urls.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
#
5+
# usage:
6+
# $ ./pr-urls.sh PR-NUMBER
7+
# $ ./pr-urls.sh PR-NUMBER IMAGE1 IMAGE2:TAG1 IMAGE3:TAG2
8+
#
9+
# $ ./pr-urls.sh 12072
10+
# $ ./pr-urls.sh 12072 hello-world:linux
11+
# $ ./pr-urls.sh 12072 | xargs -rt bashbrew build
12+
# $ ./pr-urls.sh 12072 | xargs -rt bashbrew list --uniq
13+
# $ ./pr-urls.sh 12072 | xargs -rt bashbrew list --uniq | xargs -rt ./test/run.sh
14+
#
15+
# (rough replacement for the old "test-pr.sh" script and its associated complexity)
16+
#
17+
18+
pr="$1"
19+
shift
20+
21+
patch="$(wget -qO- "https://github.com/docker-library/official-images/pull/$pr.patch")"
22+
23+
commit="$(grep <<<"$patch" -oE '^From [0-9a-f]+ ' | tail -1 | cut -d' ' -f2)"
24+
25+
if [ "$#" -eq 0 ]; then
26+
files="$(grep <<<"$patch" -oE '^[+]{3} b/library/.+' | cut -d/ -f3 | sort -u)"
27+
set -- $files
28+
fi
29+
30+
for file; do
31+
echo "https://github.com/docker-library/official-images/raw/$commit/library/$file"
32+
done

0 commit comments

Comments
 (0)