Skip to content

Commit b22ac71

Browse files
[build-and-test] Fix passing of github context to matrix.sh (#1317)
Summary: Passing the full github context to `matrix.sh` was unreliable, instead just pass the things we need. Type of change: /kind test-infra Test Plan: Testing with this PR, also rebasing #1316 which previously failed to make sure it doesn't anymore. Signed-off-by: James Bartlett <jamesbartlett@pixielabs.ai>
1 parent 5b9e5e1 commit b22ac71

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

.github/workflows/build_and_test.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ jobs:
6565
id: set-matrix
6666
shell: bash
6767
run: |
68-
echo '${{ toJSON(github) }}' > github.json
69-
matrix="$(./ci/github/matrix.sh github.json)"
68+
matrix="$(./ci/github/matrix.sh '${{ github.event_name }}')"
7069
echo "Build & Test matrix: ${matrix}"
7170
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
7271
- name: Upload Target Files

ci/github/matrix.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
# SPDX-License-Identifier: Apache-2.0
1818

1919
# This script outputs a github actions matrix with each of the configs we want to build and test
20-
# It takes a file with the github context as its first argument: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
21-
github_context="$1"
20+
# It takes the github event_name as its argument
2221

23-
event_name="$(jq -r '.event_name' < "${github_context}")"
24-
pr_body="$(jq -r '.event.pull_request.body' < "${github_context}")"
22+
if [[ $# -lt 1 ]]; then
23+
echo "Usage: $0 <event_name>"
24+
exit 1
25+
fi
26+
event_name="$1"
2527
commit_message="$(git log "$(git merge-base origin/main HEAD)"..HEAD --format="%B")"
26-
combined_message="${pr_body} \n${commit_message}"
2728

2829
nightly_regression_test_iterations="${NIGHTLY_REGRESSION_TEST_ITERATIONS:-5}"
2930

@@ -43,7 +44,7 @@ kernel_versions=( "${default_kernel_versions[@]}" )
4344

4445
check_tag() {
4546
tag="$1"
46-
echo "${combined_message}" | grep -P "${tag}([^\-a-zA-Z]|$)" > /dev/null
47+
echo "${commit_message}" | grep -P "${tag}([^\-a-zA-Z]|$)" > /dev/null
4748
}
4849

4950
build_deps_flags=()
@@ -58,12 +59,12 @@ elif [[ "${event_name}" == "schedule" ]]; then
5859
extra_bazel_args+=("--runs_per_test=${nightly_regression_test_iterations}")
5960
kernel_versions=( "${all_kernel_versions[@]}" )
6061
elif [[ "${event_name}" == "pull_request" ]]; then
61-
# Ignore bazel dependency tracking and run all targets if #ci:ignore-deps is in the pr body/commit message.
62+
# Ignore bazel dependency tracking and run all targets if #ci:ignore-deps is in the commit message.
6263
if check_tag '#ci:ignore-deps'; then
6364
echo "Found #ci:ignore-deps tag. Building all targets" >&2
6465
build_deps_flags+=("-a")
6566
fi
66-
# Build/Test bpf targets if #ci:bpf-build{-all-kernels} is in the pr body/commit message.
67+
# Build/Test bpf targets if #ci:bpf-build{-all-kernels} is in the commit message.
6768
if check_tag '#ci:bpf-build-all-kernels'; then
6869
echo "Found #ci:bpf-build tag. Building bpf targets" >&2
6970
build_deps_flags+=("-b")

0 commit comments

Comments
 (0)