From f2fb220405d8f6a08c6ff97f6ae889f28dacc1e9 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Sat, 14 Oct 2023 23:28:08 +0200 Subject: [PATCH] Try different strategies with matrix --- .github/workflows/docker_bullseye_cache.yml | 98 ++++++++++++++++++++ .github/workflows/docker_bullseye_target.yml | 95 +++++++++++++++++++ .github/workflows/docker_bullseye_upload.yml | 97 +++++++++++++++++++ ci/Dockerfile.bullseye.base_install.armv7 | 36 +++++++ ci/Dockerfile.bullseye.user_install.armv7 | 20 ++++ 5 files changed, 346 insertions(+) create mode 100644 .github/workflows/docker_bullseye_cache.yml create mode 100644 .github/workflows/docker_bullseye_target.yml create mode 100644 .github/workflows/docker_bullseye_upload.yml create mode 100644 ci/Dockerfile.bullseye.base_install.armv7 create mode 100644 ci/Dockerfile.bullseye.user_install.armv7 diff --git a/.github/workflows/docker_bullseye_cache.yml b/.github/workflows/docker_bullseye_cache.yml new file mode 100644 index 000000000..e22ad121f --- /dev/null +++ b/.github/workflows/docker_bullseye_cache.yml @@ -0,0 +1,98 @@ +name: Test Install Scripts Cache + +on: +# schedule: +# # run at 5 every sunday +# - cron: '0 5 * * 0' + push: + branches-ignore: + - 'future3/**' +# pull_request: +# # The branches below must be a subset of the branches above +# branches: [ develop ] + workflow_dispatch: + +env: + DOCKER_IMAGE_NAME: rpi-jukebox-rfid-bullseye-altuser + TEMP_DOCKER_PATH: /tmp/ + CACHE_KEY_SUFFIX: -${{ github.sha }}-${{ github.run_attempt }} + +jobs: + + prepare: + + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Build Bullseye ARMv7 + uses: docker/build-push-action@v5 + with: + context: . + load: true + push: false + file: ./ci/Dockerfile.bullseye.test_install.armv7 + platforms: linux/arm/v7 + tags: ${{ env.DOCKER_IMAGE_NAME }}:cache + cache-from: type=gha,scope=${{ github.ref_name }}-cache + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-cache + outputs: type=docker,dest=${{ env.TEMP_DOCKER_PATH }}${{ env.DOCKER_IMAGE_NAME }}.tar + build-args: | + USER_NAME=hans + USER_GROUP=wurst + GIT_BRANCH=${{ github.ref_name }} + GIT_URL=${{ github.server_url }}/${{ github.repository }} + + - name: Cache Save Docker Image + uses: actions/cache/save@v3 + with: + path: ${{ env.TEMP_DOCKER_PATH }}${{ env.DOCKER_IMAGE_NAME }}.tar + key: ${{ env.DOCKER_IMAGE_NAME }}${{ env.CACHE_KEY_SUFFIX }} + + + test: + + needs: prepare + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + test_Script: [run_installation_tests.sh, run_installation_tests2.sh, run_installation_tests3.sh] + + steps: + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Cache Restore Docker Image + uses: actions/cache/restore@v3 + with: + path: ${{ env.TEMP_DOCKER_PATH }}${{ env.DOCKER_IMAGE_NAME }}.tar + key: ${{ env.DOCKER_IMAGE_NAME }}${{ env.CACHE_KEY_SUFFIX }} + fail-on-cache-miss: true + + - name: Load Docker Image + run: | + docker load --input ${{ env.TEMP_DOCKER_PATH }}${{ env.DOCKER_IMAGE_NAME }}.tar + + - name: Run ${{ matrix.test_Script }} Bullseye ARMv7 + uses: tj-actions/docker-run@v2 + with: + image: ${{ env.DOCKER_IMAGE_NAME }}:cache + options: --platform linux/arm/v7 + name: ${{ matrix.test_Script }} + args: | + ./${{ matrix.test_Script }} diff --git a/.github/workflows/docker_bullseye_target.yml b/.github/workflows/docker_bullseye_target.yml new file mode 100644 index 000000000..e84e62eb7 --- /dev/null +++ b/.github/workflows/docker_bullseye_target.yml @@ -0,0 +1,95 @@ +name: Test Install Scripts Target + +on: +# schedule: +# # run at 5 every sunday +# - cron: '0 5 * * 0' + push: + branches-ignore: + - 'future3/**' +# pull_request: +# # The branches below must be a subset of the branches above +# branches: [ develop ] + workflow_dispatch: + +env: + DOCKER_IMAGE_NAME: rpi-jukebox-rfid-bullseye-altuser + + + +jobs: + + prepare: + + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Build Bullseye ARMv7 + uses: docker/build-push-action@v5 + with: + context: . + load: true + push: false + file: ./ci/Dockerfile.bullseye.base_install.armv7 + platforms: linux/arm/v7 + tags: ${{ env.DOCKER_IMAGE_NAME }}_base:cache + cache-from: type=gha,scope=${{ github.ref_name }}-target + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-target + build-args: | + GIT_BRANCH=${{ github.ref_name }} + GIT_URL=${{ github.server_url }}/${{ github.repository }} + + + test: + + needs: prepare + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + test_Script: [run_installation_tests.sh, run_installation_tests2.sh, run_installation_tests3.sh] + + steps: + + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Build Bullseye ARMv7 + uses: docker/build-push-action@v5 + with: + context: . + load: true + push: false + file: ./ci/Dockerfile.bullseye.user_install.armv7 + platforms: linux/arm/v7 + tags: ${{ env.DOCKER_IMAGE_NAME }}_user:cache + cache-from: type=gha,scope=${{ github.ref_name }}-target + build-args: | + BASEIMAGE=${{ env.DOCKER_IMAGE_NAME }}_base + USER_NAME=hans + USER_GROUP=wurst + + - name: Run ${{ matrix.test_Script }} Bullseye ARMv7 + uses: tj-actions/docker-run@v2 + with: + image: ${{ env.DOCKER_IMAGE_NAME }}_user:cache + options: --platform linux/arm/v7 + name: ${{ matrix.test_Script }} + args: | + ./${{ matrix.test_Script }} diff --git a/.github/workflows/docker_bullseye_upload.yml b/.github/workflows/docker_bullseye_upload.yml new file mode 100644 index 000000000..b8f831db9 --- /dev/null +++ b/.github/workflows/docker_bullseye_upload.yml @@ -0,0 +1,97 @@ +name: Test Install Scripts Upload + +on: +# schedule: +# # run at 5 every sunday +# - cron: '0 5 * * 0' + push: + branches-ignore: + - 'future3/**' +# pull_request: +# # The branches below must be a subset of the branches above +# branches: [ develop ] + workflow_dispatch: + +env: + DOCKER_IMAGE_NAME: rpi-jukebox-rfid-bullseye-altuser + TEMP_DOCKER_PATH: /tmp/ + + +jobs: + + prepare: + + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Build Bullseye ARMv7 + uses: docker/build-push-action@v5 + with: + context: . + load: true + push: false + file: ./ci/Dockerfile.bullseye.test_install.armv7 + platforms: linux/arm/v7 + tags: ${{ env.DOCKER_IMAGE_NAME }}:cache + cache-from: type=gha,scope=${{ github.ref_name }}-upload + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-upload + outputs: type=docker,dest=${{ env.TEMP_DOCKER_PATH }}${{ env.DOCKER_IMAGE_NAME }}.tar + build-args: | + USER_NAME=hans + USER_GROUP=wurst + GIT_BRANCH=${{ github.ref_name }} + GIT_URL=${{ github.server_url }}/${{ github.repository }} + + - name: Upload Docker Build Image + uses: actions/upload-artifact@v3 + with: + name: ${{ env.DOCKER_IMAGE_NAME }}.tar + path: ${{ env.TEMP_DOCKER_PATH }}${{ env.DOCKER_IMAGE_NAME }}.tar + + + test: + + needs: prepare + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + test_Script: [run_installation_tests.sh, run_installation_tests2.sh, run_installation_tests3.sh] + + steps: + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Download Docker Build Image + uses: actions/download-artifact@v3 + with: + name: ${{ env.DOCKER_IMAGE_NAME }}.tar + path: ${{ env.TEMP_DOCKER_PATH }} + + - name: Load Docker Build Image + run: | + docker load --input ${{ env.TEMP_DOCKER_PATH }}${{ env.DOCKER_IMAGE_NAME }}.tar + + - name: Run ${{ matrix.test_Script }} Bullseye ARMv7 + uses: tj-actions/docker-run@v2 + with: + image: ${{ env.DOCKER_IMAGE_NAME }}:cache + options: --platform linux/arm/v7 + name: ${{ matrix.test_Script }} + args: | + ./${{ matrix.test_Script }} diff --git a/ci/Dockerfile.bullseye.base_install.armv7 b/ci/Dockerfile.bullseye.base_install.armv7 new file mode 100644 index 000000000..2e497e228 --- /dev/null +++ b/ci/Dockerfile.bullseye.base_install.armv7 @@ -0,0 +1,36 @@ +FROM --platform=linux/arm/v7 arm32v7/debian:bullseye-slim as base + +# Define constants +ENV DOCKER_RUNNING=true DEBIAN_FRONTEND=noninteractive +RUN touch /boot/cmdlinetxt + +# Define Git Repo variables. If this changes all should be build again +ARG GIT_BRANCH +ARG GIT_URL + +ENV GIT_BRANCH=$GIT_BRANCH GIT_URL=$GIT_URL + +# Install packages +RUN apt-get update && \ + apt-get -y install \ + apt-utils \ + curl \ + gnupg + +RUN echo 'deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi' > /etc/apt/sources.list.d/raspi.list ;\ + echo 'deb http://archive.raspberrypi.org/debian/ bullseye main' >> /etc/apt/sources.list.d/raspi.list ;\ + curl http://raspbian.raspberrypi.org/raspbian.public.key | apt-key add - ;\ + curl http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add - ;\ + apt-get update && \ + apt-get -y install \ + build-essential \ + git \ + iw \ + locales \ + # install here to speed up GitHub Action + raspberrypi-kernel-headers \ + sudo \ + systemd \ + wget \ + wpasupplicant ;\ + rm -rf /var/lib/apt/lists/* diff --git a/ci/Dockerfile.bullseye.user_install.armv7 b/ci/Dockerfile.bullseye.user_install.armv7 new file mode 100644 index 000000000..09d2ca825 --- /dev/null +++ b/ci/Dockerfile.bullseye.user_install.armv7 @@ -0,0 +1,20 @@ +ARG BASEIMAGE +FROM $BASEIMAGE:cache as user + +# Define user info that my change, but are irrelevant for package installation +ARG USER_NAME=pi +ARG USER_GROUP=$USER_NAME +ENV USER=$USER_NAME + +RUN groupadd --gid 1000 $USER_GROUP && \ + useradd -u 1000 -g 1000 -G sudo -d /home/$USER -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER && \ + echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER + +USER $USER + +# Define needed files for installation test +COPY --chown=$USER:$USER_GROUP --chmod=750 scripts/installscripts/tests/*.sh /tests/ +COPY --chown=$USER:$USER_GROUP --chmod=750 scripts/installscripts/buster-install-default.sh / + +WORKDIR /tests +