Skip to content

Commit

Permalink
Factor out incremental build prep into an action
Browse files Browse the repository at this point in the history
  • Loading branch information
theihor committed Sep 12, 2024
1 parent f1bc702 commit eb423f1
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 39 deletions.
23 changes: 0 additions & 23 deletions .github/scripts/get-commit-metadata.sh

This file was deleted.

26 changes: 10 additions & 16 deletions .github/workflows/kernel-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
REPO_ROOT: ${{ github.workspace }}
REPO_PATH: ""
KBUILD_OUTPUT: kbuild-output/
BASE_BRANCH: >-
${{ github.event_name == 'push' && github.ref_name
|| github.base_ref
|| 'bpf-next_base'
}}
steps:
- uses: actions/checkout@v4
# We fetch an actual bit of history here to facilitate incremental
Expand All @@ -67,23 +72,12 @@ jobs:
rm -rf .kernel/.git
cp -rf .kernel/. .
rm -rf .kernel
- name: Get commit meta-data
id: get-commit-metadata
run: |
bash .github/scripts/get-commit-metadata.sh
- name: Pull recent KBUILD_OUTPUT contents
uses: actions/cache@v4
- uses: ./prepare-incremental-build
with:
path: ${{ env.KBUILD_OUTPUT }}
key: kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-${{ steps.get-commit-metadata.outputs.commit }}
restore-keys: |
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-
- name: Prepare incremental build
shell: bash
run: |
bash .github/scripts/prepare-incremental-builds.sh ${{ steps.get-commit-metadata.outputs.commit }}
repo-root: ${{ env.REPO_ROOT }}
base-branch: ${{ env.BASE_BRANCH }}
arch: ${{ inputs.arch }}
toolchain_full: ${{ inputs.toolchain_full }}
- uses: ./patch-kernel
with:
repo-root: '${{ github.workspace }}'
Expand Down
52 changes: 52 additions & 0 deletions prepare-incremental-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Prepare incremental kernel build'
description: 'Pull cached kernel build output from previous runs and prepare the repo for incremental build'
inputs:
repo-root:
description: "Root of the kernel repository"
required: true
default: ${{ github.workspace }}
base-branch:
description: "Base branch for cache lookup"
required: true
default: bpf-next_base
arch:
required: true
type: string
description: "Part of cache lookup key"
toolchain_full:
required: true
type: string
description: "Part of cache lookup key"
kbuild-output:
required: true
type: string
description: "Path to KBUILD_OUTPUT"
default: kbuild-output

runs:
using: "composite"
steps:

- name: Get commit meta-data for cache lookup
id: get-commit-metadata
shell: bash
working-directory: ${{ inputs.repo-root }}
run: ${GITHUB_ACTION_PATH}/get-commit-metadata.sh ${{ inputs.base-branch }}

- name: Pull recent KBUILD_OUTPUT contents
uses: actions/cache@v4
with:
path: ${{ inputs.kbuild-output }}
key: kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-${{ steps.get-commit-metadata.outputs.commit }}
restore-keys: |
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-
- name: Prepare incremental build
shell: bash
env:
KBUILD_OUTPUT: ${{ inputs.kbuild-output }}
working-directory: ${{ inputs.repo-root }}
run: ${GITHUB_ACTION_PATH}/prepare-incremental-builds.sh ${{ steps.get-commit-metadata.outputs.commit }}

26 changes: 26 additions & 0 deletions prepare-incremental-build/get-commit-metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# branch="${GITHUB_BASE_REF}"

# if [ "${GITHUB_EVENT_NAME}" = 'push' ]; then
# branch="${GITHUB_REF_NAME}"
# fi

set -eux

branch=${1:-bpf-next_base}

echo "branch=${branch}" >> "${GITHUB_OUTPUT}"

upstream="${branch//_base/}"

git fetch --quiet --prune --no-tags --depth=1 --no-recurse-submodules \
origin "+refs/heads/${upstream}:refs/remotes/origin/${upstream}"
commit=$(git rev-parse "origin/${upstream}")

timestamp_utc="$(TZ=utc git show --format='%cd' --no-patch --date=iso-strict-local "${commit}")"

echo "timestamp=${timestamp_utc}" >> "${GITHUB_OUTPUT}"
echo "commit=${commit}" >> "${GITHUB_OUTPUT}"
echo "Most recent upstream commit is ${commit}"

File renamed without changes.

0 comments on commit eb423f1

Please sign in to comment.