forked from MiczFlor/RPi-Jukebox-RFID
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9252ad1
commit 734663a
Showing
2 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: Test Install Scripts Debian Unified | ||
|
||
# let only one instance run the test so cache is not corrupted. | ||
# cancel already running instances as only the last run will be relevant | ||
concurrency: | ||
group: ${{ github.ref }}-debian-unified | ||
cancel-in-progress: true | ||
|
||
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 | ||
_PATH_DOCKER_IMAGE: ./rpi-jukebox-rfid | ||
_PATH_DOCKER_IMAGE_SUFFIX: .tar | ||
CACHE_SCOPE: ${{ github.ref }}-debian-unified | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
debian_version: [bullseye, buster] | ||
|
||
# outputs: | ||
# base_image_tag_name: ${{ steps.step-output.outputs.base_image_tag_name }} | ||
|
||
steps: | ||
# - name: Set step output | ||
# id: step-output | ||
# run: | | ||
# echo "base_image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:" >> $GITHUB_OUTPUT | ||
|
||
# - name: Set step env | ||
# id: step-env | ||
# run: | | ||
# echo "base_image_tag_ebian=${{ steps.step-output.outputs.base_image_tag_name }}:${{ matrix.debian_version }}" >> $GITHUB_OUTPUT | ||
# echo "cache_scope_debian=${{ env.CACHE_SCOPE }}-${{ matrix.debian_version }}" >> $GITHUB_ENV | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/[email protected] | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Build Debian ARMv7 - Base | ||
id: docker-build-base | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
load: false | ||
push: false | ||
file: ./ci/Dockerfile.debian.test_install_unified.armv7 | ||
target: user | ||
platforms: linux/arm/v7 | ||
tags: "${{ env.DOCKER_IMAGE_NAME }}:${{ matrix.debian_version }}-test-base" | ||
cache-from: type=gha,scope=${{ env.CACHE_SCOPE }}-${{ matrix.debian_version }} | ||
cache-to: type=gha,mode=max,scope=${{ env.CACHE_SCOPE }}-${{ matrix.debian_version }} | ||
build-args: | | ||
DEBIAN_VERSION=${{ matrix.debian_version }} | ||
- name: Build Debian ARMv7 - Update | ||
id: docker-build-update | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
load: false | ||
push: false | ||
file: ./ci/Dockerfile.debian.test_install_unified.armv7 | ||
target: test-update | ||
platforms: linux/arm/v7 | ||
tags: "${{ env.DOCKER_IMAGE_NAME }}:${{ matrix.debian_version }}-test" | ||
cache-from: type=gha,scope=${{ env.CACHE_SCOPE }}-${{ matrix.debian_version }} | ||
# DON'T use 'cache-to' here as then the layer is cached and this build would be useless | ||
outputs: type=docker,dest=${{ env._PATH_DOCKER_IMAGE }}-${{ matrix.debian_version }}${{ env._PATH_DOCKER_IMAGE_SUFFIX }} | ||
build-args: | | ||
GIT_BRANCH=${{ github.ref_name }} | ||
GIT_URL=${{ github.server_url }}/${{ github.repository }} | ||
- name: Cache Check Docker Image | ||
uses: actions/cache/restore@v3 | ||
id: cache-restore | ||
with: | ||
lookup-only: true | ||
key: ${{ env.DOCKER_IMAGE_NAME }}-${{ github.sha }}-${{ github.run_id }} | ||
path: ${{ env._PATH_DOCKER_IMAGE }}-${{ matrix.debian_version }}${{ env._PATH_DOCKER_IMAGE_SUFFIX }} | ||
|
||
- name: Cache Save Docker Image | ||
uses: actions/cache/save@v3 | ||
if: ${{ ! steps.cache-restore.outputs.cache-hit }} | ||
with: | ||
key: ${{ steps.cache-restore.outputs.cache-primary-key }} | ||
path: ${{ env._PATH_DOCKER_IMAGE }}-${{ matrix.debian_version }}${{ env._PATH_DOCKER_IMAGE_SUFFIX }} | ||
|
||
|
||
test: | ||
needs: prepare | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
debian_version: [bullseye, buster] | ||
test_Script: [run_installation_tests.sh, run_installation_tests2.sh, run_installation_tests3.sh] | ||
username: [pi, hans] | ||
|
||
steps: | ||
- name: Set up QEMU | ||
uses: docker/[email protected] | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Cache Restore Docker Image | ||
uses: actions/cache/restore@v3 | ||
with: | ||
key: ${{ env.DOCKER_IMAGE_NAME }}-${{ github.sha }}-${{ github.run_id }} | ||
path: ${{ env._PATH_DOCKER_IMAGE }}-${{ matrix.debian_version }}${{ env._PATH_DOCKER_IMAGE_SUFFIX }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Load Docker Image | ||
run: | | ||
docker load --input ${{ env._PATH_DOCKER_IMAGE }}-${{ matrix.debian_version }}${{ env._PATH_DOCKER_IMAGE_SUFFIX }} | ||
- name: Run ${{ matrix.debian_version }}-${{ matrix.username }}-${{ matrix.test_Script }} | ||
uses: tj-actions/docker-run@v2 | ||
with: | ||
image: "${{ env.DOCKER_IMAGE_NAME }}:${{ matrix.debian_version }}-test" | ||
options: --platform linux/arm/v7 --user ${{ matrix.username }} | ||
name: ${{ matrix.test_Script }} | ||
args: | | ||
./${{ matrix.test_Script }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Target to build and install all needed base configuration and packages | ||
ARG DEBIAN_VERSION=bullseye | ||
FROM debian:${DEBIAN_VERSION}-slim as base | ||
ARG DEBIAN_VERSION | ||
|
||
ENV DOCKER_RUNNING=true | ||
RUN touch /boot/cmdlinetxt | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update \ | ||
&& apt-get -y install \ | ||
apt-utils \ | ||
curl \ | ||
gnupg \ | ||
&& echo "deb http://raspbian.raspberrypi.org/raspbian/ ${DEBIAN_VERSION} main contrib non-free rpi" > /etc/apt/sources.list.d/raspi.list \ | ||
&& echo "deb http://archive.raspberrypi.org/debian/ ${DEBIAN_VERSION} 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 upgrade \ | ||
&& apt-get -y install \ | ||
build-essential \ | ||
git \ | ||
iw \ | ||
locales \ | ||
sudo \ | ||
systemd \ | ||
wget \ | ||
wpasupplicant \ | ||
# install internally used packages here to speed up GitHub Action | ||
raspberrypi-kernel \ | ||
raspberrypi-kernel-headers \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# ------ | ||
|
||
|
||
# Target for setting up user for test. user can be selected with the docker '--user $USERNAME' option | ||
FROM base as user | ||
ENV TEST_USER_GROUP=test | ||
|
||
# Group used for assigning file permissions | ||
RUN groupadd --gid 1002 $TEST_USER_GROUP | ||
|
||
RUN export USER_PI=pi \ | ||
&& export USER_PI_GROUP=$USER_PI \ | ||
&& groupadd --gid 1000 $USER_PI_GROUP \ | ||
&& useradd -u 1000 -g $USER_PI_GROUP -G sudo,$TEST_USER_GROUP -d /home/$USER_PI -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER_PI \ | ||
&& echo "$USER_PI ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER_PI | ||
|
||
RUN export USER_ALT=hans \ | ||
&& export USER_ALT_GROUP=wurst \ | ||
&& groupadd --gid 1001 $USER_ALT_GROUP \ | ||
&& useradd -u 1001 -g $USER_ALT_GROUP -G sudo,$TEST_USER_GROUP -d /home/$USER_ALT -m -s /bin/bash -p '$1$iV7TOwOe$6ojkJQXyEA9bHd/SqNLNj0' $USER_ALT \ | ||
&& echo "$USER_ALT ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER_ALT | ||
# ------ | ||
|
||
|
||
# Target for adding envs and scripts from the repo to test installation | ||
FROM user as test | ||
ARG GIT_BRANCH | ||
ARG GIT_URL | ||
|
||
ENV GIT_BRANCH=$GIT_BRANCH GIT_URL=$GIT_URL | ||
|
||
COPY --chown=root:$TEST_USER_GROUP --chmod=770 scripts/installscripts/buster-install-default.sh . | ||
WORKDIR /tests | ||
COPY --chown=root:$TEST_USER_GROUP --chmod=770 scripts/installscripts/tests/*.sh . | ||
# ------ | ||
|
||
|
||
# Target for applying latest updates (should not be cached!) | ||
FROM test as test-update | ||
RUN apt-get update \ | ||
&& apt-get -y upgrade \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# ------ |