Skip to content

Commit

Permalink
kernel-build: enable kbuild-output cache for libbpf/ci
Browse files Browse the repository at this point in the history
  • Loading branch information
theihor committed Nov 6, 2024
1 parent d8dda73 commit 170a993
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/kernel-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
|| 'bpf-next'
}}
BUILD_SCHED_EXT_SELFTESTS: ${{ inputs.arch == 'x86_64' || inputs.arch == 'aarch64' && 'true' || '' }}
CACHED_KERNEL_BUILD: ${{ github.event_name == 'push' || github.repository == 'libbpf/ci' && 'true' || '' }}
KBUILD_OUTPUT: ${{ github.workspace }}/kbuild-output
KERNEL: ${{ inputs.kernel }}
REPO_PATH: ""
Expand All @@ -65,23 +66,34 @@ jobs:
fetch-depth: 50
- if: ${{ inputs.download_sources }}
name: Download bpf-next tree
env:
FETCH_GIT_REPO: ${{ env.CACHED_KERNEL_BUILD }}
uses: ./get-linux-source
with:
dest: '.kernel'
- if: ${{ inputs.download_sources }}
name: Move linux source in place
shell: bash
run: |
rm -rf .kernel/.git
cp -rf .kernel/. .
rm -rf .kernel
- uses: ./prepare-incremental-build
mv .git /tmp/.git.not-kernel
cd .kernel
mv -t .. $(ls -A)
cd ..
rmdir .kernel
- if: ${{ env.CACHED_KERNEL_BUILD }}
uses: ./prepare-incremental-build
with:
repo-root: ${{ env.REPO_ROOT }}
base-branch: ${{ env.BASE_BRANCH }}
arch: ${{ inputs.arch }}
toolchain_full: ${{ inputs.toolchain_full }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
- if: ${{ inputs.download_sources }}
name: Restore .git # is this really necessary?
shell: bash
run: |
rm -rf .git
mv /tmp/.git.not-kernel .git
- uses: ./patch-kernel
with:
patches-root: '${{ github.workspace }}/ci/diffs'
Expand Down Expand Up @@ -152,7 +164,7 @@ jobs:
archive: ${{ env.ARTIFACTS_ARCHIVE }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
repo-root: ${{ env.REPO_ROOT }}
- if: ${{ github.event_name != 'push' }}
- if: ${{ ! env.CACHED_KERNEL_BUILD }}
name: Remove KBUILD_OUTPUT content
shell: bash
run: |
Expand Down
8 changes: 6 additions & 2 deletions get-linux-source/checkout_latest_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ source $(cd $(dirname $0) && pwd)/../helpers.sh

CWD=$(pwd)

FETCH_GIT_REPO=${FETCH_GIT_REPO:-}

echo KERNEL_ORIGIN = ${KERNEL_ORIGIN}
echo KERNEL_BRANCH = ${KERNEL_BRANCH}
echo REPO_PATH = ${REPO_PATH}
Expand All @@ -29,7 +31,7 @@ if [ ! -d "${REPO_PATH}" ]; then
mkdir -p $(dirname "${REPO_PATH}")
cd $(dirname "${REPO_PATH}")
# attempt to fetch desired bpf-next repo snapshot
if [ -n "${SNAPSHOT_URL}" ] && \
if [ -n "${SNAPSHOT_URL}" ] && [ -z "${FETCH_GIT_REPO}" ] && \
wget -U 'BPFCIBot/1.0 ([email protected])' -nv ${SNAPSHOT_URL} && \
tar xf bpf-next-${LINUX_SHA}.tar.gz --totals ; then
mv bpf-next-${LINUX_SHA} $(basename ${REPO_PATH})
Expand All @@ -48,7 +50,9 @@ if [ ! -d "${REPO_PATH}" ]; then
fi
git reset --hard ${LINUX_SHA}
fi
rm -rf ${REPO_PATH}/.git || true
if [ -z "${FETCH_GIT_REPO}" ]; then
rm -rf ${REPO_PATH}/.git || true
fi

foldable end pull_kernel_srcs
fi

0 comments on commit 170a993

Please sign in to comment.