Skip to content

Commit 3532e4a

Browse files
committed
Setup auto update system-tests
1 parent 1205c9a commit 3532e4a

File tree

3 files changed

+120
-1
lines changed

3 files changed

+120
-1
lines changed

.github/scripts/update_reference.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
# Read the file and perform the substitution
32+
if [ -f "$TARGET" ]; then
33+
# Perform the substitution and save to temporary file
34+
# We use perl here because sed's regex support varies across platforms
35+
perl -pe "s/$CLEAN_PATTERN/\${1}$REF\${3}/g" "$TARGET" > "$TEMP_FILE"
36+
37+
# Compare files to check if any changes were made
38+
if cmp -s "$TARGET" "$TEMP_FILE"; then
39+
echo "No references found in $TARGET"
40+
else
41+
# Copy the temp file back to the target
42+
cp "$TEMP_FILE" "$TARGET"
43+
echo "✓ Updated references in $TARGET"
44+
fi
45+
else
46+
echo "Error: Target file $TARGET does not exist"
47+
rm -f "$TEMP_FILE"
48+
exit 1
49+
fi
50+
51+
# Clean up temporary file
52+
rm -f "$TEMP_FILE"

.github/workflows/run-system-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
main:
5151
needs:
5252
- build
53-
uses: DataDog/system-tests/.github/workflows/system-tests.yml@main
53+
uses: DataDog/system-tests/.github/workflows/system-tests.yml@main # Automated: This reference is automatically updated.
5454
secrets: inherit
5555
permissions:
5656
contents: read
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Update System Tests
2+
3+
on: # yamllint disable-line rule:truthy
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+
- run: .github/scripts/update_reference.sh
44+
env:
45+
TARGET: ".github/workflows/run-system-tests.yaml"
46+
PATTERN: '(\s*system-tests.yml@)(\S+)(\s+# Automated:.*)'
47+
REF: ${{ steps.system-test-ref.outputs.commit }}
48+
49+
- run: git diff --color=always
50+
51+
- name: Create Pull Request
52+
if: ${{ github.event.inputs.dry-run != true }}
53+
id: cpr
54+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
55+
with:
56+
branch: auto-generate/update-system-tests
57+
title: '[🤖] Update System Tests'
58+
base: master
59+
commit-message: "[🤖] Update System Tests: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
60+
sign-commits: true
61+
delete-branch: true
62+
add-paths: |
63+
.github/
64+
body: |
65+
_This is an auto-generated PR from [here](${{ github.server_url }}/${{ github.repository }}/blob/master/.github/workflows/update-system-tests.yml)_
66+
The PR updates the system tests (Updated to commit: ${{ steps.system-test-ref.outputs.commit }})
67+
Please review the changes and merge when ready

0 commit comments

Comments
 (0)