From 3c96e86ab0b05fc0211b4dddf7f3bc0c1c475015 Mon Sep 17 00:00:00 2001 From: Travis Shivers Date: Mon, 21 Sep 2020 22:20:21 -0500 Subject: [PATCH 1/2] ci: add multiarch testing --- .github/workflows/10-alpine3.10.yml | 27 +++++++++++++-- .github/workflows/10-alpine3.11.yml | 27 +++++++++++++-- .github/workflows/10-alpine3.9.yml | 27 +++++++++++++-- .github/workflows/10-buster-slim.yml | 27 +++++++++++++-- .github/workflows/10-buster.yml | 27 +++++++++++++-- .github/workflows/10-stretch-slim.yml | 27 +++++++++++++-- .github/workflows/10-stretch.yml | 27 +++++++++++++-- .github/workflows/12-alpine3.10.yml | 27 +++++++++++++-- .github/workflows/12-alpine3.11.yml | 27 +++++++++++++-- .github/workflows/12-alpine3.12.yml | 27 +++++++++++++-- .github/workflows/12-alpine3.9.yml | 27 +++++++++++++-- .github/workflows/12-buster-slim.yml | 27 +++++++++++++-- .github/workflows/12-buster.yml | 27 +++++++++++++-- .github/workflows/12-stretch-slim.yml | 27 +++++++++++++-- .github/workflows/12-stretch.yml | 27 +++++++++++++-- .github/workflows/14-alpine3.10.yml | 27 +++++++++++++-- .github/workflows/14-alpine3.11.yml | 27 +++++++++++++-- .github/workflows/14-alpine3.12.yml | 27 +++++++++++++-- .github/workflows/14-buster-slim.yml | 27 +++++++++++++-- .github/workflows/14-buster.yml | 27 +++++++++++++-- .github/workflows/14-stretch-slim.yml | 27 +++++++++++++-- .github/workflows/14-stretch.yml | 27 +++++++++++++-- functions.sh | 48 +++++++++++++++++++++++++++ test-build.sh | 30 +++++++++++------ test-image.bats | 6 ++-- update.sh | 30 +++++++++++++++-- 26 files changed, 625 insertions(+), 83 deletions(-) diff --git a/.github/workflows/10-alpine3.10.yml b/.github/workflows/10-alpine3.10.yml index 1e27cc11f..84544a680 100644 --- a/.github/workflows/10-alpine3.10.yml +++ b/.github/workflows/10-alpine3.10.yml @@ -18,7 +18,28 @@ jobs: build: name: 10 on alpine3.10 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 10 alpine3.10 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 10 alpine3.10 ${{ matrix.arch }} diff --git a/.github/workflows/10-alpine3.11.yml b/.github/workflows/10-alpine3.11.yml index e7f459afe..525148e02 100644 --- a/.github/workflows/10-alpine3.11.yml +++ b/.github/workflows/10-alpine3.11.yml @@ -18,7 +18,28 @@ jobs: build: name: 10 on alpine3.11 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 10 alpine3.11 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 10 alpine3.11 ${{ matrix.arch }} diff --git a/.github/workflows/10-alpine3.9.yml b/.github/workflows/10-alpine3.9.yml index cfc60915a..229aba8ad 100644 --- a/.github/workflows/10-alpine3.9.yml +++ b/.github/workflows/10-alpine3.9.yml @@ -18,7 +18,28 @@ jobs: build: name: 10 on alpine3.9 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 10 alpine3.9 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 10 alpine3.9 ${{ matrix.arch }} diff --git a/.github/workflows/10-buster-slim.yml b/.github/workflows/10-buster-slim.yml index 7d1b53e9a..c7c19f7aa 100644 --- a/.github/workflows/10-buster-slim.yml +++ b/.github/workflows/10-buster-slim.yml @@ -18,7 +18,28 @@ jobs: build: name: 10 on buster-slim runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 10 buster-slim + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 10 buster-slim ${{ matrix.arch }} diff --git a/.github/workflows/10-buster.yml b/.github/workflows/10-buster.yml index 648f5f7b9..774e413f8 100644 --- a/.github/workflows/10-buster.yml +++ b/.github/workflows/10-buster.yml @@ -18,7 +18,28 @@ jobs: build: name: 10 on buster runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 10 buster + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 10 buster ${{ matrix.arch }} diff --git a/.github/workflows/10-stretch-slim.yml b/.github/workflows/10-stretch-slim.yml index 846ec74de..e33577f77 100644 --- a/.github/workflows/10-stretch-slim.yml +++ b/.github/workflows/10-stretch-slim.yml @@ -18,7 +18,28 @@ jobs: build: name: 10 on stretch-slim runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 10 stretch-slim + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 10 stretch-slim ${{ matrix.arch }} diff --git a/.github/workflows/10-stretch.yml b/.github/workflows/10-stretch.yml index 7a9dc1b22..3c0648203 100644 --- a/.github/workflows/10-stretch.yml +++ b/.github/workflows/10-stretch.yml @@ -18,7 +18,28 @@ jobs: build: name: 10 on stretch runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 10 stretch + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 10 stretch ${{ matrix.arch }} diff --git a/.github/workflows/12-alpine3.10.yml b/.github/workflows/12-alpine3.10.yml index e81565fe7..b7e3351d3 100644 --- a/.github/workflows/12-alpine3.10.yml +++ b/.github/workflows/12-alpine3.10.yml @@ -18,7 +18,28 @@ jobs: build: name: 12 on alpine3.10 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 12 alpine3.10 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 12 alpine3.10 ${{ matrix.arch }} diff --git a/.github/workflows/12-alpine3.11.yml b/.github/workflows/12-alpine3.11.yml index 531a09680..474f99c8f 100644 --- a/.github/workflows/12-alpine3.11.yml +++ b/.github/workflows/12-alpine3.11.yml @@ -18,7 +18,28 @@ jobs: build: name: 12 on alpine3.11 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 12 alpine3.11 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 12 alpine3.11 ${{ matrix.arch }} diff --git a/.github/workflows/12-alpine3.12.yml b/.github/workflows/12-alpine3.12.yml index f18fc554e..afe9cf22e 100644 --- a/.github/workflows/12-alpine3.12.yml +++ b/.github/workflows/12-alpine3.12.yml @@ -18,7 +18,28 @@ jobs: build: name: 12 on alpine3.12 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 12 alpine3.12 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 12 alpine3.12 ${{ matrix.arch }} diff --git a/.github/workflows/12-alpine3.9.yml b/.github/workflows/12-alpine3.9.yml index 385ff52a2..ee9746fa0 100644 --- a/.github/workflows/12-alpine3.9.yml +++ b/.github/workflows/12-alpine3.9.yml @@ -18,7 +18,28 @@ jobs: build: name: 12 on alpine3.9 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 12 alpine3.9 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 12 alpine3.9 ${{ matrix.arch }} diff --git a/.github/workflows/12-buster-slim.yml b/.github/workflows/12-buster-slim.yml index 04f8e8b11..03befbefd 100644 --- a/.github/workflows/12-buster-slim.yml +++ b/.github/workflows/12-buster-slim.yml @@ -18,7 +18,28 @@ jobs: build: name: 12 on buster-slim runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 12 buster-slim + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 12 buster-slim ${{ matrix.arch }} diff --git a/.github/workflows/12-buster.yml b/.github/workflows/12-buster.yml index 0b16ee6a9..30e3389aa 100644 --- a/.github/workflows/12-buster.yml +++ b/.github/workflows/12-buster.yml @@ -18,7 +18,28 @@ jobs: build: name: 12 on buster runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 12 buster + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 12 buster ${{ matrix.arch }} diff --git a/.github/workflows/12-stretch-slim.yml b/.github/workflows/12-stretch-slim.yml index 608160eeb..c99d431fe 100644 --- a/.github/workflows/12-stretch-slim.yml +++ b/.github/workflows/12-stretch-slim.yml @@ -18,7 +18,28 @@ jobs: build: name: 12 on stretch-slim runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 12 stretch-slim + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 12 stretch-slim ${{ matrix.arch }} diff --git a/.github/workflows/12-stretch.yml b/.github/workflows/12-stretch.yml index 8019f3e1f..f45479c8f 100644 --- a/.github/workflows/12-stretch.yml +++ b/.github/workflows/12-stretch.yml @@ -18,7 +18,28 @@ jobs: build: name: 12 on stretch runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 12 stretch + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 12 stretch ${{ matrix.arch }} diff --git a/.github/workflows/14-alpine3.10.yml b/.github/workflows/14-alpine3.10.yml index e0d04a271..f7477121f 100644 --- a/.github/workflows/14-alpine3.10.yml +++ b/.github/workflows/14-alpine3.10.yml @@ -18,7 +18,28 @@ jobs: build: name: 14 on alpine3.10 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 14 alpine3.10 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 14 alpine3.10 ${{ matrix.arch }} diff --git a/.github/workflows/14-alpine3.11.yml b/.github/workflows/14-alpine3.11.yml index c401f9389..9d6f879c7 100644 --- a/.github/workflows/14-alpine3.11.yml +++ b/.github/workflows/14-alpine3.11.yml @@ -18,7 +18,28 @@ jobs: build: name: 14 on alpine3.11 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 14 alpine3.11 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 14 alpine3.11 ${{ matrix.arch }} diff --git a/.github/workflows/14-alpine3.12.yml b/.github/workflows/14-alpine3.12.yml index 3a20d9520..79cd3f205 100644 --- a/.github/workflows/14-alpine3.12.yml +++ b/.github/workflows/14-alpine3.12.yml @@ -18,7 +18,28 @@ jobs: build: name: 14 on alpine3.12 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 14 alpine3.12 + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 14 alpine3.12 ${{ matrix.arch }} diff --git a/.github/workflows/14-buster-slim.yml b/.github/workflows/14-buster-slim.yml index b7d027f93..bf37a88e7 100644 --- a/.github/workflows/14-buster-slim.yml +++ b/.github/workflows/14-buster-slim.yml @@ -18,7 +18,28 @@ jobs: build: name: 14 on buster-slim runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 14 buster-slim + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 14 buster-slim ${{ matrix.arch }} diff --git a/.github/workflows/14-buster.yml b/.github/workflows/14-buster.yml index 4481aadc2..061a4fdab 100644 --- a/.github/workflows/14-buster.yml +++ b/.github/workflows/14-buster.yml @@ -18,7 +18,28 @@ jobs: build: name: 14 on buster runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 14 buster + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 14 buster ${{ matrix.arch }} diff --git a/.github/workflows/14-stretch-slim.yml b/.github/workflows/14-stretch-slim.yml index d7c68f026..d9e1e9a66 100644 --- a/.github/workflows/14-stretch-slim.yml +++ b/.github/workflows/14-stretch-slim.yml @@ -18,7 +18,28 @@ jobs: build: name: 14 on stretch-slim runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 14 stretch-slim + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 14 stretch-slim ${{ matrix.arch }} diff --git a/.github/workflows/14-stretch.yml b/.github/workflows/14-stretch.yml index dfbfea496..43caa5d73 100644 --- a/.github/workflows/14-stretch.yml +++ b/.github/workflows/14-stretch.yml @@ -18,7 +18,28 @@ jobs: build: name: 14 on stretch runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh 14 stretch + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh 14 stretch ${{ matrix.arch }} diff --git a/functions.sh b/functions.sh index be9c57539..25b6b26bc 100755 --- a/functions.sh +++ b/functions.sh @@ -359,3 +359,51 @@ function tests_updated() { fi return 0 } + +function arch_to_buildx_platform() { + local arch + local platform + arch=$1 + shift + + case $arch in + amd64) + platform="amd64" + ;; + arm32v6) + platform="arm/v6" + ;; + arm32v7) + platform="arm/v7" + ;; + arm64v8) + platform="arm64" + ;; + i386) + platform="386" + ;; + ppc64le) + platform="ppc64le" + ;; + s390x) + platform="s390x" + ;; + *) + echo "$0 does not support architecture ${arch} ... aborting" + exit 1 + ;; + esac + + echo "${platform}" +} + +function json_array() { + echo -n '[' + while [ $# -gt 0 ]; do + x=${1//\\/\\\\} + echo -n \""${x//\"/\\\"}"\" + [ $# -gt 1 ] && echo -n ',' + shift + done + echo ']' +} diff --git a/test-build.sh b/test-build.sh index 6614725d3..682772007 100755 --- a/test-build.sh +++ b/test-build.sh @@ -11,6 +11,7 @@ set -euo pipefail # "10,12" becomes "10 12" and "slim,alpine" becomes "slim alpine" IFS=',' read -ra versions_arg <<< "${1:-}" IFS=',' read -ra variant_arg <<< "${2:-}" +IFS=',' read -ra arches_arg <<< "${3:-}" default_variant=$(get_config "./" "default_variant") @@ -18,6 +19,7 @@ function build() { local version local tag local variant + local platform local full_tag local path version="$1" @@ -26,13 +28,15 @@ function build() { shift tag="$1" shift + platform="$1" + shift full_tag=$(get_full_tag "${variant}" "${tag}") path=$(get_path "${version}" "${variant}") - info "Building ${full_tag}..." + info "Building ${full_tag} on ${platform}..." - if ! docker build --cpuset-cpus="0,1" -t node:"${full_tag}" "${path}"; then + if ! docker buildx build --load --platform "${platform}" -t node:"${full_tag}" "${path}"; then fatal "Build of ${full_tag} failed!" fi info "Build of ${full_tag} succeeded." @@ -41,6 +45,7 @@ function build() { function test_image() { local full_version local variant + local platform local tag local full_tag full_version="$1" @@ -49,25 +54,23 @@ function test_image() { shift tag="$1" shift + platform="$1" + shift full_tag=$(get_full_tag "${variant}" "${tag}") - info "Testing ${full_tag}" + info "Testing ${full_tag} on ${platform}" ( export full_version=${full_version} export full_tag=${full_tag} + export platform=${platform} bats test-image.bats ) } cd "$(cd "${0%/*}" && pwd -P)" || exit -IFS=' ' read -ra versions <<< "$(get_versions . "${versions_arg[@]}")" -if [ ${#versions[@]} -eq 0 ]; then - fatal "No valid versions found!" -fi - -for version in "${versions[@]}"; do +for version in "${versions_arg[@]}"; do # Skip "docs" and other non-docker directories [ -f "${version}/Dockerfile" ] || [ -a "${version}/${default_variant}/Dockerfile" ] || continue @@ -82,8 +85,13 @@ for version in "${versions[@]}"; do # Skip non-docker directories [ -f "${version}/${variant}/Dockerfile" ] || continue - build "${version}" "${variant}" "${tag}" - test_image "${full_version}" "${variant}" "${tag}" + for arch in "${arches_arg[@]}"; do + buildx_platform=$(arch_to_buildx_platform "${arch}") + + build "${version}" "${variant}" "${tag}" "linux/${buildx_platform}" + test_image "${full_version}" "${variant}" "${tag}" "linux/${buildx_platform}" + done + done done diff --git a/test-image.bats b/test-image.bats index b424b95a4..5eba95b2a 100755 --- a/test-image.bats +++ b/test-image.bats @@ -1,17 +1,17 @@ #!/usr/bin/env bats @test "Test for node and version" { - run docker run --rm node:"$full_tag" node -e "process.stdout.write(process.versions.node)" + run docker run --platform ${platform} --rm node:"$full_tag" node -e "process.stdout.write(process.versions.node)" [ "$status" -eq 0 ] [ "$output" == "${full_version}" ] } @test "Test for npm" { - run docker run --rm node:"$full_tag" npm --version + run docker run --platform ${platform} --rm node:"$full_tag" npm --version [ "$status" -eq 0 ] } @test "Test for yarn" { - run docker run --rm node:"$full_tag" yarn --version + run docker run --platform ${platform} --rm node:"$full_tag" yarn --version [ "$status" -eq 0 ] } diff --git a/update.sh b/update.sh index 8b66a6e55..72c539559 100755 --- a/update.sh +++ b/update.sh @@ -196,6 +196,9 @@ function add_stage() { local variant=${1} shift + IFS=' ' read -ra supportedArches <<< "$(get_supported_arches "${version}" "${variant}")" + read -r arch_json <<< "$(json_array "${supportedArches[@]}")" + echo "name: ${version} on ${variant} on: @@ -216,10 +219,31 @@ jobs: build: name: ${version} on ${variant} runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: \${{fromJson('{\"arch\":${arch_json}}')}} steps: - - uses: actions/checkout@v2 - - run: sudo apt-get install bats - - run: ./test-build.sh ${version} ${variant}" > ".github/workflows/${version}-${variant}.yml" + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Write experimental docker flag + run: | + echo '{\"experimental\": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Build and test + run: ./test-build.sh ${version} ${variant} \${{ matrix.arch }}" > ".github/workflows/${version}-${variant}.yml" } for version in "${versions[@]}"; do From ca5c494d0d437c62cda1a616b761164f17991114 Mon Sep 17 00:00:00 2001 From: Travis Shivers Date: Thu, 24 Sep 2020 21:58:22 -0500 Subject: [PATCH 2/2] ci: single test action --- .github/workflows/10-alpine3.10.yml | 45 ----------- .github/workflows/10-alpine3.11.yml | 45 ----------- .github/workflows/10-alpine3.9.yml | 45 ----------- .github/workflows/10-buster-slim.yml | 45 ----------- .github/workflows/10-buster.yml | 45 ----------- .github/workflows/10-stretch-slim.yml | 45 ----------- .github/workflows/10-stretch.yml | 45 ----------- .github/workflows/12-alpine3.10.yml | 45 ----------- .github/workflows/12-alpine3.11.yml | 45 ----------- .github/workflows/12-alpine3.12.yml | 45 ----------- .github/workflows/12-alpine3.9.yml | 45 ----------- .github/workflows/12-buster-slim.yml | 45 ----------- .github/workflows/12-buster.yml | 45 ----------- .github/workflows/12-stretch-slim.yml | 45 ----------- .github/workflows/12-stretch.yml | 45 ----------- .github/workflows/14-alpine3.10.yml | 45 ----------- .github/workflows/14-alpine3.11.yml | 45 ----------- .github/workflows/14-alpine3.12.yml | 45 ----------- .github/workflows/14-buster-slim.yml | 45 ----------- .github/workflows/14-buster.yml | 45 ----------- .github/workflows/14-stretch-slim.yml | 45 ----------- .github/workflows/14-stretch.yml | 45 ----------- .github/workflows/build-test.yml | 72 +++++++++++++++++ genMatrix.js | 111 ++++++++++++++++++++++++++ 24 files changed, 183 insertions(+), 990 deletions(-) delete mode 100644 .github/workflows/10-alpine3.10.yml delete mode 100644 .github/workflows/10-alpine3.11.yml delete mode 100644 .github/workflows/10-alpine3.9.yml delete mode 100644 .github/workflows/10-buster-slim.yml delete mode 100644 .github/workflows/10-buster.yml delete mode 100644 .github/workflows/10-stretch-slim.yml delete mode 100644 .github/workflows/10-stretch.yml delete mode 100644 .github/workflows/12-alpine3.10.yml delete mode 100644 .github/workflows/12-alpine3.11.yml delete mode 100644 .github/workflows/12-alpine3.12.yml delete mode 100644 .github/workflows/12-alpine3.9.yml delete mode 100644 .github/workflows/12-buster-slim.yml delete mode 100644 .github/workflows/12-buster.yml delete mode 100644 .github/workflows/12-stretch-slim.yml delete mode 100644 .github/workflows/12-stretch.yml delete mode 100644 .github/workflows/14-alpine3.10.yml delete mode 100644 .github/workflows/14-alpine3.11.yml delete mode 100644 .github/workflows/14-alpine3.12.yml delete mode 100644 .github/workflows/14-buster-slim.yml delete mode 100644 .github/workflows/14-buster.yml delete mode 100644 .github/workflows/14-stretch-slim.yml delete mode 100644 .github/workflows/14-stretch.yml create mode 100644 .github/workflows/build-test.yml create mode 100644 genMatrix.js diff --git a/.github/workflows/10-alpine3.10.yml b/.github/workflows/10-alpine3.10.yml deleted file mode 100644 index 84544a680..000000000 --- a/.github/workflows/10-alpine3.10.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 10 on alpine3.10 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/alpine3.10/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/alpine3.10/Dockerfile - -jobs: - build: - name: 10 on alpine3.10 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 10 alpine3.10 ${{ matrix.arch }} diff --git a/.github/workflows/10-alpine3.11.yml b/.github/workflows/10-alpine3.11.yml deleted file mode 100644 index 525148e02..000000000 --- a/.github/workflows/10-alpine3.11.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 10 on alpine3.11 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/alpine3.11/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/alpine3.11/Dockerfile - -jobs: - build: - name: 10 on alpine3.11 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 10 alpine3.11 ${{ matrix.arch }} diff --git a/.github/workflows/10-alpine3.9.yml b/.github/workflows/10-alpine3.9.yml deleted file mode 100644 index 229aba8ad..000000000 --- a/.github/workflows/10-alpine3.9.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 10 on alpine3.9 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/alpine3.9/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/alpine3.9/Dockerfile - -jobs: - build: - name: 10 on alpine3.9 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 10 alpine3.9 ${{ matrix.arch }} diff --git a/.github/workflows/10-buster-slim.yml b/.github/workflows/10-buster-slim.yml deleted file mode 100644 index c7c19f7aa..000000000 --- a/.github/workflows/10-buster-slim.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 10 on buster-slim - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/buster-slim/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/buster-slim/Dockerfile - -jobs: - build: - name: 10 on buster-slim - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 10 buster-slim ${{ matrix.arch }} diff --git a/.github/workflows/10-buster.yml b/.github/workflows/10-buster.yml deleted file mode 100644 index 774e413f8..000000000 --- a/.github/workflows/10-buster.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 10 on buster - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/buster/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/buster/Dockerfile - -jobs: - build: - name: 10 on buster - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 10 buster ${{ matrix.arch }} diff --git a/.github/workflows/10-stretch-slim.yml b/.github/workflows/10-stretch-slim.yml deleted file mode 100644 index e33577f77..000000000 --- a/.github/workflows/10-stretch-slim.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 10 on stretch-slim - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/stretch-slim/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/stretch-slim/Dockerfile - -jobs: - build: - name: 10 on stretch-slim - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 10 stretch-slim ${{ matrix.arch }} diff --git a/.github/workflows/10-stretch.yml b/.github/workflows/10-stretch.yml deleted file mode 100644 index 3c0648203..000000000 --- a/.github/workflows/10-stretch.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 10 on stretch - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/stretch/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 10/stretch/Dockerfile - -jobs: - build: - name: 10 on stretch - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 10 stretch ${{ matrix.arch }} diff --git a/.github/workflows/12-alpine3.10.yml b/.github/workflows/12-alpine3.10.yml deleted file mode 100644 index b7e3351d3..000000000 --- a/.github/workflows/12-alpine3.10.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 12 on alpine3.10 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/alpine3.10/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/alpine3.10/Dockerfile - -jobs: - build: - name: 12 on alpine3.10 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 12 alpine3.10 ${{ matrix.arch }} diff --git a/.github/workflows/12-alpine3.11.yml b/.github/workflows/12-alpine3.11.yml deleted file mode 100644 index 474f99c8f..000000000 --- a/.github/workflows/12-alpine3.11.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 12 on alpine3.11 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/alpine3.11/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/alpine3.11/Dockerfile - -jobs: - build: - name: 12 on alpine3.11 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 12 alpine3.11 ${{ matrix.arch }} diff --git a/.github/workflows/12-alpine3.12.yml b/.github/workflows/12-alpine3.12.yml deleted file mode 100644 index afe9cf22e..000000000 --- a/.github/workflows/12-alpine3.12.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 12 on alpine3.12 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/alpine3.12/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/alpine3.12/Dockerfile - -jobs: - build: - name: 12 on alpine3.12 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 12 alpine3.12 ${{ matrix.arch }} diff --git a/.github/workflows/12-alpine3.9.yml b/.github/workflows/12-alpine3.9.yml deleted file mode 100644 index ee9746fa0..000000000 --- a/.github/workflows/12-alpine3.9.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 12 on alpine3.9 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/alpine3.9/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/alpine3.9/Dockerfile - -jobs: - build: - name: 12 on alpine3.9 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 12 alpine3.9 ${{ matrix.arch }} diff --git a/.github/workflows/12-buster-slim.yml b/.github/workflows/12-buster-slim.yml deleted file mode 100644 index 03befbefd..000000000 --- a/.github/workflows/12-buster-slim.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 12 on buster-slim - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/buster-slim/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/buster-slim/Dockerfile - -jobs: - build: - name: 12 on buster-slim - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 12 buster-slim ${{ matrix.arch }} diff --git a/.github/workflows/12-buster.yml b/.github/workflows/12-buster.yml deleted file mode 100644 index 30e3389aa..000000000 --- a/.github/workflows/12-buster.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 12 on buster - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/buster/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/buster/Dockerfile - -jobs: - build: - name: 12 on buster - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 12 buster ${{ matrix.arch }} diff --git a/.github/workflows/12-stretch-slim.yml b/.github/workflows/12-stretch-slim.yml deleted file mode 100644 index c99d431fe..000000000 --- a/.github/workflows/12-stretch-slim.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 12 on stretch-slim - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/stretch-slim/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/stretch-slim/Dockerfile - -jobs: - build: - name: 12 on stretch-slim - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 12 stretch-slim ${{ matrix.arch }} diff --git a/.github/workflows/12-stretch.yml b/.github/workflows/12-stretch.yml deleted file mode 100644 index f45479c8f..000000000 --- a/.github/workflows/12-stretch.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 12 on stretch - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/stretch/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 12/stretch/Dockerfile - -jobs: - build: - name: 12 on stretch - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 12 stretch ${{ matrix.arch }} diff --git a/.github/workflows/14-alpine3.10.yml b/.github/workflows/14-alpine3.10.yml deleted file mode 100644 index f7477121f..000000000 --- a/.github/workflows/14-alpine3.10.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 14 on alpine3.10 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/alpine3.10/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/alpine3.10/Dockerfile - -jobs: - build: - name: 14 on alpine3.10 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 14 alpine3.10 ${{ matrix.arch }} diff --git a/.github/workflows/14-alpine3.11.yml b/.github/workflows/14-alpine3.11.yml deleted file mode 100644 index 9d6f879c7..000000000 --- a/.github/workflows/14-alpine3.11.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 14 on alpine3.11 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/alpine3.11/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/alpine3.11/Dockerfile - -jobs: - build: - name: 14 on alpine3.11 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 14 alpine3.11 ${{ matrix.arch }} diff --git a/.github/workflows/14-alpine3.12.yml b/.github/workflows/14-alpine3.12.yml deleted file mode 100644 index 79cd3f205..000000000 --- a/.github/workflows/14-alpine3.12.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 14 on alpine3.12 - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/alpine3.12/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/alpine3.12/Dockerfile - -jobs: - build: - name: 14 on alpine3.12 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v6","arm32v7","arm64v8","i386","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 14 alpine3.12 ${{ matrix.arch }} diff --git a/.github/workflows/14-buster-slim.yml b/.github/workflows/14-buster-slim.yml deleted file mode 100644 index bf37a88e7..000000000 --- a/.github/workflows/14-buster-slim.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 14 on buster-slim - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/buster-slim/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/buster-slim/Dockerfile - -jobs: - build: - name: 14 on buster-slim - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 14 buster-slim ${{ matrix.arch }} diff --git a/.github/workflows/14-buster.yml b/.github/workflows/14-buster.yml deleted file mode 100644 index 061a4fdab..000000000 --- a/.github/workflows/14-buster.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 14 on buster - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/buster/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/buster/Dockerfile - -jobs: - build: - name: 14 on buster - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8","ppc64le","s390x"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 14 buster ${{ matrix.arch }} diff --git a/.github/workflows/14-stretch-slim.yml b/.github/workflows/14-stretch-slim.yml deleted file mode 100644 index d9e1e9a66..000000000 --- a/.github/workflows/14-stretch-slim.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 14 on stretch-slim - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/stretch-slim/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/stretch-slim/Dockerfile - -jobs: - build: - name: 14 on stretch-slim - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 14 stretch-slim ${{ matrix.arch }} diff --git a/.github/workflows/14-stretch.yml b/.github/workflows/14-stretch.yml deleted file mode 100644 index 43caa5d73..000000000 --- a/.github/workflows/14-stretch.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 14 on stretch - -on: - push: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/stretch/Dockerfile - pull_request: - paths: - - functions.sh - - test-build.sh - - test-image.bats - - 14/stretch/Dockerfile - -jobs: - build: - name: 14 on stretch - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: ${{fromJson('{"arch":["amd64","arm32v7","arm64v8"]}')}} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install bats - run: sudo apt-get install bats - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Write experimental docker flag - run: | - echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json - - - name: Restart docker daemon - run: sudo systemctl restart docker - - - name: Build and test - run: ./test-build.sh 14 stretch ${{ matrix.arch }} diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 000000000..8cedd1bf3 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,72 @@ +name: test-build + +on: + push: + pull_request: + +jobs: + gen-matrix: + name: generate-matrix + runs-on: ubuntu-latest + + steps: + - name: Calculate file differences + uses: lots0logs/gh-action-get-changed-files@2.1.4 + id: diff + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout + uses: actions/checkout@v2 + + - name: Generate testing matrix + uses: actions/github-script@v3 + id: generator + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const script = require(`${process.env.GITHUB_WORKSPACE}/genMatrix.js`) + return script( + ${{ steps.diff.outputs.added }}, + ${{ steps.diff.outputs.modified }}, + ${{ steps.diff.outputs.renamed }}, + ); + + - name: Matrix + run: echo "${{ toJson(steps.generator.outputs.result) }}" + + outputs: + matrix: ${{ steps.generator.outputs.result }} + + build: + if: ${{ fromJson(needs.gen-matrix.outputs.matrix) }} + needs: gen-matrix + name: build + runs-on: ubuntu-latest + timeout-minutes: 600 + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install bats + run: sudo apt-get install bats + + - name: Write experimental docker flag + run: | + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + + - name: Restart docker daemon + run: sudo systemctl restart docker + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and test + run: ./test-build.sh ${{ matrix.version }} ${{ matrix.variant }} ${{ matrix.arch }} diff --git a/genMatrix.js b/genMatrix.js new file mode 100644 index 000000000..77882b333 --- /dev/null +++ b/genMatrix.js @@ -0,0 +1,111 @@ +const path = require('path'); +const fs = require('fs'); + +const testFiles = [ + 'functions.sh', + 'test-build.sh', + 'test-image.bats', +]; + +const nodeDirRegex = /^\d+$/; + +const areTestFilesChanged = (changedFiles) => changedFiles + .filter((file) => testFiles.includes(file)).length; + +// Returns a list of the child directories in the given path +const getChildDirectories = (parent) => fs.readdirSync(parent, { withFileTypes: true }) + .filter((dirent) => dirent.isDirectory()) + .map(({ name }) => path.resolve(parent, name)); + + +const getNodeVerionDirs = (base) => getChildDirectories(base) + .filter((childPath) => nodeDirRegex.test(path.basename(childPath))); + +// Returns the paths of Dockerfiles that are at: base/*/Dockerfile +const getDockerfilesInChildDirs = (base) => getChildDirectories(base) + .map((childDir) => path.resolve(childDir, 'Dockerfile')); + +const getAllDockerfiles = (base) => getNodeVerionDirs(base).flatMap(getDockerfilesInChildDirs); + +// Get the Dockerfiles affected by the architectures file +const getArchAffectedDockerfiles = (archFile) => getDockerfilesInChildDirs(path.dirname(archFile)); + +const getAffectedDockerfiles = (filesAdded, filesModified, filesRenamed) => { + const files = [ + ...filesAdded, + ...filesModified, + ...filesRenamed, + ]; + + // If the test files were changed, include everything + if (areTestFilesChanged(files)) { + console.log('Test files changed so scheduling all Dockerfiles'); + return getAllDockerfiles(__dirname); + } + + const dockerfiles = files.filter((file) => file.endsWith('/Dockerfile')); + + // Look Dockerfiles affected by changed architectures files + const archAffectedFiles = files.filter((file) => file.endsWith('/architectures')) + .flatMap(getArchAffectedDockerfiles); + + return [ + ...dockerfiles, + ...archAffectedFiles, + ]; +}; + +// Parses an arch line like: +// amd64 stretch,stretch-slim +// Into ["amd64", ["stretch", "stretch-slim"]] +const parseArchLine = (line) => { + const [arch, rawVariants] = line.split(/\s+/); + const variants = rawVariants.split(','); + + return [ + arch, + variants + ]; +}; + +// Parses an architectures file into an object like: +// { +// "amd64": ["stretch", "stretch-slim"], +// // .... +// } +const parseArchFile = (file) => Object.fromEntries( + fs.readFileSync(file, { encoding: 'utf8' }) + .split('\n') + .slice(1) + .filter((line) => line) + .map(parseArchLine), +); + +// Given a Dockerfile path, this function returns an array of the supported arches +const getDockerfileArches = (file, variant) => { + const archVariants = parseArchFile(path.resolve(path.dirname(file), '../architectures')); + return Object.keys(archVariants).filter((arch) => archVariants[arch].includes(variant)); +}; + +const getDockerfileMatrixEntries = (file) => { + const [version, variant] = path.dirname(file).split(path.sep).slice(-2); + const supportedArches = getDockerfileArches(file, variant); + + return supportedArches.map((arch) => ({ + version, + variant, + arch, + })); +}; + +const generateBuildMatrix = (filesAdded, filesModified, filesRenamed) => { + // The Dockerfile paths contain the version in variant. + const dockerfiles = [...new Set(getAffectedDockerfiles(filesAdded, filesModified, filesRenamed))]; + + const entries = dockerfiles.flatMap(getDockerfileMatrixEntries); + return entries.length + ? { include: entries } + : null; +}; + +module.exports = generateBuildMatrix;