Skip to content

Commit 32585d0

Browse files
committed
Add update-system-tests workflow
1 parent f92a95e commit 32585d0

File tree

4 files changed

+129
-2
lines changed

4 files changed

+129
-2
lines changed

.github/scripts/update_reference.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# This script updates the reference in a YAML file.
4+
5+
# Check if required environment variables are set
6+
if [ -z "$TARGET" ]; then
7+
echo "Error: TARGET environment variable is not set"
8+
exit 1
9+
fi
10+
11+
if [ -z "$REF" ]; then
12+
echo "Error: REF environment variable is not set"
13+
exit 1
14+
fi
15+
16+
if [ -z "$PATTERN" ]; then
17+
echo "Error: PATTERN environment variable is not set"
18+
exit 1
19+
fi
20+
21+
echo "Target: $TARGET"
22+
echo "Ref: $REF"
23+
24+
# Remove leading and trailing forward slashes from pattern
25+
CLEAN_PATTERN=$(echo "$PATTERN" | sed 's/^\///;s/\/$//')
26+
echo "Pattern: $CLEAN_PATTERN"
27+
28+
# Create a temporary file
29+
TEMP_FILE=$(mktemp)
30+
31+
# Set trap to cleanup on script exit
32+
trap 'rm -f "$TEMP_FILE"' EXIT
33+
34+
# Read the file and perform the substitution
35+
if [ -f "$TARGET" ]; then
36+
# Perform the substitution and save to temporary file
37+
# We use perl here because sed's regex support varies across platforms
38+
perl -pe "s/$CLEAN_PATTERN/\${1}$REF\${3}/g" "$TARGET" > "$TEMP_FILE"
39+
40+
# Compare files to check if any changes were made
41+
if cmp -s "$TARGET" "$TEMP_FILE"; then
42+
echo "No references found in $TARGET"
43+
else
44+
# Copy the temp file back to the target
45+
cp "$TEMP_FILE" "$TARGET"
46+
echo "✓ Updated references in $TARGET"
47+
fi
48+
else
49+
echo "Error: Target file $TARGET does not exist"
50+
exit 1
51+
fi

.github/workflows/parametric-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ on:
3131
permissions:
3232
contents: read
3333

34+
env:
35+
SYSTEM_TESTS_REF: 08e171d1bcde254e7ca5057ee9ffab2fffcd330a # Automated: This reference is automatically updated.
36+
3437
jobs:
3538
parametric-tests:
3639
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'DataDog/dd-trace-go')
@@ -43,7 +46,7 @@ jobs:
4346
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
4447
with:
4548
repository: 'DataDog/system-tests'
46-
ref: ${{ inputs.ref }}
49+
ref: ${{ inputs.ref || env.SYSTEM_TESTS_REF }}
4750

4851
- name: Checkout dd-trace-go
4952
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

.github/workflows/system-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ on:
3131
permissions:
3232
contents: read
3333

34+
env:
35+
SYSTEM_TESTS_REF: 08e171d1bcde254e7ca5057ee9ffab2fffcd330a # Automated: This reference is automatically updated.
36+
3437
jobs:
3538
system-tests:
3639
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'DataDog/dd-trace-go')
@@ -130,7 +133,7 @@ jobs:
130133
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
131134
with:
132135
repository: 'DataDog/system-tests'
133-
ref: ${{ inputs.ref }}
136+
ref: ${{ inputs.ref || env.SYSTEM_TESTS_REF }}
134137

135138
- name: Checkout dd-trace-go
136139
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Update System Tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0' # Every Sunday at midnight
6+
workflow_dispatch:
7+
inputs:
8+
ref:
9+
description: Reference to be updated (commit hash, branch, or tag)
10+
required: false
11+
type: string
12+
dry-run:
13+
description: Skip PR creation and only show changes
14+
required: false
15+
type: boolean
16+
default: false
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
# Default permissions for all jobs
23+
permissions: {}
24+
25+
jobs:
26+
update-system-tests:
27+
name: "Update System Tests"
28+
runs-on: ubuntu-24.04
29+
steps:
30+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31+
with:
32+
persist-credentials: true
33+
34+
- name: Checkout System Test
35+
id: system-test-ref
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
with:
38+
repository: "DataDog/system-tests"
39+
path: system-tests
40+
persist-credentials: false
41+
ref: ${{ github.event.inputs.ref || '' }}
42+
43+
# TODO: Implement replacement with pattern
44+
45+
# - run: .github/scripts/update_reference.sh
46+
# env:
47+
# TARGET: ".github/workflows/system-tests.yml"
48+
# PATTERN: '(\s*SYSTEM_TESTS_REF:\s+)(\S+)(\s+# Automated:.*)'
49+
# REF: ${{ steps.system-test-ref.outputs.commit }}
50+
51+
- run: git diff --color=always
52+
53+
- name: Create Pull Request
54+
if: ${{ github.event.inputs.dry-run != true }}
55+
id: cpr
56+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
57+
with:
58+
branch: auto-generate/update-system-tests
59+
title: '[🤖] Update System Tests'
60+
base: main
61+
# labels: dev/internal
62+
commit-message: "[🤖] Update System Tests: ${{github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
63+
delete-branch: true
64+
sign-commits: true
65+
add-paths: |
66+
.github/
67+
body: |
68+
_This is an auto-generated PR from [here](${{github.server_url}}/${{ github.repository }}/blob/master/.github/workflows/update-system-tests.yml)_
69+
The PR updates the system tests (Updated to commit: ${{ steps.system-test-ref.outputs.commit }})
70+
Please review the changes and merge when ready

0 commit comments

Comments
 (0)