diff --git a/.github/workflows/create-release-branch.yaml b/.github/workflows/create-release-branch.yaml index e38254ac29f..b690edf2161 100644 --- a/.github/workflows/create-release-branch.yaml +++ b/.github/workflows/create-release-branch.yaml @@ -119,7 +119,7 @@ jobs: 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 + git commit -m "chore: Pin system-tests for release branch" .github/workflows/run-system-tests.yaml .gitlab-ci.yml echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Push changes diff --git a/.github/workflows/run-system-tests.yaml b/.github/workflows/run-system-tests.yaml index 0463d76ac36..9b97ea5c167 100644 --- a/.github/workflows/run-system-tests.yaml +++ b/.github/workflows/run-system-tests.yaml @@ -62,7 +62,7 @@ jobs: needs: - build # 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 + uses: DataDog/system-tests/.github/workflows/system-tests.yml@main # system tests are pinned on release branches only secrets: TEST_OPTIMIZATION_API_KEY: ${{ secrets.DATADOG_API_KEY_PROD }} permissions: @@ -72,7 +72,7 @@ jobs: 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 + ref: main # system tests are pinned on release branches only binaries_artifact: binaries desired_execution_time: 900 # 15 minutes scenarios_groups: tracer-release diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36618494552..d8527784e80 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1071,6 +1071,7 @@ publishing-gate: configure_system_tests: variables: + SYSTEM_TESTS_REF: main # system tests are pinned on release branches only SYSTEM_TESTS_SCENARIOS_GROUPS: "simple_onboarding,simple_onboarding_profiling,simple_onboarding_appsec,docker-ssi,lib-injection" create_key: diff --git a/tooling/update_system_test_reference.sh b/tooling/update_system_test_reference.sh index 951fe8e4b1d..9271a414e83 100755 --- a/tooling/update_system_test_reference.sh +++ b/tooling/update_system_test_reference.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -# This script updates the system-tests reference in run-system-tests.yaml. +# This script updates the system-tests references used by GitHub Actions (run-system-tests.yaml) and GitLab CI (.gitlab-ci.yml). # 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= tooling/update_system_test_reference.sh @@ -11,9 +11,11 @@ if [ -z "${BRANCH:-}" ]; then 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 +GITHUB_TARGET=".github/workflows/run-system-tests.yaml" +GITLAB_TARGET=".gitlab-ci.yml" +GITHUB_PATTERN_1='(\s*system-tests\.yml@)(\S+)(\s+# system tests.*)' # pattern to update the "system-tests.yml@" reference +GITHUB_PATTERN_2='(\s*ref: )(\S+)(\s+# system tests.*)' # pattern to update the "ref:" reference +GITLAB_PATTERN='(\s*SYSTEM_TESTS_REF:\s*)(\S+)(\s+# system tests.*)' # pattern to update the GitLab SYSTEM_TESTS_REF variable 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) @@ -23,8 +25,13 @@ if [ -z "$REF" ]; then fi echo "Fetched SHA: $REF" -if [ ! -f "$TARGET" ]; then - echo "Error: Target file $TARGET does not exist" +if [ ! -f "$GITHUB_TARGET" ]; then + echo "Error: Target file $GITHUB_TARGET does not exist" + exit 1 +fi + +if [ ! -f "$GITLAB_TARGET" ]; then + echo "Error: Target file $GITLAB_TARGET does not exist" exit 1 fi @@ -33,13 +40,18 @@ 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" +perl -pe "s/$GITHUB_PATTERN_1/\${1}$REF\${3}/g" "$GITHUB_TARGET" > "$TEMP_FILE" +cp "$TEMP_FILE" "$GITHUB_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" +perl -pe "s/$GITHUB_PATTERN_2/\${1}$REF\${3}/g" "$GITHUB_TARGET" > "$TEMP_FILE" +cp "$TEMP_FILE" "$GITHUB_TARGET" + +# Update the GitLab SYSTEM_TESTS_REF variable +echo "Updating 'SYSTEM_TESTS_REF' reference..." +perl -pe "s/$GITLAB_PATTERN/\${1}$REF\${3}/g" "$GITLAB_TARGET" > "$TEMP_FILE" +cp "$TEMP_FILE" "$GITLAB_TARGET" # Clean up temporary file rm -f "$TEMP_FILE"