Test base image in local registry #9
Workflow file for this run
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
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 | |
CACHE_SCOPE: ${{ github.ref }}-debian-unified | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
runs_on: ubuntu-latest | |
# Definition of the matrix values for the subsequent jobs | |
matrix_debian_version: "['bullseye', 'buster']" | |
matrix_username: "['hans']" #"['pi', 'hans']" | |
matrix_test_script: "['run_installation_tests.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh']" | |
cache_scope: ${{ steps.set-cache_scope.outputs.cache_scope }} | |
image_tag_name: ${{ steps.set-image_tag_name.outputs.image_tag_name }} | |
image_file_path: ${{ steps.set-image_file_path.outputs.image_file_path }} | |
cache_key: ${{ steps.set-cache_key.outputs.cache_key }} | |
steps: | |
- name: Set Output cache_scope | |
id: set-cache_scope | |
run: echo "cache_scope=${{ env.CACHE_SCOPE }}-{0}" >> $GITHUB_OUTPUT | |
- name: Set Output image_tag_name | |
id: set-image_tag_name | |
run: echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:{0}-test" >> $GITHUB_OUTPUT | |
- name: Set Output image_file_path | |
id: set-image_file_path | |
run: echo "image_file_path=./${{ env.DOCKER_IMAGE_NAME }}-{0}.tar" >> $GITHUB_OUTPUT | |
- name: Set Output cache_key | |
id: set-cache_key | |
run: echo "cache_key=${{ steps.set-cache_scope.outputs.cache_scope }}-${{ github.sha }}#${{ github.run_attempt }}" >> $GITHUB_OUTPUT | |
build: | |
needs: [prepare] | |
runs-on: ${{ needs.prepare.outputs.runs_on }} | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
strategy: | |
fail-fast: false | |
matrix: | |
debian_version: ${{ fromJSON(needs.prepare.outputs.matrix_debian_version) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
with: | |
# network=host driver-opt needed to push to local registry | |
driver-opts: network=host | |
- name: Build Image ARMv7 - Base | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: false | |
push: true | |
file: ./ci/Dockerfile.debian.test_install_unified.armv7 | |
target: test | |
platforms: linux/arm/v7 | |
tags: localhost:5000/${{ format( needs.prepare.outputs.image_tag_name, matrix.debian_version) }}-base | |
cache-from: type=gha,scope=${{ format( needs.prepare.outputs.cache_scope, matrix.debian_version) }} | |
cache-to: type=gha,mode=max,scope=${{ format( needs.prepare.outputs.cache_scope, matrix.debian_version) }} | |
build-args: | | |
DEBIAN_VERSION=${{ matrix.debian_version }} | |
GIT_BRANCH=${{ github.ref_name }} | |
GIT_URL=${{ github.server_url }}/${{ github.repository }} | |
- name: Build Image ARMv7 - 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: ${{ format( needs.prepare.outputs.image_tag_name, matrix.debian_version) }} | |
cache-from: type=gha,scope=${{ format( needs.prepare.outputs.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=${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }} | |
build-args: | | |
BASE_TEST_IMAGE="localhost:5000/${{ format( needs.prepare.outputs.image_tag_name, matrix.debian_version) }}-base" | |
- name: Cache Check Docker Image | |
uses: actions/cache/restore@v3 | |
id: cache-restore | |
with: | |
lookup-only: true | |
key: ${{ format( needs.prepare.outputs.cache_key, matrix.debian_version) }} | |
path: ${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }} | |
- 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: ${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }} | |
test: | |
needs: [prepare, build] | |
runs-on: ${{ needs.prepare.outputs.runs_on }} | |
strategy: | |
fail-fast: false | |
matrix: | |
debian_version: ${{ fromJSON(needs.prepare.outputs.matrix_debian_version) }} | |
username: ${{ fromJSON(needs.prepare.outputs.matrix_username) }} | |
test_script: ${{ fromJSON(needs.prepare.outputs.matrix_test_script) }} | |
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: ${{ format( needs.prepare.outputs.cache_key, matrix.debian_version) }} | |
path: ${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }} | |
fail-on-cache-miss: true | |
- name: Load Docker Image | |
run: | | |
docker load --input ${{ format( needs.prepare.outputs.image_file_path, matrix.debian_version) }} | |
- name: Run Test ${{ matrix.debian_version }}-${{ matrix.username }}-${{ matrix.test_script }} | |
uses: tj-actions/docker-run@v2 | |
with: | |
image: ${{ format( needs.prepare.outputs.image_tag_name, matrix.debian_version) }} | |
options: --platform linux/arm/v7 --user ${{ matrix.username }} | |
name: ${{ matrix.test_script }} | |
args: | | |
./${{ matrix.test_script }} |