diff --git a/.github/scripts/tar-artifact.sh b/.github/scripts/tar-artifact.sh index 43bff08..8751040 100644 --- a/.github/scripts/tar-artifact.sh +++ b/.github/scripts/tar-artifact.sh @@ -2,6 +2,15 @@ set -eux +# Assumptions: +# - $(pwd) is the root of kernel repo we're tarring +# - zstd is installed by default in the runner images + +if [ ! -d "${KBUILD_OUTPUT:-}" ]; then + echo "KBUILD_OUTPUT must be a directory" + exit 1 +fi + arch="${1}" toolchain="${2}" archive_make_helpers="${3:-0}" @@ -39,6 +48,28 @@ find selftests/ -name "*.o" -a ! -name "*.bpf.o" -print0 | \ # DWARF to symbolize stacktraces). "${arch}"-linux-gnu-strip --strip-debug "${KBUILD_OUTPUT}"/vmlinux +image_name=$(make ARCH="$(platform_to_kernel_arch "${arch}")" -s image_name) +kbuild_output_file_list=( + ".config" + "${image_name}" + "include/config/auto.conf" + "include/generated/autoconf.h" + "vmlinux" +) + +# While we are preparing the tarball, move $KBUILD_OUTPUT to a tmp +# location just in case it's inside the repo root +tmp=$(mktemp -d) +mv "${KBUILD_OUTPUT}" "${tmp}" +stashed_kbuild_output=${tmp}/$(basename "${KBUILD_OUTPUT}") +local_kbuild_output=$(realpath kbuild-output) +mkdir -p "${local_kbuild_output}" + +for file in "${kbuild_output_file_list[@]}"; do + mkdir -p "$(dirname "${local_kbuild_output}/${file}")" + cp -a "${stashed_kbuild_output}/${file}" "${local_kbuild_output}/${file}" +done + additional_file_list=() if [ $archive_make_helpers -ne 0 ]; then # Package up a bunch of additional infrastructure to support running @@ -52,26 +83,17 @@ if [ $archive_make_helpers -ne 0 ]; then ) fi -image_name=$(make ARCH="$(platform_to_kernel_arch "${arch}")" -s image_name) - -kbuild_output_file_list=( - ".config" - "${image_name}" - "include/config/auto.conf" - "include/generated/autoconf.h" - "vmlinux" -) - -# Assumptions: -# - $(pwd) is the root of kernel repo we're tarring -# - zstd is installed by default in the runner images -tar -cf - \ - -C "$KBUILD_OUTPUT" \ - "${kbuild_output_file_list[@]}" \ - -C "$(pwd)" \ - "${additional_file_list[@]}" \ - --exclude '*.cmd' \ - --exclude '*.d' \ - --exclude '*.output' \ - selftests/bpf/ \ +tar -cf - \ + "${local_kbuild_output}/" \ + "${additional_file_list[@]}" \ + --exclude '*.cmd' \ + --exclude '*.d' \ + --exclude '*.h' \ + --exclude '*.output' \ + selftests/bpf/ \ | zstd -T0 -19 -o "vmlinux-${arch}-${toolchain}.tar.zst" + +# Cleanup and restore the original KBUILD_OUTPUT +# We have to put KBUILD_OUTPUT back to its original location for actions/cache +rm -rf "${local_kbuild_output}" +mv "${stashed_kbuild_output}" "${KBUILD_OUTPUT}" diff --git a/.github/workflows/kernel-test.yml b/.github/workflows/kernel-test.yml index 4fbb2c7..21efc04 100644 --- a/.github/workflows/kernel-test.yml +++ b/.github/workflows/kernel-test.yml @@ -41,7 +41,6 @@ jobs: KERNEL: ${{ inputs.kernel }} REPO_ROOT: ${{ github.workspace }} REPO_PATH: "" - KBUILD_OUTPUT: ${{ github.workspace }}/kbuild-output # https://github.com/actions/runner/issues/1483#issuecomment-1031671517 # booleans are weird in GH. CONTINUE_ON_ERROR: ${{ inputs.continue_on_error }} @@ -67,4 +66,6 @@ jobs: kernel-root: ${{ env.REPO_ROOT }} max-cpu: 8 kernel-test: ${{ inputs.test }} - kbuild-output: ${{ env.KBUILD_OUTPUT }} + # Here we must use kbuild-output local to the repo, because + # it was extracted from the artifacts. + kbuild-output: ${{ env.REPO_ROOT }}/kbuild-output