Skip to content

Commit 8454c26

Browse files
authored
Merge pull request #81 from infosiftr/github-actions
Update GitHub Actions to take advantage of a generated matrix
2 parents 68c99dc + eb35037 commit 8454c26

File tree

2 files changed

+49
-33
lines changed

2 files changed

+49
-33
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
11
name: GitHub CI
22

33
on:
4-
54
pull_request:
6-
75
push:
86
branches:
97
- master
10-
118
schedule:
129
- cron: 0 0 * * 0
1310

14-
jobs:
15-
16-
build-test:
11+
defaults:
12+
run:
13+
shell: 'bash -Eeuo pipefail -x {0}'
1714

18-
strategy:
19-
matrix:
20-
libc:
21-
- glibc
22-
- musl
23-
- uclibc
15+
jobs:
2416

17+
generate-jobs:
18+
name: Generate Jobs
2519
runs-on: ubuntu-latest
26-
20+
outputs:
21+
strategy: ${{ steps.generate-jobs.outputs.strategy }}
2722
steps:
28-
2923
- uses: actions/checkout@v1
30-
with:
31-
fetch-depth: 1
32-
33-
- name: Prepare Environment
34-
run: docker system prune --all --force --volumes
35-
- name: Happy Eyeballs
36-
run: wget -qO- 'https://github.com/tianon/pgp-happy-eyeballs/raw/master/hack-my-builds.sh' | bash
37-
38-
- name: Build Tarball
39-
run: ./build.sh ${{ matrix.libc }}
40-
41-
- name: Build Image
42-
run: docker build -t busybox:${{ matrix.libc }} ${{ matrix.libc }}
43-
44-
- name: Run Tests
24+
- id: generate-jobs
25+
name: Generate Jobs
4526
run: |
46-
git clone --depth 1 https://github.com/docker-library/official-images.git ~/oi
47-
~/oi/test/run.sh busybox:${{ matrix.libc }}
48-
27+
git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew
28+
strategy="$(GENERATE_STACKBREW_LIBRARY='.github/workflows/fake-gsl.sh' ~/bashbrew/scripts/github-actions/generate.sh)"
29+
strategy="$(jq -c '.matrix.include = [ .matrix.include[] | .runs.build = "./build.sh " + (.meta.entries[].directory | @sh) + "\n" + .runs.build ]' <<<"$strategy")"
30+
jq . <<<"$strategy" # sanity check / debugging aid
31+
echo "::set-output name=strategy::$strategy"
32+
33+
test:
34+
needs: generate-jobs
35+
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
36+
name: ${{ matrix.name }}
37+
runs-on: ${{ matrix.os }}
38+
steps:
39+
- uses: actions/checkout@v1
40+
- name: Prepare Environment
41+
run: ${{ matrix.runs.prepare }}
42+
- name: Pull Dependencies
43+
run: ${{ matrix.runs.pull }}
44+
- name: Build ${{ matrix.name }}
45+
run: ${{ matrix.runs.build }}
46+
- name: History ${{ matrix.name }}
47+
run: ${{ matrix.runs.history }}
48+
- name: Test ${{ matrix.name }}
49+
run: ${{ matrix.runs.test }}
4950
- name: '"docker images"'
50-
run: docker images
51+
run: ${{ matrix.runs.images }}

.github/workflows/fake-gsl.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
# 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
5+
6+
echo 'Maintainers: foo (@bar)'
7+
echo 'GitRepo: https://github.com/docker-library/busybox.git'
8+
for f in */Dockerfile.builder; do
9+
d="$(dirname "$f")"
10+
commit="$(git log -1 --format='format:%H' "$d/Dockerfile")"
11+
echo
12+
echo "Tags: $d"
13+
echo "Directory: $d"
14+
echo "GitCommit: $commit"
15+
done

0 commit comments

Comments
 (0)