ci: enabled release gcc build #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Reusable build workflow | ||
on: | ||
workflow_call: | ||
inputs: | ||
arch: | ||
required: true | ||
type: string | ||
description: The architecture to build against, e.g x86_64, aarch64, s390x... | ||
toolchain_full: | ||
required: true | ||
type: string | ||
description: The toolchain and for llvm, its version, e.g gcc, llvm-15 | ||
toolchain: | ||
required: true | ||
type: string | ||
description: The toolchain, e.g gcc, llvm | ||
runs_on: | ||
required: true | ||
type: string | ||
description: The runners to run the test on. This is a json string representing an array of labels. | ||
llvm-version: | ||
required: true | ||
type: string | ||
description: The version of LLVM used to build selftest.... for llvm toolchain, this should match the one from toolchain_full, for gcc it is an arbritrary version we decide to build selftests against. | ||
kernel: | ||
required: true | ||
type: string | ||
description: The kernel to run the test against. For KPD this is always LATEST, which runs against a newly built kernel. | ||
download_sources: | ||
required: true | ||
type: boolean | ||
description: Whether to download the linux sources into the working directory. | ||
default: false | ||
release: | ||
required: false | ||
type: boolean | ||
description: Build selftest with -O2 optimization | ||
default: false | ||
jobs: | ||
build: | ||
name: build for ${{ inputs.arch }} with ${{ inputs.toolchain_full }}${{ inputs.release && '-O2' || '' }} | ||
runs-on: ${{ fromJSON(inputs.runs_on) }} | ||
timeout-minutes: 100 | ||
env: | ||
KERNEL: ${{ inputs.kernel }} | ||
REPO_ROOT: ${{ github.workspace }} | ||
REPO_PATH: "" | ||
KBUILD_OUTPUT: kbuild-output/ | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# We fetch an actual bit of history here to facilitate incremental | ||
# builds (which may check out some earlier upstream change). | ||
with: | ||
fetch-depth: 50 | ||
- if: ${{ inputs.download_sources }} | ||
name: Download bpf-next tree | ||
uses: libbpf/ci/get-linux-source@main | ||
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 | ||
- 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 | ||
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 }} | ||
- uses: libbpf/ci/patch-kernel@main | ||
with: | ||
patches-root: '${{ github.workspace }}/ci/diffs' | ||
repo-root: '${{ github.workspace }}' | ||
- name: Setup build environment | ||
uses: libbpf/ci/setup-build-env@main | ||
with: | ||
arch: ${{ inputs.arch }} | ||
llvm-version: ${{ inputs.llvm-version }} | ||
- name: Print toolchain version used | ||
shell: bash | ||
run: | | ||
$INPUT_TOOLCHAIN_FULL --version | ||
- name: Build kernel image | ||
uses: libbpf/ci/build-linux@main | ||
with: | ||
arch: ${{ inputs.arch }} | ||
toolchain: ${{ inputs.toolchain }} | ||
kbuild-output: ${{ env.KBUILD_OUTPUT }} | ||
max-make-jobs: 32 | ||
llvm-version: ${{ inputs.llvm-version }} | ||
- name: Build selftests | ||
uses: libbpf/ci/build-selftests@main | ||
with: | ||
arch: ${{ inputs.arch }} | ||
toolchain: ${{ inputs.toolchain }} | ||
kbuild-output: ${{ env.KBUILD_OUTPUT }} | ||
max-make-jobs: 32 | ||
llvm-version: ${{ inputs.llvm-version }} | ||
env: | ||
# RELEASE= disables all optimizaions | ||
# RELEASE=0 adds -O0 make flag | ||
# RELEASE=1 adds -O2 make flag | ||
RELEASE: ${{ inputs.release && '1' || '' }} | ||
- if: ${{ github.event_name != 'push' }} | ||
name: Build samples | ||
uses: libbpf/ci/build-samples@main | ||
with: | ||
arch: ${{ inputs.arch }} | ||
toolchain: ${{ inputs.toolchain }} | ||
kbuild-output: ${{ env.KBUILD_OUTPUT }} | ||
max-make-jobs: 32 | ||
llvm-version: ${{ inputs.llvm-version }} | ||
- name: Tar artifacts | ||
run: | | ||
bash .github/scripts/tar-artifact.sh ${{ inputs.arch }} ${{ inputs.toolchain_full }} | ||
- if: ${{ github.event_name != 'push' }} | ||
name: Remove KBUILD_OUTPUT content | ||
shell: bash | ||
run: | | ||
# Remove $KBUILD_OUTPUT to prevent cache creation for pull requests. | ||
# Only on pushed changes are build artifacts actually cached, because | ||
# of github.com/actions/cache's cache isolation logic. | ||
rm -rf "${KBUILD_OUTPUT}" | ||
- uses: actions/upload-artifact@v4 | ||
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 |