Skip to content

Update GitHub Actions to take advantage of a generated matrix #81

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

Merged
merged 1 commit into from
Apr 29, 2020
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
67 changes: 34 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
name: GitHub CI

on:

pull_request:

push:
branches:
- master

schedule:
- cron: 0 0 * * 0

jobs:

build-test:
defaults:
run:
shell: 'bash -Eeuo pipefail -x {0}'

strategy:
matrix:
libc:
- glibc
- musl
- uclibc
jobs:

generate-jobs:
name: Generate Jobs
runs-on: ubuntu-latest

outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:

- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Prepare Environment
run: docker system prune --all --force --volumes
- name: Happy Eyeballs
run: wget -qO- 'https://github.com/tianon/pgp-happy-eyeballs/raw/master/hack-my-builds.sh' | bash

- name: Build Tarball
run: ./build.sh ${{ matrix.libc }}

- name: Build Image
run: docker build -t busybox:${{ matrix.libc }} ${{ matrix.libc }}

- name: Run Tests
- id: generate-jobs
name: Generate Jobs
run: |
git clone --depth 1 https://github.com/docker-library/official-images.git ~/oi
~/oi/test/run.sh busybox:${{ matrix.libc }}

git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew
strategy="$(GENERATE_STACKBREW_LIBRARY='.github/workflows/fake-gsl.sh' ~/bashbrew/scripts/github-actions/generate.sh)"
strategy="$(jq -c '.matrix.include = [ .matrix.include[] | .runs.build = "./build.sh " + (.meta.entries[].directory | @sh) + "\n" + .runs.build ]' <<<"$strategy")"
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@v1
- name: Prepare Environment
run: ${{ matrix.runs.prepare }}
- name: Pull Dependencies
run: ${{ matrix.runs.pull }}
- name: Build ${{ matrix.name }}
run: ${{ matrix.runs.build }}
- name: History ${{ matrix.name }}
run: ${{ matrix.runs.history }}
- name: Test ${{ matrix.name }}
run: ${{ matrix.runs.test }}
- name: '"docker images"'
run: docker images
run: ${{ matrix.runs.images }}
15 changes: 15 additions & 0 deletions .github/workflows/fake-gsl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# this is a fake version of "generate-stackbrew-library.sh" just so https://github.com/docker-library/bashbrew/blob/c74be66ae6a019e0baee601287187dc6df29b384/scripts/github-actions/generate.sh can generate us a sane starter matrix

echo 'Maintainers: foo (@bar)'
echo 'GitRepo: https://github.com/docker-library/busybox.git'
for f in */Dockerfile.builder; do
d="$(dirname "$f")"
commit="$(git log -1 --format='format:%H' "$d/Dockerfile")"
echo
echo "Tags: $d"
echo "Directory: $d"
echo "GitCommit: $commit"
done