diff --git a/.github/scripts/tar-artifact.sh b/.github/scripts/tar-artifact.sh deleted file mode 100644 index 549acf9..0000000 --- a/.github/scripts/tar-artifact.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -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}" - -# Convert a platform (as returned by uname -m) to the kernel -# arch (as expected by ARCH= env). -platform_to_kernel_arch() { - case $1 in - s390x) - echo "s390" - ;; - aarch64) - echo "arm64" - ;; - riscv64) - echo "riscv" - ;; - x86_64) - echo "x86" - ;; - *) - echo "$1" - ;; - esac -} - -# Remove intermediate object files that we have no use for. Ideally -# we'd just exclude them from tar below, but it does not provide -# options to express the precise constraints. -find tools/testing/selftests/ -name "*.o" -a ! -name "*.bpf.o" -print0 | \ - xargs --null --max-args=10000 rm - -# Strip debug information, which is excessively large (consuming -# bandwidth) while not actually being used (the kernel does not use -# 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}") - -# Note: ${local_kbuild_output} must point to ./kbuild-output because -# of the tar command at the bottom. -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 [[ -n "${ARCHIVE_MAKE_HELPERS}" ]]; then - # Package up a bunch of additional infrastructure to support running - # 'make kernelrelease' and bpf tool checks later on. - mapfile -t additional_file_list < <(find . -iname Makefile) - additional_file_list+=( - "scripts/" - "tools/testing/selftests/bpf/" - "tools/include/" - "tools/bpf/bpftool/" - ) -fi - -mkdir -p selftests -cp -r tools/testing/selftests/bpf selftests -if [[ -n "${BUILD_SCHED_EXT_SELFTESTS}" ]]; then - cp -r tools/testing/selftests/sched_ext selftests -fi - -tar -cf - \ - kbuild-output \ - "${additional_file_list[@]}" \ - --exclude '*.cmd' \ - --exclude '*.d' \ - --exclude '*.h' \ - --exclude '*.output' \ - selftests/ \ - | 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-build.yml b/.github/workflows/kernel-build.yml index c978f91..e58116c 100644 --- a/.github/workflows/kernel-build.yml +++ b/.github/workflows/kernel-build.yml @@ -45,17 +45,17 @@ jobs: runs-on: ${{ fromJSON(inputs.runs_on) }} timeout-minutes: 100 env: - ARCHIVE_MAKE_HELPERS: ${{ github.repository != 'kernel-patches/bpf' && 'true' || '' }} - KERNEL: ${{ inputs.kernel }} - REPO_ROOT: ${{ github.workspace }} - REPO_PATH: "" - KBUILD_OUTPUT: ${{ github.workspace }}/kbuild-output + ARTIFACTS_ARCHIVE: "vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst" BASE_BRANCH: >- ${{ github.event_name == 'push' && github.ref_name || github.base_ref || 'bpf-next' }} BUILD_SCHED_EXT_SELFTESTS: ${{ inputs.arch == 'x86_64' || inputs.arch == 'aarch64' && 'true' || '' }} + KBUILD_OUTPUT: ${{ github.workspace }}/kbuild-output + KERNEL: ${{ inputs.kernel }} + REPO_PATH: "" + REPO_ROOT: ${{ github.workspace }} steps: - uses: actions/checkout@v4 # We fetch an actual bit of history here to facilitate incremental @@ -140,9 +140,17 @@ jobs: max-make-jobs: 32 llvm-version: ${{ inputs.llvm-version }} - name: Tar artifacts - working-directory: ${{ env.REPO_ROOT }} - run: | - bash .github/scripts/tar-artifact.sh ${{ inputs.arch }} ${{ inputs.toolchain_full }} + id: tar-artifacts + uses: libbpf/ci/tar-artifacts@v1 + env: + ARCHIVE_BPF_SELFTESTS: 'true' + ARCHIVE_MAKE_HELPERS: ${{ github.repository != 'kernel-patches/bpf' && 'true' || '' }} + ARCHIVE_SCHED_EXT_SELFTESTS: ${{ env.BUILD_SCHED_EXT_SELFTESTS }} + with: + arch: ${{ inputs.arch }} + archive: ${{ env.ARTIFACTS_ARCHIVE }} + kbuild-output: ${{ env.KBUILD_OUTPUT }} + repo-root: ${{ env.REPO_ROOT }} - if: ${{ github.event_name != 'push' }} name: Remove KBUILD_OUTPUT content shell: bash @@ -155,4 +163,4 @@ jobs: with: name: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}${{ inputs.release && '-release' || '' }} if-no-files-found: error - path: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst + path: ${{ env.ARTIFACTS_ARCHIVE }}