diff --git a/.github/workflows/run-kola-tests.yaml b/.github/workflows/run-kola-tests.yaml index 9eb84816da..6c0ef80168 100644 --- a/.github/workflows/run-kola-tests.yaml +++ b/.github/workflows/run-kola-tests.yaml @@ -34,7 +34,7 @@ jobs: run: | sudo rm /bin/sh sudo ln -s /bin/bash /bin/sh - sudo apt-get install -y ca-certificates curl gnupg lsb-release qemu-system git bzip2 jq dnsmasq + sudo apt-get install -y ca-certificates curl gnupg lsb-release qemu-system git bzip2 jq dnsmasq python3 sudo systemctl stop dnsmasq sudo systemctl mask dnsmasq @@ -60,45 +60,156 @@ jobs: fetch-depth: 0 submodules: true - - name: Download artifact + - name: Download binpkgs if: ${{ !inputs.workflow_run_id }} uses: actions/download-artifact@v3 with: - name: images-${{ matrix.arch }} + name: ${{ matrix.arch }}-binpkgs - - name: Download artifacts from other workflow + - name: Download test update image + if: ${{ !inputs.workflow_run_id }} + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.arch }}-test-update + + - name: Download generic image + if: ${{ !inputs.workflow_run_id }} + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.arch }}-generic-image + + - name: Download developer container + if: ${{ !inputs.workflow_run_id }} + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.arch }}-devcontainer + + - name: Download torcx tarball + if: ${{ !inputs.workflow_run_id }} + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.arch }}-torcx + + - name: Download binpkgs from other workflow uses: gabriel-samfira/action-download-artifact@v5 if: ${{ inputs.workflow_run_id }} with: workflow: ${{ inputs.workflow_name_or_id }} workflow_conclusion: success run_id: ${{ inputs.workflow_run_id }} - name: images-${{ matrix.arch }} + name: ${{ matrix.arch }}-binpkgs + + - name: Download test update image from other workflow + uses: gabriel-samfira/action-download-artifact@v5 + if: ${{ inputs.workflow_run_id }} + with: + workflow: ${{ inputs.workflow_name_or_id }} + workflow_conclusion: success + run_id: ${{ inputs.workflow_run_id }} + name: ${{ matrix.arch }}-test-update + + - name: Download generic image from other workflow + uses: gabriel-samfira/action-download-artifact@v5 + if: ${{ inputs.workflow_run_id }} + with: + workflow: ${{ inputs.workflow_name_or_id }} + workflow_conclusion: success + run_id: ${{ inputs.workflow_run_id }} + name: ${{ matrix.arch }}-generic-image + + - name: Download developer container from other workflow + uses: gabriel-samfira/action-download-artifact@v5 + if: ${{ inputs.workflow_run_id }} + with: + workflow: ${{ inputs.workflow_name_or_id }} + workflow_conclusion: success + run_id: ${{ inputs.workflow_run_id }} + name: ${{ matrix.arch }}-devcontainer + + - name: Download torcx tarball from other workflow + uses: gabriel-samfira/action-download-artifact@v5 + if: ${{ inputs.workflow_run_id }} + with: + workflow: ${{ inputs.workflow_name_or_id }} + workflow_conclusion: success + run_id: ${{ inputs.workflow_run_id }} + name: ${{ matrix.arch }}-torcx + + - name: Extract artifacts + shell: bash + run: | + exec 2>&1 + set -x + set -euo pipefail + + # Set up a webserver for devcontainer and torcx tests. + # The respective tests will download devcontainer and torcx tarball via http. + # The devcontainer test will then run a build + # which will download and install binpkgs into the dev container. + # For the sake of that test we will serve both via a temporary local web server. + TESTS_WEBSERVER_WEBROOT="scripts/devcontainer-webroot" + default_rout_device="$(sudo ip -j route sh default |jq -r .[0].dev)" + TESTS_WEBSERVER_IP="$(sudo ip -j address show dev "${default_rout_device}" | jq -r .[0].addr_info[0].local)" + TESTS_WEBSERVER_PORT=12345 + echo "TESTS_WEBSERVER_WEBROOT=${TESTS_WEBSERVER_WEBROOT}" >> "$GITHUB_ENV" + echo "TESTS_WEBSERVER_IP=${TESTS_WEBSERVER_IP}" >> "$GITHUB_ENV" + echo "TESTS_WEBSERVER_PORT=${TESTS_WEBSERVER_PORT}" >> "$GITHUB_ENV" + + mkdir ${TESTS_WEBSERVER_WEBROOT} + mv flatcar_developer_container* ${TESTS_WEBSERVER_WEBROOT} + tar -C ${TESTS_WEBSERVER_WEBROOT} -xvf binpkgs.tar + + tar -C ${TESTS_WEBSERVER_WEBROOT} -xvf torcx.tar + + # Move torcx package into plain webroot + # (path consists of ///:.torcx.tar.gz) + mv "${TESTS_WEBSERVER_WEBROOT}/${{ matrix.arch }}-usr"/*/*/*.torcx.tgz \ + "${TESTS_WEBSERVER_WEBROOT}" + + # Update torcx.json's http URL to point to the webserver IP. + # ci.yaml defines the "localhost" placeholder in its "Set Environment" step. + sed -i "s,http://localhost:12345,http://${TESTS_WEBSERVER_IP}:${TESTS_WEBSERVER_PORT}," \ + "${TESTS_WEBSERVER_WEBROOT}/torcx_manifest.json" + cat "${TESTS_WEBSERVER_WEBROOT}/torcx_manifest.json" + + # Extract the generic image we'll use for qemu tests. + # Note that the qemu[_uefi] tests use the generic image instead of the + # qemu vendor VM image ("Astronaut: [...] Always have been."). + bzip2 --decompress flatcar_production_image.bin.bz2 + mv flatcar_production_image.bin flatcar_production_qemu_uefi_efi_code.fd scripts/ + + mv flatcar_test_update.gz scripts/ + - name: Run tests shell: bash run: | exec 2>&1 - set +x + set -x set -euo pipefail - # extract the image. - IMG_ARCHIVE=$(readlink -f images/**/flatcar_production_image.bin.bz2) - QEMU_UEFI_BIOS_FILE=$(readlink -f images/**/flatcar_production_qemu_uefi_efi_code.fd) - bzip2 --decompress ${IMG_ARCHIVE} - - cp ${IMG_ARCHIVE%%.bz2} ./scripts/ - cp ${QEMU_UEFI_BIOS_FILE} ./scripts/ + python3 -m http.server -d "${TESTS_WEBSERVER_WEBROOT}" -b "${TESTS_WEBSERVER_IP}" "${TESTS_WEBSERVER_PORT}" & pushd scripts source ci-automation/test.sh + # Provide our own torcx prepare function so we use our local manifest json. + # This is called by test_run below. + function __prepare_torcx() { + shift; shift # no need for arch or vernum + local destdir="$1" + cp "../${TESTS_WEBSERVER_WEBROOT}/torcx_manifest.json" "${destdir}" + } + PARALLEL_ARCH=10 cat > sdk_container/.env <