Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/chainguard/self.update-system-tests.push.sts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
issuer: https://token.actions.githubusercontent.com

subject: repo:DataDog/dd-trace-java:ref:refs/(heads/master|tags/v[0-9]+.[0-9]+.0)

claim_pattern:
event_name: (push|workflow_dispatch)
ref: refs/(heads/master|tags/v[0-9]+\.[0-9]+\.0)
ref_protected: "true"
job_workflow_ref: DataDog/dd-trace-java/\.github/workflows/create-release-branch\.yaml@refs/heads/master

permissions:
contents: write
84 changes: 84 additions & 0 deletions .github/workflows/create-release-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Create Release Branch and Pin System-Tests

on:
push:
tags:
- 'v[0-9]+.[0-9]+.0' # Trigger on minor release tags (e.g. v1.54.0)
workflow_dispatch:
inputs:
tag:
description: 'The minor release tag (e.g. v1.54.0)'
required: true
type: string

jobs:
create-release-branch:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Required for OIDC token federation
steps:
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
id: octo-sts
with:
scope: DataDog/dd-trace-java
policy: self.update-system-tests.push

- name: Determine tag
id: determine-tag
run: |
if [ -n "${{ github.event.inputs.tag }}" ]; then
TAG=${{ github.event.inputs.tag }}
else
TAG=${GITHUB_REF#refs/tags/}
fi
if ! [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then
echo "Error: Tag $TAG is not in the expected format: vX.Y.0"
exit 1
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"

- name: Define branch name from tag
id: define-branch
run: |
TAG=${{ steps.determine-tag.outputs.tag }}
BRANCH="release/${TAG%.0}.x"
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"

- name: Checkout dd-trace-java
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0

- name: Check if branch already exists
id: check-branch
run: |
BRANCH=${{ steps.define-branch.outputs.branch }}
if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
echo "creating_new_branch=false" >> "$GITHUB_OUTPUT"
echo "Branch $BRANCH already exists - skipping following steps"
else
echo "creating_new_branch=true" >> "$GITHUB_OUTPUT"
echo "Branch $BRANCH does not exist - proceeding with following steps"
fi

- name: Update system-tests references to latest commit SHA on main
if: steps.check-branch.outputs.creating_new_branch == 'true'
run: BRANCH=main ./tooling/update_system_test_reference.sh

- name: Commit changes
if: steps.check-branch.outputs.creating_new_branch == 'true'
id: create-commit
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "chore: Pin system-tests for release branch" .github/workflows/run-system-tests.yaml
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Push changes
if: steps.check-branch.outputs.creating_new_branch == 'true'
uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1
with:
token: "${{ steps.octo-sts.outputs.token }}"
branch: "${{ steps.define-branch.outputs.branch }}"
branch-from: "${{ github.sha }}"
command: push
commits: "${{ steps.create-commit.outputs.commit }}"
5 changes: 4 additions & 1 deletion .github/workflows/run-system-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ jobs:
main:
needs:
- build
uses: DataDog/system-tests/.github/workflows/system-tests.yml@main
# If you change the following comment, update the pattern in the update_system_test_reference.sh script to match.
uses: DataDog/system-tests/.github/workflows/system-tests.yml@main # system tests are pinned for releases only
secrets: inherit
permissions:
contents: read
id-token: write
packages: write
with:
library: java
# If you change the following comment, update the pattern in the update_system_test_reference.sh script to match.
ref: main # system tests are pinned for releases only
binaries_artifact: binaries
desired_execution_time: 900 # 15 minutes
scenarios_groups: tracer-release
Expand Down
47 changes: 47 additions & 0 deletions tooling/update_system_test_reference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -euo pipefail

# This script updates the system-tests reference in run-system-tests.yaml.
# The reference will be updated with the latest commit SHA of the given branch (or `main` if not set) of https://github.com/DataDog/system-tests.
# Usage: BRANCH=<branch-name> tooling/update_system_test_reference.sh

# Set BRANCH to main if not set
if [ -z "${BRANCH:-}" ]; then
BRANCH="main"
echo "BRANCH is not set. Defaulting to 'main'."
fi

TARGET=".github/workflows/run-system-tests.yaml" # target file to update
PATTERN_1='(\s*system-tests\.yml@)(\S+)(\s+# system tests.*)' # pattern to update the "system-tests.yml@" reference
PATTERN_2='(\s*ref: )(\S+)(\s+# system tests.*)' # pattern to update the "ref:" reference

echo "Fetching latest commit SHA for system-tests branch: $BRANCH"
REF=$(git ls-remote https://github.com/DataDog/system-tests "refs/heads/$BRANCH" | cut -f 1)
if [ -z "$REF" ]; then
echo "Error: Failed to fetch commit SHA for branch $BRANCH"
exit 1
fi
echo "Fetched SHA: $REF"

if [ ! -f "$TARGET" ]; then
echo "Error: Target file $TARGET does not exist"
exit 1
fi

# Save the substitution results to a temporary file first
TEMP_FILE=$(mktemp)

# Update the "system-tests.yml@" reference
echo "Updating 'system-tests.yml@' reference..."
perl -pe "s/$PATTERN_1/\${1}$REF\${3}/g" "$TARGET" > "$TEMP_FILE"
cp "$TEMP_FILE" "$TARGET"

# Update the "ref:" reference
echo "Updating 'ref:' reference..."
perl -pe "s/$PATTERN_2/\${1}$REF\${3}/g" "$TARGET" > "$TEMP_FILE"
cp "$TEMP_FILE" "$TARGET"

# Clean up temporary file
rm -f "$TEMP_FILE"

echo "Done updating system-tests references to $REF"