Skip to content

workflow: move build operations in a reusable workflow #527

workflow: move build operations in a reusable workflow

workflow: move build operations in a reusable workflow #527

Workflow file for this run

name: bpf-ci
on:
pull_request:
push:
branches:
- bpf_base
- bpf-next_base
env:
veristat_arch: x86_64
veristat_toolchain: gcc
concurrency:
group: ci-test-${{ github.ref_name }}
cancel-in-progress: true
jobs:
set-matrix:
# FIXME: set-matrix is lightweight, run it on any self-hosted machines for kernel-patches org
# so we do not wait for GH hosted runners when there potentially all are busy because of bpf-rc
# repo for instance.
# This could be somehow fixed long term by making this action/workflow re-usable and letting the called
# specify what to run on.
runs-on: ${{ github.repository_owner == 'kernel-patches' && 'x86_64' || 'ubuntu-latest' }}
outputs:
build-matrix: ${{ steps.set-matrix-impl.outputs.build_matrix }}
test-matrix: ${{ steps.set-matrix-impl.outputs.test_matrix }}
veristat-runs-on: ${{ steps.set-matrix-impl.outputs.veristat_runs_on }}
steps:
- uses: actions/checkout@v3
- id: set-matrix-impl
run: |
python3 .github/scripts/matrix.py
# Build kernel and selftest
build:
uses: ./.github/workflows/kernel-build.yml

Check failure on line 38 in .github/workflows/test.yml

View workflow run for this annotation

GitHub Actions / bpf-ci

Invalid workflow file

The workflow is not valid. .github/workflows/test.yml (Line: 38, Col: 11): Input runs_on is required, but not provided while calling. .github/workflows/test.yml (Line: 47, Col: 15): Invalid input, runson is not defined in the referenced workflow.
needs: set-matrix
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.set-matrix.outputs.build-matrix) }}
with:
arch: ${{ matrix.arch }}
toolchain_full: ${{ matrix.toolchain_full }}
toolchain: ${{ matrix.toolchain }}
runson: ${{ toJSON(matrix.runs_on) }}
llvm-version: ${{ matrix.llvm-version }}
kernel: ${{ matrix.kernel }}
test:
if: ${{ github.event_name != 'push' }}
name: ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain_full }}
needs: [set-matrix, build]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.set-matrix.outputs.test-matrix) }}
runs-on: ${{ matrix.runs_on }}
timeout-minutes: 100
env:
KERNEL: ${{ matrix.kernel }}
REPO_ROOT: ${{ github.workspace }}
REPO_PATH: ""
KBUILD_OUTPUT: kbuild-output/
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain_full }}
path: .
- name: Untar artifacts
# zstd is installed by default in the runner images.
run: zstd -d -T0 vmlinux-${{ matrix.arch }}-${{ matrix.toolchain_full }}.tar.zst --stdout | tar -xf -
- name: Prepare rootfs
uses: libbpf/ci/prepare-rootfs@main
with:
project-name: 'libbpf'
arch: ${{ matrix.arch }}
kernel: ${{ matrix.kernel }}
kernel-root: '.'
kbuild-output: ${{ env.KBUILD_OUTPUT }}
image-output: '/tmp/root.img'
test: ${{ matrix.test }}
- name: Run selftests
uses: libbpf/ci/run-qemu@main
continue-on-error: ${{ matrix.continue_on_error }}
timeout-minutes: ${{ matrix.timeout_minutes }}
with:
arch: ${{ matrix.arch}}
img: '/tmp/root.img'
vmlinuz: '${{ github.workspace }}/vmlinuz'
kernel-root: '.'
max-cpu: 8
kernel-test: ${{ matrix.test }}
veristat:
name: veristat
needs: [set-matrix, build]
runs-on: ${{ fromJSON(needs.set-matrix.outputs.veristat-runs-on) }}
timeout-minutes: 100
env:
KERNEL: LATEST
REPO_ROOT: ${{ github.workspace }}
REPO_PATH: ""
KBUILD_OUTPUT: kbuild-output/
permissions:
id-token: write
contents: read
steps:
- name: Setup environment variables
run: |
echo ARCH_AND_TOOL=${{ env.veristat_arch }}-${{ env.veristat_toolchain }} >> \
${GITHUB_ENV}
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: vmlinux-${{ env.ARCH_AND_TOOL }}
path: .
- name: Untar artifacts
# zstd is installed by default in the runner images.
run: zstd -d -T0 vmlinux-${{ env.ARCH_AND_TOOL }}.tar.zst --stdout | tar -xf -
- name: Prepare rootfs
uses: libbpf/ci/prepare-rootfs@main
with:
project-name: 'libbpf'
arch: x86_64
kernel: LATEST
kernel-root: '.'
kbuild-output: ${{ env.KBUILD_OUTPUT }}
image-output: '/tmp/root.img'
- name: Configure AWS Credentials
# Disabling BPF objects download and veristat-meta benchmark for PRs
# created from fork repositories. These won't have access to required
# enviroment variables and secrets, and otherwise would consistently fail
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: github-action-bpf-ci
- name: Download BPF objects
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
run: |
set -eux
if [ -n "$AWS_ROLE_ARN" ]; then
mkdir /tmp/bpf_objects
aws s3 sync s3://veristat-bpf-binaries /tmp/bpf_objects
fi
env:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
- name: Add BPF objects to rootfs
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
shell: bash
run: ./.github/scripts/bpf-objects-rootfs.sh
- name: Run veristat
uses: libbpf/ci/run-qemu@main
with:
arch: x86_64
img: '/tmp/root.img'
vmlinuz: '${{ github.workspace }}/vmlinuz'
kernel-root: '.'
max-cpu: 8
kernel-test: run_veristat_kernel,run_veristat_meta
output-dir: '${{ github.workspace }}'
- name: Compare and save veristat.kernel.csv
uses: ./.github/actions/veristat_baseline_compare
with:
veristat_output: veristat-kernel
baseline_name: ${{ env.ARCH_AND_TOOL}}-baseline-veristat-kernel
- name: Compare and save veristat.meta.csv
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
uses: ./.github/actions/veristat_baseline_compare
with:
veristat_output: veristat-meta
baseline_name: ${{ env.ARCH_AND_TOOL}}-baseline-veristat-meta