Skip to content
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

Add initial "composite" action for installing Bashbrew #57

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: '>=1.18'
- name: Build
run: |
./bashbrew.sh --version > /dev/null
bin/bashbrew --version
- uses: actions/checkout@v3
- uses: ./ # test our "action.yml" 👀
- name: Smoke Test
run: |
image='https://github.com/docker-library/official-images/raw/master/library/hello-world'
bin/bashbrew list "$image"
bin/bashbrew list --uniq "$image"
bin/bashbrew cat "$image"
bin/bashbrew from --uniq "$image"
bashbrew list "$image"
bashbrew list --uniq "$image"
bashbrew cat "$image"
bashbrew from --uniq "$image"

"$BASHBREW_SCRIPTS/bashbrew-host-arch.sh" # should print "amd64"

arm32v7="$("$BASHBREW_SCRIPTS/bashbrew-arch-to-goenv.sh" arm32v7)"
eval "$arm32v7"
test "$GOARM" = '7'
go-test:
name: Go Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Go Test
run: |
docker build --pull --file Dockerfile.test --tag test .
Expand All @@ -49,15 +49,15 @@ jobs:
name: Test Dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build Dockerfile
run: |
docker build --pull .
dockerfile-release:
name: Test Dockerfile.release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build Dockerfile.release
run: |
docker build --pull --file Dockerfile.release .
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# steps:
# - ...
# - uses: docker-library/bashbrew
# - ...

name: 'Install Bashbrew'
description: 'Install the "bashbrew" tool in GITHUB_PATH'
runs:
using: 'composite'
steps:
- uses: actions/setup-go@v3
with:
go-version-file: '${{ github.action_path }}/go.mod'
- run: |
'${{ github.action_path }}/bashbrew.sh' --version > /dev/null
'${{ github.action_path }}/bin/bashbrew' --version
echo '${{ github.action_path }}/bin' >> "$GITHUB_PATH"
echo 'BASHBREW_SCRIPTS=${{ github.action_path }}/scripts' >> "$GITHUB_ENV"
shell: 'bash -Eeuo pipefail -x {0}'
10 changes: 5 additions & 5 deletions scripts/github-actions/example-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ jobs:
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: docker-library/bashbrew
- id: generate-jobs
name: Generate Jobs
run: |
git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew
strategy="$(~/bashbrew/scripts/github-actions/generate.sh)"
strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")"
echo "strategy=$strategy" >> "$GITHUB_OUTPUT"
jq . <<<"$strategy" # sanity check / debugging aid
echo "::set-output name=strategy::$strategy"

test:
needs: generate-jobs
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Prepare Environment
run: ${{ matrix.runs.prepare }}
- name: Pull Dependencies
Expand Down
8 changes: 6 additions & 2 deletions scripts/github-actions/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ for tag in $tags; do
'
)"

parent="$(bashbrew parents "$bashbrewImage" | tail -1)" # if there ever exists an image with TWO parents in the same repo, this will break :)
if [ -n "$parent" ]; then
if parent="$(bashbrew parents "$bashbrewImage" | grep "^${tag%%:*}:")" && [ -n "$parent" ]; then
if [ "$(wc -l <<<"$parent")" -ne 1 ]; then
echo >&2 "error: '$tag' has multiple parents in the same repository and this script can't handle that yet!"
echo >&2 "$parent"
exit 1
fi
parentBashbrewImage="${parent##*/}" # account for BASHBREW_NAMESPACE being set
parent="$(bashbrew list --uniq "$parentBashbrewImage")" # normalize
parentMeta="${metas["$parent"]}"
Expand Down