-
Notifications
You must be signed in to change notification settings - Fork 25
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
Factor out tar-artifacts action #148
Merged
Merged
Changes from all commits
Commits
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 was deleted.
Oops, something went wrong.
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,34 @@ | ||
# Tar build artifacts | ||
|
||
This action creates a tarball with kbuild-output and other build | ||
artifacts necessary to run the selftests. | ||
|
||
The action is expected to be executed by a workflow with access to the | ||
Linux kernel repository. | ||
|
||
## Required inputs | ||
|
||
* `arch` - Kernel build architecture, required to find image_name | ||
* `archive` - path to the produced .zst archive | ||
* `kbuild-output` - Path to the kernel build output | ||
* `repo-root` - Path to the root of the Linux kernel repository | ||
|
||
# Archive options | ||
|
||
Essential content of the directory passed via `kbuild-output` input is | ||
always included in the tarball. | ||
|
||
For selftests artifacts the script checks environment variables to | ||
determine what to include. These are handled as bash flags: | ||
emptystring means false, any other value means true. | ||
|
||
* `ARCHIVE_BPF_SELFTESTS` - add `tools/testing/selftests/bpf` binaries | ||
under `selftests/bpf` in the tarball | ||
* `ARCHIVE_MAKE_HELPERS` - add all the Linux repo makefiles and other | ||
scripts | ||
* `ARCHIVE_SCHED_EXT_SELFTESTS` - add | ||
`tools/testing/selftests/sched_ext` binaries under | ||
`selftests/sched_ext` in the tarball | ||
|
||
|
||
|
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,26 @@ | ||
name: 'Tar build artifacts' | ||
inputs: | ||
arch: | ||
description: 'Target arch of the kernel, required for finding the image' | ||
required: true | ||
archive: | ||
description: 'Path to the output archive' | ||
required: true | ||
kbuild-output: | ||
description: 'Path to the kernel build output for archiving' | ||
required: true | ||
repo-root: | ||
description: "Path to the root of the kernel repository" | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Run tar-artifacts.sh | ||
env: | ||
KBUILD_OUTPUT: ${{ inputs.kbuild-output }} | ||
REPO_ROOT: ${{ inputs.repo-root }} | ||
ARCH: ${{ inputs.arch }} | ||
shell: bash | ||
run: | ||
${GITHUB_ACTION_PATH}/tar-artifacts.sh ${{ inputs.archive }} |
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,79 @@ | ||
#!/bin/bash | ||
|
||
set -eux -o pipefail | ||
|
||
if [ ! -d "${REPO_ROOT:-}" ]; then | ||
echo "REPO_ROOT must be a directory: ${REPO_ROOT}" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "${KBUILD_OUTPUT:-}" ]; then | ||
echo "KBUILD_OUTPUT must be a directory: ${KBUILD_OUTPUT}" | ||
exit 1 | ||
fi | ||
|
||
zst_tarball="$1" | ||
arch="${ARCH}" | ||
|
||
ARCHIVE_BPF_SELFTESTS="${ARCHIVE_BPF_SELFTESTS:-true}" | ||
ARCHIVE_MAKE_HELPERS="${ARCHIVE_MAKE_HELPERS:-}" | ||
ARCHIVE_SCHED_EXT_SELFTESTS="${ARCHIVE_SCHED_EXT_SELFTESTS:-}" | ||
|
||
tarball=$(mktemp ./artifacts.XXXXXXXX.tar) | ||
|
||
source "${GITHUB_ACTION_PATH}/../helpers.sh" | ||
|
||
# Strip debug information, which is excessively large (consuming | ||
# bandwidth) while not actually being used (the kernel does not use | ||
# DWARF to symbolize stacktraces). | ||
"${arch}"-linux-gnu-strip --strip-debug "${KBUILD_OUTPUT}"/vmlinux | ||
|
||
image_name=$(make -C ${REPO_ROOT} ARCH="$(platform_to_kernel_arch "${arch}")" -s image_name) | ||
kbuild_output_file_list=( | ||
".config" | ||
"${image_name}" | ||
"include/config/auto.conf" | ||
"include/generated/autoconf.h" | ||
"vmlinux" | ||
) | ||
|
||
tar -rf "${tarball}" -C "${KBUILD_OUTPUT}" \ | ||
--transform "s,^,kbuild-output/," \ | ||
"${kbuild_output_file_list[@]}" | ||
|
||
# In case artifacts are restored not to the kernel repo root, | ||
# package up a bunch of additional infrastructure to support running | ||
# 'make kernelrelease' and bpf tool checks later on. | ||
if [[ -n "${ARCHIVE_MAKE_HELPERS}" ]]; then | ||
find "${REPO_ROOT}" -iname Makefile -printf '%P\n' \ | ||
| tar -rf "${tarball}" -C "${REPO_ROOT}" -T - | ||
tar -rf "${tarball}" -C "${REPO_ROOT}" \ | ||
--exclude '*.o' \ | ||
--exclude '*.d' \ | ||
"scripts/" \ | ||
"tools/testing/selftests/bpf/" \ | ||
"tools/include/" \ | ||
"tools/bpf/bpftool/" | ||
fi | ||
|
||
if [[ -n "${ARCHIVE_BPF_SELFTESTS}" ]]; then | ||
# add .bpf.o files | ||
find "${REPO_ROOT}/tools/testing/selftests/bpf" \ | ||
-name "*.bpf.o" -printf 'selftests/bpf/%P\n' \ | ||
| tar -rf "${tarball}" -C "${REPO_ROOT}/tools/testing" -T - | ||
# add other relevant files | ||
tar -rf "${tarball}" -C "${REPO_ROOT}/tools/testing" \ | ||
--exclude '*.cmd' \ | ||
--exclude '*.d' \ | ||
--exclude '*.h' \ | ||
--exclude '*.o' \ | ||
--exclude '*.output' \ | ||
selftests/bpf/ | ||
fi | ||
|
||
if [[ -n "${ARCHIVE_SCHED_EXT_SELFTESTS}" ]]; then | ||
tar -rf "${tarball}" -C "${REPO_ROOT}/tools/testing" selftests/sched_ext/ | ||
fi | ||
|
||
zstd -T0 -19 -i "${tarball}" -o "${zst_tarball}" | ||
|
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.
thought for later: maybe we should move this out of libbpf/ci eventually and let the caller set it through an env var or input (probably preferred)
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.
Right, this is why I made them env vars in the first place. They are set in the workflow step right now, I guess you're talking about a case when the workflow itself is called from outside.
When we figure out how to actually use reusable workflows in kernel-patches/vmtest, this might be worth revisiting.