-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
workflow: move build operations in a reusable workflow #244
Merged
chantra
merged 10 commits into
kernel-patches:master
from
chantra:reuseable_workflow_tests
Oct 26, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1b90a74
workflow: move build operations in a reusable workflow
chantra 21bb7a0
[workflow] move test in a reusable workflow
chantra 6c2928d
[workflow] move veristat in a reusable workflow
chantra 1ac463c
workflow: a reusable workflow to kick a build/test/veristat *PER* arc…
chantra 4c49999
[workflow] Document reusable workflow input variables
chantra 1fd52f8
Run on ubuntu-20.04 when using GH runners
chantra 83a74e7
[workflow] Set job name when calling reusable workflow with matrix
chantra 77645ea
[workflow] stop using tests-matrix and veristat-matrix
chantra 120f9d0
[lint] Validate matrix.py
chantra 6831f53
[scripts] Blacken scripts en enforce it
chantra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Reusable Build/Test/Veristat 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. | ||
tests: | ||
required: true | ||
type: string | ||
description: A serialized json array with the tests to be running, it must follow the json-matrix format, https://www.jitsejan.com/use-github-actions-with-json-file-as-matrix | ||
run_veristat: | ||
required: true | ||
type: boolean | ||
description: Whether or not to run veristat | ||
secrets: | ||
AWS_ROLE_ARN: | ||
required: true | ||
|
||
jobs: | ||
# Build kernel and selftest | ||
build: | ||
uses: ./.github/workflows/kernel-build.yml | ||
with: | ||
arch: ${{ inputs.arch }} | ||
toolchain_full: ${{ inputs.toolchain_full }} | ||
toolchain: ${{ inputs.toolchain }} | ||
runs_on: ${{ inputs.runs_on }} | ||
llvm-version: ${{ inputs.llvm-version }} | ||
kernel: ${{ inputs.kernel }} | ||
|
||
test: | ||
uses: ./.github/workflows/kernel-test.yml | ||
# Setting name to test here to avoid lengthy autogenerated names due to matrix | ||
# e.g build-and-test x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc | ||
name: "test" | ||
needs: [build] | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJSON(inputs.tests) }} | ||
with: | ||
arch: ${{ inputs.arch }} | ||
toolchain_full: ${{ inputs.toolchain_full }} | ||
runs_on: ${{ inputs.runs_on }} | ||
kernel: ${{ inputs.kernel }} | ||
test: ${{ matrix.test }} | ||
continue_on_error: ${{ toJSON(matrix.continue_on_error) }} | ||
timeout_minutes: ${{ matrix.timeout_minutes }} | ||
|
||
veristat: | ||
if: ${{ inputs.run_veristat }} | ||
uses: ./.github/workflows/kernel-veristat.yml | ||
needs: [build] | ||
permissions: | ||
id-token: write | ||
contents: read | ||
with: | ||
arch: ${{ inputs.arch }} | ||
toolchain: ${{ inputs.toolchain }} | ||
aws_region: ${{ vars.AWS_REGION }} | ||
runs_on: ${{ inputs.runs_on }} | ||
secrets: | ||
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
|
||
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. | ||
|
||
|
||
jobs: | ||
build: | ||
name: build for ${{ inputs.arch }} with ${{ inputs.toolchain_full }} | ||
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@v3 | ||
# 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: ${{ github.repository == 'kernel-patches/vmtest' }} | ||
name: Download bpf-next tree | ||
uses: libbpf/ci/get-linux-source@main | ||
with: | ||
dest: '.kernel' | ||
- if: ${{ github.repository == 'kernel-patches/vmtest' }} | ||
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@v3 | ||
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: | ||
llvm-version: ${{ inputs.llvm-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: | ||
toolchain: ${{ inputs.toolchain }} | ||
kbuild-output: ${{ env.KBUILD_OUTPUT }} | ||
max-make-jobs: 32 | ||
llvm-version: ${{ inputs.llvm-version }} | ||
- if: ${{ github.event_name != 'push' }} | ||
name: Build samples | ||
uses: libbpf/ci/build-samples@main | ||
with: | ||
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@v3 | ||
with: | ||
name: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }} | ||
if-no-files-found: error | ||
path: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather we make this some kind of meaningful input argument than this reliance on global state. Do you think that's possible?