Skip to content

Commit 4f9d9ce

Browse files
authored
fix(ci): fix DAG-scoped builds for connector plugins and multi-crate PRs (#3120)
The DAG-scoped build filter selected packages with `"bin"` targets but missed `"cdylib"` targets, so connector plugin `.so` files (e.g. `libiggy_connector_http_sink.so`) were never compiled.
1 parent aa34566 commit 4f9d9ce

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

.github/actions/rust/pre-merge/action.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ runs:
8181
METADATA_JSON=$(cargo metadata --format-version 1 --no-deps 2>/dev/null || echo "{}")
8282
TOTAL_CRATES=$(echo "$METADATA_JSON" | jq '.workspace_members | length' 2>/dev/null || echo "?")
8383
echo "$TOTAL_CRATES" > /tmp/total-crates.txt
84-
# Extract packages with binary targets — integration tests may invoke
85-
# binaries from other packages via assert_cmd (CARGO_BIN_EXE_<name>),
86-
# so these must always be compiled alongside affected crates.
87-
echo "$METADATA_JSON" | jq -r '.packages[] | select(.targets[] | .kind[] == "bin") | .name' 2>/dev/null > /tmp/bin-packages.txt || true
84+
# Extract packages with binary or cdylib targets — integration tests may
85+
# invoke binaries via assert_cmd (CARGO_BIN_EXE_<name>), and connector
86+
# plugins (cdylib) are loaded at runtime via dlopen by iggy-connectors.
87+
# Both must always be compiled alongside affected crates.
88+
echo "$METADATA_JSON" | jq -r '.packages[] | select(.targets[] | .kind[] | (. == "bin" or . == "cdylib")) | .name' 2>/dev/null > /tmp/bin-packages.txt || true
8889
8990
PLAN_JSON=$(cargo rail plan --since origin/master -f json 2>/tmp/affected-stderr.txt || echo "")
9091
@@ -94,13 +95,13 @@ runs:
9495
CRATES=$(echo "$PLAN_JSON" | jq -r '.scope.crates[]')
9596
CRATE_COUNT=$(echo "$CRATES" | wc -l)
9697
# Build nextest filter expression for cargo nextest run (affected crates only)
97-
echo "$CRATES" | sed 's/^/package(/; s/$/)/' | paste -sd ' | ' > /tmp/nextest-filter.txt
98+
echo "$CRATES" | sed 's/^/package(/; s/$/)/' | paste -sd '|' | sed 's/|/ | /g' > /tmp/nextest-filter.txt
9899
# Save affected-only -p flags for cargo test fallback (no nextest filter)
99100
echo "$CRATES" | sed 's/^/-p /' | tr '\n' ' ' > /tmp/test-packages.txt
100-
# Build -p flags: affected crates + packages with binary targets.
101-
# cargo nextest sets CARGO_BIN_EXE_<name> from compiled binary
102-
# artifacts, so binary packages must be in the build to avoid
103-
# "CARGO_BIN_EXE_<name> is unset" panics in assert_cmd tests.
101+
# Build -p flags: affected crates + packages with bin/cdylib targets.
102+
# Binary packages: nextest sets CARGO_BIN_EXE_<name> from compiled
103+
# artifacts; cdylib packages: connector plugins loaded via dlopen.
104+
# Both must be in the build even if not directly in the DAG scope.
104105
BIN_PKGS=$(cat /tmp/bin-packages.txt 2>/dev/null || echo "")
105106
ALL_BUILD_PKGS=$(printf '%s\n%s\n' "$CRATES" "$BIN_PKGS" | sort -u | grep -v '^$')
106107
echo "$ALL_BUILD_PKGS" | sed 's/^/-p /' | tr '\n' ' ' > /tmp/packages.txt
@@ -236,7 +237,7 @@ runs:
236237
test_start=$(date +%s)
237238
if command -v cargo-nextest &> /dev/null; then
238239
if [[ -n "$NEXTEST_FILTER" ]]; then
239-
cargo nextest run --locked --no-fail-fast --profile ci $PARTITION_FLAG -E "$NEXTEST_FILTER"
240+
cargo nextest run --locked --no-fail-fast --profile ci $PARTITION_FLAG $PACKAGE_FLAGS -E "$NEXTEST_FILTER"
240241
else
241242
cargo nextest run --locked --no-fail-fast --profile ci $PARTITION_FLAG
242243
fi

0 commit comments

Comments
 (0)