diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d582dc..954aeae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,11 +5,11 @@ on: branches: - main schedule: - - cron: "0 5 * * *" + - cron: "0 1 * * 1" jobs: build: - name: Build Container + name: Build and Push Container runs-on: ubuntu-latest strategy: matrix: @@ -21,9 +21,6 @@ jobs: - name: Docker info run: docker info - - - name: Docker Builder - run: docker buildx ls - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -32,23 +29,25 @@ jobs: uses: docker/setup-buildx-action@v3 with: platforms: linux/amd64,linux/arm64 - - name: Setup BATS + - + name: Setup BATS uses: mig4/setup-bats@v1 with: - bats-version: 1.2.1 - - - name: Check out code + bats-version: 1.11.0 + - + name: Check out code uses: actions/checkout@v1 - - - name: "Test ddev ${{ matrix.version }} image" + - + name: "Test ddev ${{ matrix.version }} image" shell: 'script -q -e -c "bash {0}"' run: | + sudo snap install yq ./build.sh -v ${{ matrix.version }} -l DDEV_VERSION=${{ matrix.version }} bash bats tests - - name: "ddev ${{ matrix.version }}" + name: "Build ddev ${{ matrix.version }} multi-arch image" shell: 'script -q -e -c "bash {0}"' run: | echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin docker buildx create --use --platform=linux/arm64,linux/amd64 - ./build.sh -v ${{ matrix.version }} -p + ./build.sh -v ${{ matrix.version }} -x -p diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2179401..211204c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ on: - '!main' jobs: build: - name: Build Container + name: Build and Test Container runs-on: ubuntu-latest strategy: matrix: @@ -20,9 +20,6 @@ jobs: - name: Docker info run: docker info - - - name: Docker Builder - run: docker buildx ls - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -31,9 +28,6 @@ jobs: uses: docker/setup-buildx-action@v3 with: platforms: linux/amd64,linux/arm64 - - - name: Setup yq - uses: mikefarah/yq@master - name: Setup BATS uses: mig4/setup-bats@v1 @@ -46,5 +40,6 @@ jobs: name: "Test ddev ${{ matrix.version }} image" shell: 'script -q -e -c "bash {0}"' run: | + sudo snap install yq ./build.sh -v ${{ matrix.version }} -l DDEV_VERSION=${{ matrix.version }} bash bats tests diff --git a/build.sh b/build.sh index f6fdf0d..5fba3b1 100755 --- a/build.sh +++ b/build.sh @@ -15,6 +15,7 @@ help() { echo " * v - DDEV version e.g. 'v1.23.1'" echo " * l - Load the image (--load)" echo " * p - Push the image (--push)" + echo " * x - Build multi-arch image (--platform linux/amd64,linux/arm64)" } loadVersionAndTags() { @@ -49,7 +50,7 @@ loadVersionAndTags() { fi } -while getopts ":v:hpl" opt; do +while getopts ":v:hplx" opt; do case $opt in h) help @@ -64,6 +65,9 @@ while getopts ":v:hpl" opt; do l) LOAD="--load" ;; + x) + PLATFORM="--platform linux/amd64,linux/arm64" + ;; *) echo "Invalid option: -$OPTARG" help @@ -74,9 +78,4 @@ done loadVersionAndTags -docker buildx build --platform linux/amd64,linux/arm64 --progress plain --no-cache --pull . -f Dockerfile ${DOCKER_TAGS[@]} --build-arg ddev_version="$DDEV_VERSION" $PUSH $LOAD - -if [ $LOAD ]; then - docker run --rm -it -v "$(pwd)/test.sh:/tmp/test.sh" --entrypoint "ash" "$IMAGE_NAME:$DDEV_VERSION" /tmp/test.sh -fi - +docker buildx build ${PLATFORM} --progress plain --no-cache --pull . -f Dockerfile ${DOCKER_TAGS[@]} --build-arg ddev_version="$DDEV_VERSION" $PUSH $LOAD diff --git a/tests/test.bats b/tests/test.bats index 0b52f99..bcb98e2 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -13,7 +13,7 @@ @test "See ddev version" { run docker-run "ddev version -j" - version=$(echo "$output" | head -2 | tail -1 | yq '.raw.["DDEV version"]') + version=$(echo "$output" | tail -n 1 | yq '.raw.["DDEV version"]') regex='^v([0-9]+)\.([0-9]+)\.([0-9]+)$' [[ $version =~ $regex ]] @@ -71,6 +71,6 @@ docker-run() { local COMMAND=${1} - # @todo: Pass in the current version + docker run --rm -it --network ddev-docker ghcr.io/ochorocho/ddev-gitlab-ci:"${DDEV_VERSION}" /bin/sh -c "${COMMAND}" }