Skip to content

Auto upgrade system-tests #8922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
52 changes: 52 additions & 0 deletions .github/scripts/update_reference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# This script updates the reference in a YAML file.

# Check if required environment variables are set
if [ -z "$TARGET" ]; then
echo "Error: TARGET environment variable is not set"
exit 1
fi

if [ -z "$REF" ]; then
echo "Error: REF environment variable is not set"
exit 1
fi

if [ -z "$PATTERN" ]; then
echo "Error: PATTERN environment variable is not set"
exit 1
fi

echo "Target: $TARGET"
echo "Ref: $REF"

# Remove leading and trailing forward slashes from pattern
CLEAN_PATTERN=$(echo "$PATTERN" | sed 's/^\///;s/\/$//')
echo "Pattern: $CLEAN_PATTERN"

# Create a temporary file
TEMP_FILE=$(mktemp)

# Read the file and perform the substitution
if [ -f "$TARGET" ]; then
# Perform the substitution and save to temporary file
# We use perl here because sed's regex support varies across platforms
perl -pe "s/$CLEAN_PATTERN/\${1}$REF\${3}/g" "$TARGET" > "$TEMP_FILE"

# Compare files to check if any changes were made
if cmp -s "$TARGET" "$TEMP_FILE"; then
echo "No references found in $TARGET"
else
# Copy the temp file back to the target
cp "$TEMP_FILE" "$TARGET"
echo "✓ Updated references in $TARGET"
fi
else
echo "Error: Target file $TARGET does not exist"
rm -f "$TEMP_FILE"
exit 1
fi

# Clean up temporary file
rm -f "$TEMP_FILE"
3 changes: 2 additions & 1 deletion .github/workflows/run-system-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ jobs:
main:
needs:
- build
uses: DataDog/system-tests/.github/workflows/system-tests.yml@main
uses: DataDog/system-tests/.github/workflows/system-tests.yml@84c7354433427ffb4d1a48ad60166627fac8cee3 # Automated: This reference is automatically updated.
secrets: inherit
permissions:
contents: read
packages: write
with:
library: java
ref: 84c7354433427ffb4d1a48ad60166627fac8cee3 # Automated: This reference is automatically updated.
binaries_artifact: binaries
desired_execution_time: 900 # 15 minutes
scenarios_groups: tracer-release
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/update-system-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Update System Tests

on: # yamllint disable-line rule:truthy
schedule:
- cron: '0 0 * * 0' # Every Sunday at midnight
workflow_dispatch:
inputs:
ref:
description: Reference to be updated (commit hash, branch, or tag)
required: false
type: string
dry-run:
description: Skip PR creation and only show changes
required: false
type: boolean
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Default permissions for all jobs
permissions: {}

jobs:
update-system-tests:
name: "Update System Tests"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: true

- name: Checkout System Test
id: system-test-ref
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: "DataDog/system-tests"
path: system-tests
persist-credentials: false
ref: ${{ github.event.inputs.ref || '' }}

- run: .github/scripts/update_reference.sh
env:
TARGET: ".github/workflows/run-system-tests.yaml"
PATTERN: '(\s*system-tests.yml@)(\S+)(\s+# Automated:.*)'
REF: ${{ steps.system-test-ref.outputs.commit }}

- run: .github/scripts/update_reference.sh
env:
TARGET: ".github/workflows/run-system-tests.yaml"
PATTERN: '(\s*ref: )(\S+)(\s+# Automated:.*)'
REF: ${{ steps.system-test-ref.outputs.commit }}


- run: git diff --color=always

- name: Create Pull Request
if: ${{ github.event.inputs.dry-run != true }}
id: cpr
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
branch: auto-generate/update-system-tests
title: '[🤖] Update System Tests'
base: master
commit-message: "[🤖] Update System Tests: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
sign-commits: true
delete-branch: true
add-paths: |
.github/
body: |
_This is an auto-generated PR from [here](${{ github.server_url }}/${{ github.repository }}/blob/master/.github/workflows/update-system-tests.yml)_
The PR updates the system tests (Updated to commit: ${{ steps.system-test-ref.outputs.commit }})
Please review the changes and merge when ready