diff --git a/.github/workflows/mantle-releases-main.yml b/.github/workflows/mantle-releases-main.yml new file mode 100644 index 0000000000..7942f713f3 --- /dev/null +++ b/.github/workflows/mantle-releases-main.yml @@ -0,0 +1,54 @@ +name: Get the latest mantle release for branch +on: + workflow_dispatch: + push: + branches: + - main + schedule: + - cron: '0 7 * * 1' + +jobs: + get-mantle-release: + strategy: + matrix: + branch: [main,alpha,beta,stable] + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Figure out branch + id: figure-out-branch + run: | + if [ ${{ matrix.branch }} = "main" ]; then + echo ::set-output name=BRANCH::main + else + major=$(curl -sSL https://${{ matrix.branch }}.release.flatcar-linux.net/amd64-usr/current/version.txt | awk -F= '/FLATCAR_BUILD=/{ print $2 }') + echo ::set-output name=BRANCH::flatcar-${major} + fi + - uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ steps.figure-out-branch.outputs.BRANCH }} + - name: Fetch latest mantle hash + id: fetch-latest-mantle + run: | + commit=$(git ls-remote https://github.com/flatcar-linux/mantle refs/heads/flatcar-master | cut -f1) + echo ::set-output name=COMMIT::${commit} + - name: Try to apply patch + run: | + set -x + commit=${{ steps.fetch-latest-mantle.outputs.COMMIT }} + if ! grep -q "ghcr.io/flatcar-linux/mantle:git-${commit}" sdk_container/.repo/manifests/mantle-container; then + echo "ghcr.io/flatcar-linux/mantle:git-${commit}" > sdk_container/.repo/manifests/mantle-container + git add sdk_container/.repo/manifests/mantle-container + fi + - name: Create pull request for branch + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + base: ${{ steps.figure-out-branch.outputs.BRANCH }} + branch: mantle-update-${{ steps.figure-out-branch.outputs.BRANCH }} + author: Flatcar Buildbot + committer: Flatcar Buildbot + title: Upgrade mantle container image to latest HEAD in ${{ steps.figure-out-branch.outputs.BRANCH }} + commit-message: Update mantle container image to latest HEAD + delete-branch: true diff --git a/ci-automation/test.sh b/ci-automation/test.sh index 8e9246f2cf..c660bd8f9c 100644 --- a/ci-automation/test.sh +++ b/ci-automation/test.sh @@ -118,35 +118,23 @@ function test_run() { local docker_vernum docker_vernum="$(vernum_to_docker_image_version "${vernum}")" - # Get SDK from either the registry or import from build cache - local sdk_version="${FLATCAR_SDK_VERSION}" - local sdk_name="flatcar-sdk-${arch}" - local docker_sdk_vernum="$(vernum_to_docker_image_version "${sdk_version}")" - - docker_image_from_registry_or_buildcache "${sdk_name}" "${docker_sdk_vernum}" - local sdk_image="$(docker_image_fullname "${sdk_name}" "${docker_sdk_vernum}")" - echo "docker image rm -f '${sdk_image}'" >> ./ci-cleanup.sh - local work_dir="__TESTS__" local tests_dir="${work_dir}/${image}" mkdir -p "${tests_dir}" local container_name="flatcar-tests-${arch}-${docker_vernum}-${image}" + local mantle_ref + mantle_ref=$(cat sdk_container/.repo/manifests/mantle-container) # Make the torcx artifacts available to test implementation __prepare_torcx "${arch}" "${vernum}" "${work_dir}" - # Ensure we run tests with an up-to-date kola. - # This covers the case of a mantle/kola commit ID in the ebuild being - # newer than the mantle/kola included in the SDK. - ./run_sdk_container -x ./ci-cleanup.sh \ - -n "${container_name}" -C "${sdk_image}" -v "${vernum}" \ - sudo emerge mantle - local tap_merged_summary="results-${image}.tap" local tap_merged_detailed="results-${image}-detailed.tap" local retry="" local success=false + # A job on each worker prunes old mantle images (docker image prune) + echo "docker rm -f '${container_name}'" >> ./ci-cleanup.sh for retry in $(seq "${retries}"); do local tapfile="results-run-${retry}.tap" local failfile="failed-run-${retry}.txt" @@ -154,18 +142,19 @@ function test_run() { # Ignore retcode since tests are flaky. We'll re-run failed tests and # determine success based on test results (tapfile). set +e -o noglob - ./run_sdk_container -x ./ci-cleanup.sh \ - -n "${container_name}" -C "${sdk_image}" -v "${vernum}" \ - ci-automation/vendor-testing/"${image}".sh \ - "${tests_dir}" \ - "${arch}" \ - "${vernum}" \ - "${tapfile}" \ - $@ + touch sdk_container/.env + docker run --pull always --rm --name="${container_name}" --privileged --net host -v /dev:/dev \ + -w /work -v "$PWD":/work "${mantle_ref}" \ + bash -c "set -o noglob && source sdk_container/.env && ci-automation/vendor-testing/\"${image}\".sh \ + \"${tests_dir}\" \ + \"${arch}\" \ + \"${vernum}\" \ + \"${tapfile}\" \ + $@" set -e +o noglob - ./run_sdk_container -x ./ci-cleanup.sh \ - -n "${container_name}" -C "${sdk_image}" -v "${vernum}" \ + docker run --pull always --rm --name="${container_name}" --privileged --net host -v /dev:/dev \ + -w /work -v "$PWD":/work "${mantle_ref}" \ ci-automation/test_update_reruns.sh \ "${arch}" "${vernum}" "${image}" "${retry}" \ "${tests_dir}/${tapfile}" \ diff --git a/sdk_container/.repo/manifests/mantle-container b/sdk_container/.repo/manifests/mantle-container new file mode 100644 index 0000000000..5a95770c74 --- /dev/null +++ b/sdk_container/.repo/manifests/mantle-container @@ -0,0 +1 @@ +ghcr.io/flatcar-linux/mantle:git-cdf70a21b356e6ed6b1da0cb2bf57deeea8e48f7