Skip to content

Commit edf3cc7

Browse files
iunanuaclaude
andcommitted
ci(release): resolve dd-trace-rs test matrix from remote tags
The release-proposal test job pinned a hardcoded list of dd-trace-rs tags, which had already gone stale (it pinned v0.4.0 as newest while v0.5.0 exists, and tested two patches of the same 0.3 line). Resolve the matrix at run time instead: list the remote tags, group them into release lines (MAJOR from 1.0.0 on, MAJOR.MINOR while MAJOR is 0, since a 0.x minor bump is breaking), and take the newest patch of each of the most recent lines. Repo, tag prefix and line count are workflow-level env vars. The resolve step runs unconditionally, unlike the neighbouring steps: a skipped step yields an empty output, and fromJSON('') in a matrix is a hard workflow error. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent ea75b04 commit edf3cc7

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

.github/workflows/release-proposal-test.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ on:
88
branches:
99
- release/**
1010
- release-testing/**
11+
12+
env:
13+
# dd-trace-rs tags to test the proposal against are resolved at run time: the newest tag of each
14+
# of the DD_TRACE_RS_LINES most recent release lines matching DD_TRACE_RS_TAG_PREFIX.
15+
DD_TRACE_RS_REPO: https://github.com/DataDog/dd-trace-rs
16+
DD_TRACE_RS_TAG_PREFIX: datadog-opentelemetry-v
17+
DD_TRACE_RS_LINES: 3
18+
1119
jobs:
1220
package-and-upload-crates:
1321
permissions:
1422
id-token: write # Enable OIDC
1523
runs-on: ubuntu-latest
1624
outputs:
1725
upload_artifact: ${{ steps.package-crates.outputs.upload_artifact }}
26+
dd_trace_rs_versions: ${{ steps.dd-trace-rs-versions.outputs.versions }}
1827
steps:
1928
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
2029
with:
@@ -78,6 +87,54 @@ jobs:
7887
cargo +1.92.0 package "${PKG_ARGS[@]}" --all-features
7988
echo "upload_artifact=true" >> "$GITHUB_OUTPUT"
8089
90+
# Resolve the dd-trace-rs versions to compile against instead of hardcoding a matrix that
91+
# goes stale. A "release line" is the SemVer-breaking component: MAJOR from 1.0.0 on, and
92+
# MAJOR.MINOR while MAJOR is 0 (a 0.x minor bump is breaking). We take the newest patch of
93+
# each of the DD_TRACE_RS_LINES most recent lines, newest line first.
94+
# Runs unconditionally (even when nothing was packaged) so the matrix expression downstream
95+
# never sees an empty string.
96+
- name: Resolve dd-trace-rs versions to test against
97+
id: dd-trace-rs-versions
98+
run: |
99+
set -euo pipefail
100+
PREFIX="${DD_TRACE_RS_TAG_PREFIX}"
101+
102+
# --refs drops the peeled `^{}` entries annotated tags produce. Pre-release tags
103+
# (e.g. -alpha.1) are filtered out; the prefix is matched literally (index/substr,
104+
# not a regex) so a prefix with regex metacharacters would still work.
105+
VERSIONS=$(git ls-remote --tags --refs "$DD_TRACE_RS_REPO" "refs/tags/${PREFIX}*" \
106+
| awk -v ref_prefix="refs/tags/${PREFIX}" '
107+
index($2, ref_prefix) == 1 {
108+
v = substr($2, length(ref_prefix) + 1)
109+
if (v ~ /^[0-9]+\.[0-9]+\.[0-9]+$/) print v
110+
}' \
111+
| sort -V)
112+
113+
if [ -z "$VERSIONS" ]; then
114+
echo "Error: no '${PREFIX}MAJOR.MINOR.PATCH' tags found in $DD_TRACE_RS_REPO." >&2
115+
exit 1
116+
fi
117+
118+
# Newest version of each release line. Input is ascending, so the last write per key wins.
119+
declare -A LATEST_BY_LINE=()
120+
while read -r version; do
121+
IFS='.' read -r major minor _patch <<< "$version"
122+
if [ "$major" = "0" ]; then
123+
LATEST_BY_LINE["0.$minor"]="$version"
124+
else
125+
LATEST_BY_LINE["$major"]="$version"
126+
fi
127+
done <<< "$VERSIONS"
128+
129+
TAGS=()
130+
while read -r line; do
131+
TAGS+=("${PREFIX}${LATEST_BY_LINE[$line]}")
132+
done < <(printf '%s\n' "${!LATEST_BY_LINE[@]}" | sort -Vr | head -n "$DD_TRACE_RS_LINES")
133+
134+
MATRIX=$(printf '%s\n' "${TAGS[@]}" | jq -R . | jq -c -s .)
135+
echo "dd-trace-rs versions to test against: $MATRIX"
136+
echo "versions=$MATRIX" >> "$GITHUB_OUTPUT"
137+
81138
- name: Upload crates
82139
if: steps.package-crates.outputs.upload_artifact == 'true'
83140
uses: actions/upload-artifact@v4
@@ -95,7 +152,7 @@ jobs:
95152
if: needs.package-and-upload-crates.outputs.upload_artifact == 'true'
96153
strategy:
97154
matrix:
98-
version: ["datadog-opentelemetry-v0.4.0", "datadog-opentelemetry-v0.3.3", "datadog-opentelemetry-v0.3.2"]
155+
version: ${{ fromJSON(needs.package-and-upload-crates.outputs.dd_trace_rs_versions) }}
99156
steps:
100157
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
101158
with:

0 commit comments

Comments
 (0)