From bfa2570a6a32c5a48748194192320a26789a8985 Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Mon, 23 Nov 2026 18:16:36 +0100 Subject: [PATCH 1/5] ci: post a stale dd-trace v5 pin to Slack instead of failing The weekly check-pin job failed on purpose whenever a new dd-trace v5 was published, which counted as a CI infra failure in Green CI. Outside of pull requests, a stale pin now posts a reminder to #apm-serverless and the job succeeds; it fails only when the check itself or the Slack post fails. check_dd_trace_v5_pin.sh exits 2 for a stale pin (still non-zero, so the GitLab npm publish gate is unchanged) and reports both versions through $GITHUB_OUTPUT. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/dd-trace-v5-pin.yml | 39 ++++++++++++++++++++++++++- scripts/check_dd_trace_v5_pin.sh | 10 ++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dd-trace-v5-pin.yml b/.github/workflows/dd-trace-v5-pin.yml index f22f5da2..fbea4746 100644 --- a/.github/workflows/dd-trace-v5-pin.yml +++ b/.github/workflows/dd-trace-v5-pin.yml @@ -4,6 +4,11 @@ name: dd-trace v5 pin freshness # scripts/dd_trace_versions.sh (the dependency-update workflow only tracks # the v6 line). Runs when the pin file changes and weekly; the same check # gates the npm publish job in GitLab. +# +# A stale pin is the expected outcome of this job, not a failure: outside of +# pull requests it posts a reminder to #apm-serverless and the job succeeds. +# The job fails only when the check itself or the Slack notification fails. +# On pull requests touching the pin, a stale pin still fails the job. on: push: @@ -33,4 +38,36 @@ jobs: node-version: "22.x" - name: Check the v5 pin against the npm registry - run: ./scripts/check_dd_trace_v5_pin.sh + id: check + run: | + status=0 + ./scripts/check_dd_trace_v5_pin.sh || status=$? + if [ "$status" -eq 2 ] && [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then + echo "stale=true" >> "$GITHUB_OUTPUT" + elif [ "$status" -ne 0 ]; then + exit "$status" + fi + + - name: Notify #apm-serverless that the pin is stale + if: steps.check.outputs.stale == 'true' + env: + # Incoming webhook bound to #apm-serverless + SLACK_WEBHOOK: ${{ secrets.SLACK_ALERTS_WEBHOOK }} + CONFIGURED: ${{ steps.check.outputs.configured }} + LATEST: ${{ steps.check.outputs.latest }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + if [ -z "$CONFIGURED" ] || [ -z "$LATEST" ]; then + echo "The check exited 2 without reporting the configured/latest versions" >&2 + exit 1 + fi + if [ -z "$SLACK_WEBHOOK" ]; then + echo "SLACK_ALERTS_WEBHOOK secret is not set" >&2 + exit 1 + fi + text=":warning: datadog-lambda-js: the dd-trace v5 pin is stale (configured \`$CONFIGURED\`, latest \`$LATEST\`). Bump \`DD_TRACE_V5_VERSION\` in \`scripts/dd_trace_versions.sh\`. <$RUN_URL|Workflow run>" + payload=$(jq -n --arg text "$text" '{text: $text, unfurl_links: false}') + # Incoming webhooks answer non-2xx on errors (revoked webhook, bad payload, ...), so --fail fails the step + curl -sS --fail-with-body -X POST "$SLACK_WEBHOOK" \ + -H "Content-Type: application/json; charset=utf-8" \ + --data "$payload" diff --git a/scripts/check_dd_trace_v5_pin.sh b/scripts/check_dd_trace_v5_pin.sh index 8f3fcf18..69db3f1f 100755 --- a/scripts/check_dd_trace_v5_pin.sh +++ b/scripts/check_dd_trace_v5_pin.sh @@ -9,6 +9,10 @@ # 1. peerDependencies no longer lists both pins. # 2. The pin lags latest published v5. Dep-update only tracks the v6 lockfile, # so 18/20 layers would ship a stale tracer. +# +# Exit codes: 0 = pin current, 2 = pin stale (case 2), 1 = anything else. +# When run in GitHub Actions, a stale pin also writes configured=/latest= to +# $GITHUB_OUTPUT so the workflow can report it. set -e @@ -50,7 +54,11 @@ fi if [ "$DD_TRACE_V5_VERSION" != "$latest_v5" ]; then echo "dd-trace v5 pin is stale: configured=$DD_TRACE_V5_VERSION latest=$latest_v5" >&2 echo "Bump DD_TRACE_V5_VERSION in scripts/dd_trace_versions.sh" >&2 - exit 1 + if [ -n "$GITHUB_OUTPUT" ]; then + echo "configured=$DD_TRACE_V5_VERSION" >> "$GITHUB_OUTPUT" + echo "latest=$latest_v5" >> "$GITHUB_OUTPUT" + fi + exit 2 fi echo "dd-trace v5 pin is current: $DD_TRACE_V5_VERSION" From d42eb602b81d5767c5d24ceba625ea8d05aaec72 Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Tue, 24 Nov 2026 10:03:03 +0100 Subject: [PATCH 2/5] ci: also alert #apm-serverless when the pin check itself fails Store the script's exit status and branch on it in the steps' if conditions: one Slack step for a stale pin, one for an unexpected check failure, and a final step that fails the job. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/dd-trace-v5-pin.yml | 47 ++++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/.github/workflows/dd-trace-v5-pin.yml b/.github/workflows/dd-trace-v5-pin.yml index fbea4746..4756cefa 100644 --- a/.github/workflows/dd-trace-v5-pin.yml +++ b/.github/workflows/dd-trace-v5-pin.yml @@ -5,10 +5,11 @@ name: dd-trace v5 pin freshness # the v6 line). Runs when the pin file changes and weekly; the same check # gates the npm publish job in GitLab. # -# A stale pin is the expected outcome of this job, not a failure: outside of -# pull requests it posts a reminder to #apm-serverless and the job succeeds. -# The job fails only when the check itself or the Slack notification fails. -# On pull requests touching the pin, a stale pin still fails the job. +# Outside of pull requests, results are reported to #apm-serverless: +# - stale pin: a reminder is posted and the job succeeds (it did its job); +# - the check itself fails: an alert is posted and the job fails. +# On pull requests, nothing is posted and any non-zero exit fails the job. +# A failing Slack notification also fails the job. on: push: @@ -39,17 +40,14 @@ jobs: - name: Check the v5 pin against the npm registry id: check + # exit codes: 0 = pin current, 2 = pin stale, anything else = the check failed run: | status=0 ./scripts/check_dd_trace_v5_pin.sh || status=$? - if [ "$status" -eq 2 ] && [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then - echo "stale=true" >> "$GITHUB_OUTPUT" - elif [ "$status" -ne 0 ]; then - exit "$status" - fi + echo "status=$status" >> "$GITHUB_OUTPUT" - name: Notify #apm-serverless that the pin is stale - if: steps.check.outputs.stale == 'true' + if: steps.check.outputs.status == '2' && github.event_name != 'pull_request' env: # Incoming webhook bound to #apm-serverless SLACK_WEBHOOK: ${{ secrets.SLACK_ALERTS_WEBHOOK }} @@ -57,17 +55,28 @@ jobs: LATEST: ${{ steps.check.outputs.latest }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | - if [ -z "$CONFIGURED" ] || [ -z "$LATEST" ]; then - echo "The check exited 2 without reporting the configured/latest versions" >&2 - exit 1 - fi - if [ -z "$SLACK_WEBHOOK" ]; then - echo "SLACK_ALERTS_WEBHOOK secret is not set" >&2 - exit 1 - fi text=":warning: datadog-lambda-js: the dd-trace v5 pin is stale (configured \`$CONFIGURED\`, latest \`$LATEST\`). Bump \`DD_TRACE_V5_VERSION\` in \`scripts/dd_trace_versions.sh\`. <$RUN_URL|Workflow run>" payload=$(jq -n --arg text "$text" '{text: $text, unfurl_links: false}') - # Incoming webhooks answer non-2xx on errors (revoked webhook, bad payload, ...), so --fail fails the step + # Incoming webhooks answer non-2xx on errors (revoked webhook, bad payload, ...) curl -sS --fail-with-body -X POST "$SLACK_WEBHOOK" \ -H "Content-Type: application/json; charset=utf-8" \ --data "$payload" + + - name: Notify #apm-serverless that the check failed + if: steps.check.outputs.status != '0' && steps.check.outputs.status != '2' && github.event_name != 'pull_request' + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_ALERTS_WEBHOOK }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + text=":x: datadog-lambda-js: the dd-trace v5 pin check unexpectedly failed. <$RUN_URL|Workflow run>" + payload=$(jq -n --arg text "$text" '{text: $text, unfurl_links: false}') + curl -sS --fail-with-body -X POST "$SLACK_WEBHOOK" \ + -H "Content-Type: application/json; charset=utf-8" \ + --data "$payload" + + - name: Fail the job + # Any failure on pull requests; outside of them, only when the check itself failed + if: steps.check.outputs.status != '0' && (steps.check.outputs.status != '2' || github.event_name == 'pull_request') + run: | + echo "check_dd_trace_v5_pin.sh exited with ${{ steps.check.outputs.status }}" >&2 + exit 1 From f9a23f6104f38d1b8ac58bbb97ceb1837a7bbbd1 Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Tue, 24 Nov 2026 10:03:51 +0100 Subject: [PATCH 3/5] ci: quote step names containing # Co-Authored-By: Claude Opus 5.5 --- .github/workflows/dd-trace-v5-pin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dd-trace-v5-pin.yml b/.github/workflows/dd-trace-v5-pin.yml index 4756cefa..5717cd92 100644 --- a/.github/workflows/dd-trace-v5-pin.yml +++ b/.github/workflows/dd-trace-v5-pin.yml @@ -46,7 +46,7 @@ jobs: ./scripts/check_dd_trace_v5_pin.sh || status=$? echo "status=$status" >> "$GITHUB_OUTPUT" - - name: Notify #apm-serverless that the pin is stale + - name: "Notify #apm-serverless that the pin is stale" if: steps.check.outputs.status == '2' && github.event_name != 'pull_request' env: # Incoming webhook bound to #apm-serverless @@ -62,7 +62,7 @@ jobs: -H "Content-Type: application/json; charset=utf-8" \ --data "$payload" - - name: Notify #apm-serverless that the check failed + - name: "Notify #apm-serverless that the check failed" if: steps.check.outputs.status != '0' && steps.check.outputs.status != '2' && github.event_name != 'pull_request' env: SLACK_WEBHOOK: ${{ secrets.SLACK_ALERTS_WEBHOOK }} From 07343e27deb7cc9fcab2b6b477596eb8117fb71f Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Tue, 24 Nov 2026 14:37:53 +0100 Subject: [PATCH 4/5] ci: treat npm registry errors as a failed pin check Without pipefail, an npm error (e.g. E503) was masked by the node pipeline and its JSON error object became the "latest" version: the check reported a stale pin and wrote a multiline value to $GITHUB_OUTPUT, which Actions rejects, so no Slack alert was sent. Keep npm's exit status and require a 5.x.y version, else exit 1. Co-Authored-By: Claude Opus 5.5 --- scripts/check_dd_trace_v5_pin.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/check_dd_trace_v5_pin.sh b/scripts/check_dd_trace_v5_pin.sh index 69db3f1f..6c127ece 100755 --- a/scripts/check_dd_trace_v5_pin.sh +++ b/scripts/check_dd_trace_v5_pin.sh @@ -35,8 +35,10 @@ fi echo "peerDependencies['dd-trace'] advertises both pins: $peer_range" -# npm may return a single string or an array of matching versions; take the last -latest_v5=$(npm view 'dd-trace@5' version --json | node -e " +# npm may return a single string or an array of matching versions; take the last. +# On registry errors npm exits non-zero and prints a JSON error object: pipefail +# keeps that exit status, and the version check rejects anything else unexpected. +latest_v5=$(set -o pipefail; npm view 'dd-trace@5' version --json | node -e " let d = ''; process.stdin .on('data', (c) => (d += c)) @@ -44,9 +46,9 @@ process.stdin const v = JSON.parse(d); console.log(Array.isArray(v) ? v[v.length - 1] : v); }); -") +") || latest_v5="" -if [ -z "$latest_v5" ]; then +if ! [[ "$latest_v5" =~ ^5\.[0-9]+\.[0-9]+$ ]]; then echo "Could not determine the latest dd-trace v5 version from the npm registry" >&2 exit 1 fi From 5a31be9caa0fde1fc0120056395847c2b515754b Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Tue, 1 Dec 2026 17:56:15 +0100 Subject: [PATCH 5/5] ci: run the dd-trace v5 pin check in the datadog-lambda-js-pin environment Co-Authored-By: Claude Opus 5.5 --- .github/workflows/dd-trace-v5-pin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dd-trace-v5-pin.yml b/.github/workflows/dd-trace-v5-pin.yml index 5717cd92..745eddbf 100644 --- a/.github/workflows/dd-trace-v5-pin.yml +++ b/.github/workflows/dd-trace-v5-pin.yml @@ -29,6 +29,7 @@ on: jobs: check-pin: runs-on: ubuntu-latest + environment: datadog-lambda-js-pin steps: - name: Checkout uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0