Skip to content

Commit f865ee4

Browse files
author
Kernel Patches Daemon
committed
adding ci files
1 parent 95dbe21 commit f865ee4

40 files changed

+3263
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: 'run-veristat'
2+
description: 'Run veristat benchmark'
3+
inputs:
4+
veristat_output:
5+
description: 'Veristat output filepath'
6+
required: true
7+
baseline_name:
8+
description: 'Veristat baseline cache name'
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- uses: actions/upload-artifact@v4
14+
with:
15+
name: ${{ inputs.baseline_name }}
16+
if-no-files-found: error
17+
path: ${{ github.workspace }}/${{ inputs.veristat_output }}
18+
19+
# For pull request:
20+
# - get baseline log from cache
21+
# - compare it to current run
22+
- if: ${{ github.event_name == 'pull_request' }}
23+
uses: actions/cache/restore@v4
24+
with:
25+
key: ${{ github.base_ref }}-${{ inputs.baseline_name }}-
26+
restore-keys: |
27+
${{ github.base_ref }}-${{ inputs.baseline_name }}
28+
path: '${{ github.workspace }}/${{ inputs.baseline_name }}'
29+
30+
- if: ${{ github.event_name == 'pull_request' }}
31+
name: Show veristat comparison
32+
shell: bash
33+
run: ./.github/scripts/compare-veristat-results.sh
34+
env:
35+
BASELINE_PATH: ${{ github.workspace }}/${{ inputs.baseline_name }}
36+
VERISTAT_OUTPUT: ${{ inputs.veristat_output }}
37+
38+
# For push: just put baseline log to cache
39+
- if: ${{ github.event_name == 'push' }}
40+
shell: bash
41+
run: |
42+
mv "${{ github.workspace }}/${{ inputs.veristat_output }}" \
43+
"${{ github.workspace }}/${{ inputs.baseline_name }}"
44+
45+
- if: ${{ github.event_name == 'push' }}
46+
uses: actions/cache/save@v4
47+
with:
48+
key: ${{ github.ref_name }}-${{ inputs.baseline_name }}-${{ github.run_id }}
49+
path: '${{ github.workspace }}/${{ inputs.baseline_name }}'
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
veristat=$(realpath selftests/bpf/veristat)
4+
5+
# Dump verifier logs for a list of programs
6+
# Usage: dump_failed_logs <progs_file>
7+
# - progs_file: file with lines of format "file_name,prog_name"
8+
dump_failed_logs() {
9+
local progs_file="$1"
10+
local objects_dir="${VERISTAT_OBJECTS_DIR:-$(pwd)}"
11+
12+
while read -r line; do
13+
local file prog
14+
file=$(echo "$line" | cut -d',' -f1)
15+
prog=$(echo "$line" | cut -d',' -f2)
16+
echo "VERIFIER LOG FOR $file/$prog:"
17+
echo "=================================================================="
18+
$veristat -v "$objects_dir/$file" -f "$prog"
19+
echo "=================================================================="
20+
done < "$progs_file"
21+
}
22+
23+
if [[ ! -f "${BASELINE_PATH}" ]]; then
24+
echo "# No ${BASELINE_PATH} available" >> "${GITHUB_STEP_SUMMARY}"
25+
26+
echo "No ${BASELINE_PATH} available"
27+
echo "Printing veristat results"
28+
cat "${VERISTAT_OUTPUT}"
29+
30+
if [[ -n "$VERISTAT_DUMP_LOG_ON_FAILURE" ]]; then
31+
failed_progs=$(mktemp failed_progs_XXXXXX.txt)
32+
awk -F',' '$3 == "failure" { print $1","$2 }' "${VERISTAT_OUTPUT}" > "$failed_progs"
33+
if [[ -s "$failed_progs" ]]; then
34+
echo && dump_failed_logs "$failed_progs"
35+
fi
36+
rm -f "$failed_progs"
37+
fi
38+
39+
echo "$(basename "$0"): no baseline provided for veristat output"
40+
echo "VERISTAT JOB PASSED"
41+
exit 0
42+
fi
43+
44+
cmp_out=$(mktemp veristate_compare_out_XXXXXX.csv)
45+
46+
$veristat \
47+
--output-format csv \
48+
--emit file,prog,verdict,states \
49+
--compare "${BASELINE_PATH}" "${VERISTAT_OUTPUT}" > $cmp_out
50+
51+
python3 ./.github/scripts/veristat_compare.py $cmp_out
52+
exit_code=$?
53+
54+
# print verifier log for progs that failed to load
55+
if [[ -n "$VERISTAT_DUMP_LOG_ON_FAILURE" ]]; then
56+
failed_progs=$(mktemp failed_progs_XXXXXX.txt)
57+
awk -F',' '$4 == "failure" { print $1","$2 }' "$cmp_out" > "$failed_progs"
58+
if [[ -s "$failed_progs" ]]; then
59+
echo && dump_failed_logs "$failed_progs"
60+
fi
61+
rm -f "$failed_progs"
62+
fi
63+
64+
if [[ $exit_code -eq 0 ]]; then
65+
echo "$(basename "$0"): veristat output matches the baseline"
66+
echo "VERISTAT JOB PASSED"
67+
else
68+
echo "$(basename "$0"): veristat output does not match the baseline"
69+
echo "VERISTAT JOB FAILED"
70+
fi
71+
72+
exit $exit_code
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
GCC_BPF_RELEASE_GH_REPO=$1
6+
INSTALL_DIR=$(realpath $2)
7+
8+
cd /tmp
9+
10+
if ! command -v gh &> /dev/null; then
11+
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md
12+
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
13+
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
14+
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
15+
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
16+
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
17+
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
18+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
19+
&& sudo apt update \
20+
&& sudo apt install gh -y
21+
fi
22+
23+
tag=$(gh release list -L 1 -R ${GCC_BPF_RELEASE_GH_REPO} --json tagName -q .[].tagName)
24+
if [[ -z "$tag" ]]; then
25+
echo "Could not find latest GCC BPF release at ${GCC_BPF_RELEASE_GH_REPO}"
26+
exit 1
27+
fi
28+
29+
url="https://github.com/${GCC_BPF_RELEASE_GH_REPO}/releases/download/${tag}/${tag}.tar.zst"
30+
echo "Downloading $url"
31+
wget -q "$url"
32+
33+
tarball=${tag}.tar.zst
34+
dir=$(tar tf $tarball | head -1 || true)
35+
36+
echo "Extracting $tarball ..."
37+
tar -I zstd -xf $tarball && rm -f $tarball
38+
39+
rm -rf $INSTALL_DIR
40+
mv -v $dir $INSTALL_DIR
41+
42+
cd -

0 commit comments

Comments
 (0)