Skip to content

Commit

Permalink
Ugh, testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tianon committed Nov 17, 2022
1 parent d065df0 commit 5884bb5
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 228 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/.bashbrew/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://github.com/docker-library/official-images/pull/13556#issuecomment-1319181339 🙈
name: 'Shared Bashbrew Action'
description: 'Install the same version of Bashbrew consistently in all other GitHub Actions'
inputs:
build:
default: 'host' # or 'docker' or 'none'
runs:
using: 'composite'
steps:

# 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)
- shell: 'bash -Eeuo pipefail -x {0}'
run: echo BASHBREW_VERSION=v0.1.5 >> "$GITHUB_ENV"
- uses: docker-library/bashbrew@v0.1.5
if: inputs.build == 'host'

- run: docker build --pull --tag oisupport/bashbrew:base "https://github.com/docker-library/bashbrew.git#$BASHBREW_VERSION"
shell: 'bash -Eeuo pipefail -x {0}'
if: inputs.build == 'docker'
7 changes: 4 additions & 3 deletions .github/workflows/munge-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ jobs:
# 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)
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 0
- uses: ./.github/workflows/.bashbrew
with:
build: 'docker'
- name: Prepare Environment
run: |
# 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)
bashbrewVersion="$(< bashbrew-version)"
docker build --pull --tag oisupport/bashbrew:base "https://github.com/docker-library/bashbrew.git#v$bashbrewVersion"
# this avoids running repo-local scripts (to avoid CVE-2020-15228 via the scripts being updated to write nasty things to $GITHUB_ENV)
docker build --tag oisupport/bashbrew:diff-pr .
- name: Gather Maintainers
env:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: echo "BASHBREW_VERSION=$(< bashbrew-version)" >> "$GITHUB_ENV"
- uses: docker-library/bashbrew@v${{ env.BASHBREW_VERSION }}
- uses: ./.github/workflows/.bashbrew
- name: Check for Common Issues
run: .github/workflows/naughty.sh

Expand All @@ -43,8 +42,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: echo "BASHBREW_VERSION=$(< bashbrew-version)" >> "$GITHUB_ENV"
- uses: docker-library/bashbrew@v${{ env.BASHBREW_VERSION }}
- uses: ./.github/workflows/.bashbrew
- id: generate-jobs
name: Generate Jobs
run: |
Expand All @@ -70,8 +68,7 @@ jobs:
# https://github.com/docker-library/bashbrew/blob/a40a54d4d81b9fd2e39b4d7ba3fe203e8b022a67/scripts/github-actions/generate.sh#L146-L149
if: runner.os == 'Windows'
- uses: actions/checkout@v3
- run: echo "BASHBREW_VERSION=$(< bashbrew-version)" >> "$GITHUB_ENV"
- uses: docker-library/bashbrew@v${{ env.BASHBREW_VERSION }}
- uses: ./.github/workflows/.bashbrew
- name: Prepare Environment
run: ${{ matrix.runs.prepare }}
- name: Pull Dependencies
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# FYI, this base image is built via test-pr.sh (from https://github.com/docker-library/bashbrew/tree/master/Dockerfile)
# FYI, this base image is built via ".github/workflows/.bashbrew/action.yml" (from https://github.com/docker-library/bashbrew/tree/master/Dockerfile)
FROM oisupport/bashbrew:base

RUN set -eux; \
Expand Down
1 change: 0 additions & 1 deletion bashbrew-version

This file was deleted.

32 changes: 32 additions & 0 deletions pr-urls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -Eeuo pipefail

#
# usage:
# $ ./pr-urls.sh PR-NUMBER
# $ ./pr-urls.sh PR-NUMBER IMAGE1 IMAGE2:TAG1 IMAGE3:TAG2
#
# $ ./pr-urls.sh 12072
# $ ./pr-urls.sh 12072 hello-world:linux
# $ ./pr-urls.sh 12072 | xargs -rt bashbrew build
# $ ./pr-urls.sh 12072 | xargs -rt bashbrew list --uniq
# $ ./pr-urls.sh 12072 | xargs -rt bashbrew list --uniq | xargs -rt ./test/run.sh
#
# (rough replacement for the old "test-pr.sh" script and its associated complexity)
#

pr="$1"
shift

patch="$(wget -qO- "https://github.com/docker-library/official-images/pull/$pr.patch")"

commit="$(grep <<<"$patch" -oE '^From [0-9a-f]+ ' | tail -1 | cut -d' ' -f2)"

if [ "$#" -eq 0 ]; then
files="$(grep <<<"$patch" -oE '^[+]{3} b/library/.+' | cut -d/ -f3 | sort -u)"
set -- $files
fi

for file; do
echo "https://github.com/docker-library/official-images/raw/$commit/library/$file"
done
217 changes: 0 additions & 217 deletions test-pr.sh

This file was deleted.

0 comments on commit 5884bb5

Please sign in to comment.