From 2ceef1b60ce6f90ea4b130f4c81ebfeb32f67344 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:00:21 +0100 Subject: [PATCH] update workflow with improvements from v3 (#2246) * update workflow with improvements from v3 * dont run all tests for user "hans" * fix order for readability --- .github/workflows/test_docker_debian.yml | 57 ++++++++++++++----- .../test_docker_debian_codename_sub.yml | 50 +++++++++------- 2 files changed, 72 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test_docker_debian.yml b/.github/workflows/test_docker_debian.yml index 1395137a0..7c929ae76 100644 --- a/.github/workflows/test_docker_debian.yml +++ b/.github/workflows/test_docker_debian.yml @@ -20,7 +20,7 @@ on: # The branches below must be a subset of the branches above branches: - develop - - main + - master paths: - '.github/workflows/test_docker_debian*.yml' - 'ci/**' @@ -39,19 +39,48 @@ concurrency: jobs: - # Build container and run tests - run: - name: ${{ matrix.debian_codename }} - strategy: - fail-fast: false - matrix: - debian_codename: ['bookworm', 'bullseye', 'buster'] + # Build container and run tests. Duplication of job intended for better visualization. + run_bookworm_armv7: + name: 'bookworm armv7' uses: ./.github/workflows/test_docker_debian_codename_sub.yml with: - runs_on: ubuntu-latest + debian_codename: 'bookworm' platform: linux/arm/v7 - docker_image_name: rpi-jukebox-rfid - cache_scope: ${{ github.ref }}-test-debian - matrix_usernames: "['pi', 'hans']" - matrix_test_scripts: "['run_installation_tests.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh']" - debian_codename: ${{ matrix.debian_codename }} + + # # can be activate on test branches + # run_bookworm_armv6: + # name: 'bookworm armv6' + # uses: ./.github/workflows/test_docker_debian_codename_sub.yml + # with: + # debian_codename: 'bookworm' + # platform: linux/arm/v6 + + run_bullseye_armv7: + name: 'bullseye armv7' + uses: ./.github/workflows/test_docker_debian_codename_sub.yml + with: + debian_codename: 'bullseye' + platform: linux/arm/v7 + + # # can be activate on test branches, currently failing + # run_bullseye_armv6: + # name: 'bullseye armv6' + # uses: ./.github/workflows/test_docker_debian_codename_sub.yml + # with: + # debian_codename: 'bullseye' + # platform: linux/arm/v6 + + run_buster_armv7: + name: 'buster armv7' + uses: ./.github/workflows/test_docker_debian_codename_sub.yml + with: + debian_codename: 'buster' + platform: linux/arm/v7 + + # # can be activate on test branches, currently failing + # run_buster_armv6: + # name: 'buster armv6' + # uses: ./.github/workflows/test_docker_debian_codename_sub.yml + # with: + # debian_codename: 'buster' + # platform: linux/arm/v6 diff --git a/.github/workflows/test_docker_debian_codename_sub.yml b/.github/workflows/test_docker_debian_codename_sub.yml index b018afaf5..6f2bdbfaa 100644 --- a/.github/workflows/test_docker_debian_codename_sub.yml +++ b/.github/workflows/test_docker_debian_codename_sub.yml @@ -3,36 +3,33 @@ name: Subworkflow Test Install Scripts Debian on: workflow_call: inputs: - runs_on: - required: true - type: string - platform: - required: true - type: string debian_codename: required: true type: string - cache_scope: + platform: required: true type: string docker_image_name: - required: true - type: string - matrix_usernames: - required: true + required: false type: string - matrix_test_scripts: - required: true + default: rpi-jukebox-rfid + cache_scope: + required: false type: string + default: ${{ github.ref }}-test-debian local_registry_port: required: false type: number default: 5000 + runs_on: + required: false + type: string + default: ubuntu-latest # 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: ${{ inputs.cache_scope }}-${{ inputs.debian_codename }} + group: ${{ inputs.cache_scope }}-${{ inputs.debian_codename }}-${{ inputs.platform }} cancel-in-progress: true jobs: @@ -45,6 +42,7 @@ jobs: cache_key: ${{ steps.vars.outputs.cache_key }} image_file_name: ${{ steps.vars.outputs.image_file_name }} image_tag_name: ${{ steps.vars.outputs.image_tag_name }} + docker_run_options: ${{ steps.vars.outputs.docker_run_options }} # create local docker registry to use locally build images services: @@ -71,15 +69,18 @@ jobs: DEBIAN_CODENAME: ${{ inputs.debian_codename }} DOCKER_IMAGE_NAME: ${{ inputs.docker_image_name }} CACHE_SCOPE: ${{ inputs.cache_scope }} + PLATFORM: ${{ inputs.platform }} run: | - echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:${{ env.DEBIAN_CODENAME }}-test" >> $GITHUB_OUTPUT - echo "image_file_name=${{ env.DOCKER_IMAGE_NAME }}-${{ env.DEBIAN_CODENAME }}.tar" >> $GITHUB_OUTPUT - echo "cache_scope=${{ env.CACHE_SCOPE }}-${{ env.DEBIAN_CODENAME }}" >> $GITHUB_OUTPUT + PLATFORM=${PLATFORM////_} + echo "image_tag_name=${{ env.DOCKER_IMAGE_NAME }}:${{ env.DEBIAN_CODENAME }}-${PLATFORM}-test" >> $GITHUB_OUTPUT + echo "image_file_name=${{ env.DOCKER_IMAGE_NAME }}-${{ env.DEBIAN_CODENAME }}-${PLATFORM}.tar" >> $GITHUB_OUTPUT + echo "cache_scope=${{ env.CACHE_SCOPE }}-${{ env.DEBIAN_CODENAME }}-${PLATFORM}" >> $GITHUB_OUTPUT - name: Set Output vars id: vars env: LOCAL_REGISTRY_PORT: ${{ inputs.local_registry_port }} + PLATFORM: ${{ inputs.platform }} run: | echo "image_tag_name=${{ steps.pre-vars.outputs.image_tag_name }}" >> $GITHUB_OUTPUT echo "image_tag_name_local_base=localhost:${{ env.LOCAL_REGISTRY_PORT }}/${{ steps.pre-vars.outputs.image_tag_name }}-base" >> $GITHUB_OUTPUT @@ -87,6 +88,9 @@ jobs: echo "image_file_path=./${{ steps.pre-vars.outputs.image_file_name }}" >> $GITHUB_OUTPUT echo "cache_scope=${{ steps.pre-vars.outputs.cache_scope }}" >> $GITHUB_OUTPUT echo "cache_key=${{ steps.pre-vars.outputs.cache_scope }}-${{ github.sha }}#${{ github.run_attempt }}" >> $GITHUB_OUTPUT + if [ "${{ env.PLATFORM }}" == "linux/arm/v6" ] ; then + echo "docker_run_options=-e QEMU_CPU=arm1176" >> $GITHUB_OUTPUT + fi # Build base image for debian version name. Layers will be cached and image pushes to local registry - name: Build Image - Base @@ -128,7 +132,7 @@ jobs: with: name: ${{ steps.vars.outputs.image_file_name }} path: ${{ steps.vars.outputs.image_file_path }} - retention-days: 2 + retention-days: 1 # Run tests with build image @@ -139,8 +143,12 @@ jobs: strategy: fail-fast: false matrix: - username: ${{ fromJSON(inputs.matrix_usernames) }} - test_script: ${{ fromJSON(inputs.matrix_test_scripts) }} + username: ['pi'] + test_script: ['run_installation_tests.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh'] + include: + - username: 'hans' + test_script: 'run_installation_tests.sh' + steps: - name: Set up QEMU @@ -163,7 +171,7 @@ jobs: uses: tj-actions/docker-run@v2 with: image: ${{ needs.build.outputs.image_tag_name }} - options: --platform ${{inputs.platform }} --user ${{ matrix.username }} + options: ${{ needs.build.outputs.docker_run_options }} --platform ${{ inputs.platform }} --user ${{ matrix.username }} --init name: ${{ matrix.test_script }} args: | ./${{ matrix.test_script }}