|
| 1 | +name: Update smoke test latest versions |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: "0 5 * * 0" |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + update-smoke-test-latest-versions: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + name: Update smoke test latest versions |
| 11 | + permissions: |
| 12 | + contents: read |
| 13 | + id-token: write # Required for OIDC token federation |
| 14 | + steps: |
| 15 | + - uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3 |
| 16 | + id: octo-sts |
| 17 | + with: |
| 18 | + scope: DataDog/dd-trace-java |
| 19 | + policy: self.update-smoke-test-latest-versions.create-pr |
| 20 | + |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2 |
| 23 | + |
| 24 | + - name: Define branch name |
| 25 | + id: define-branch |
| 26 | + run: | |
| 27 | + DATE=$(date +'%Y%m%d') |
| 28 | + echo "branch=ci/update-smoke-test-latest-versions-${DATE}" >> "$GITHUB_OUTPUT" |
| 29 | +
|
| 30 | + - name: Fetch latest Gradle version |
| 31 | + id: gradle |
| 32 | + run: | |
| 33 | + VERSION=$(curl -sf https://services.gradle.org/versions/current | jq -r '.version') |
| 34 | + if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then |
| 35 | + echo "::error::Failed to fetch latest Gradle version" |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 39 | + echo "Latest Gradle version: $VERSION" |
| 40 | +
|
| 41 | + - name: Fetch latest stable Maven version |
| 42 | + id: maven |
| 43 | + run: | |
| 44 | + METADATA=$(curl -sf https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/maven-metadata.xml) |
| 45 | + # Get all versions, filter out alpha/beta/rc, take the latest |
| 46 | + VERSION=$(echo "$METADATA" \ |
| 47 | + | xmllint --xpath '//versions/version/text()' - 2>/dev/null \ |
| 48 | + | tr ' ' '\n' \ |
| 49 | + | grep -v -E '(alpha|beta|rc)' \ |
| 50 | + | sort -V \ |
| 51 | + | tail -1) |
| 52 | + if [ -z "$VERSION" ]; then |
| 53 | + echo "::error::Failed to fetch latest stable Maven version" |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 57 | + echo "Latest stable Maven version: $VERSION" |
| 58 | +
|
| 59 | + - name: Fetch latest stable Maven Surefire version |
| 60 | + id: surefire |
| 61 | + run: | |
| 62 | + METADATA=$(curl -sf https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml) |
| 63 | + # Get all versions, filter out alpha/beta, take the latest |
| 64 | + VERSION=$(echo "$METADATA" \ |
| 65 | + | xmllint --xpath '//versions/version/text()' - 2>/dev/null \ |
| 66 | + | tr ' ' '\n' \ |
| 67 | + | grep -v -E '(alpha|beta)' \ |
| 68 | + | sort -V \ |
| 69 | + | tail -1) |
| 70 | + if [ -z "$VERSION" ]; then |
| 71 | + echo "::error::Failed to fetch latest stable Maven Surefire version" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 75 | + echo "Latest stable Maven Surefire version: $VERSION" |
| 76 | +
|
| 77 | + - name: Update properties files |
| 78 | + env: |
| 79 | + GRADLE_VERSION: ${{ steps.gradle.outputs.version }} |
| 80 | + MAVEN_VERSION: ${{ steps.maven.outputs.version }} |
| 81 | + SUREFIRE_VERSION: ${{ steps.surefire.outputs.version }} |
| 82 | + run: | |
| 83 | + printf '%s\n' \ |
| 84 | + "# Pinned \"latest\" versions for CI Visibility Gradle smoke tests." \ |
| 85 | + "# Updated automatically by the update-smoke-test-latest-versions workflow." \ |
| 86 | + "gradle.version=${GRADLE_VERSION}" \ |
| 87 | + > dd-smoke-tests/gradle/src/test/resources/latest-tool-versions.properties |
| 88 | +
|
| 89 | + printf '%s\n' \ |
| 90 | + "# Pinned \"latest\" versions for CI Visibility Maven smoke tests." \ |
| 91 | + "# Updated automatically by the update-smoke-test-latest-versions workflow." \ |
| 92 | + "maven.version=${MAVEN_VERSION}" \ |
| 93 | + "maven-surefire.version=${SUREFIRE_VERSION}" \ |
| 94 | + > dd-smoke-tests/maven/src/test/resources/latest-tool-versions.properties |
| 95 | +
|
| 96 | + - name: Check for changes |
| 97 | + id: check-changes |
| 98 | + run: | |
| 99 | + if [[ -z "$(git status -s)" ]]; then |
| 100 | + echo "No changes to commit." |
| 101 | + echo "has_changes=false" >> "$GITHUB_OUTPUT" |
| 102 | + else |
| 103 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 104 | + fi |
| 105 | +
|
| 106 | + - name: Configure git |
| 107 | + if: steps.check-changes.outputs.has_changes == 'true' |
| 108 | + run: | |
| 109 | + git config user.name "github-actions[bot]" |
| 110 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 111 | +
|
| 112 | + - name: Create commit |
| 113 | + if: steps.check-changes.outputs.has_changes == 'true' |
| 114 | + id: create-commit |
| 115 | + run: | |
| 116 | + git add dd-smoke-tests/gradle/src/test/resources/latest-tool-versions.properties \ |
| 117 | + dd-smoke-tests/maven/src/test/resources/latest-tool-versions.properties |
| 118 | + git commit -m "chore: Update smoke test latest tool versions" |
| 119 | + echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 120 | +
|
| 121 | + - name: Push changes |
| 122 | + if: steps.check-changes.outputs.has_changes == 'true' |
| 123 | + uses: DataDog/commit-headless@05d7b7ee023e2c7d01c47832d420c2503cd416f3 # action/v2.0.3 |
| 124 | + with: |
| 125 | + token: "${{ steps.octo-sts.outputs.token }}" |
| 126 | + branch: "${{ steps.define-branch.outputs.branch }}" |
| 127 | + head-sha: "${{ github.sha }}" |
| 128 | + create-branch: true |
| 129 | + command: push |
| 130 | + commits: "${{ steps.create-commit.outputs.commit }}" |
| 131 | + |
| 132 | + - name: Create pull request |
| 133 | + if: steps.check-changes.outputs.has_changes == 'true' |
| 134 | + env: |
| 135 | + GH_TOKEN: ${{ steps.octo-sts.outputs.token }} |
| 136 | + run: | |
| 137 | + gh pr create --title "Update smoke test latest tool versions" \ |
| 138 | + --base master \ |
| 139 | + --head ${{ steps.define-branch.outputs.branch }} \ |
| 140 | + --label "tag: dependencies" \ |
| 141 | + --label "tag: no release notes" \ |
| 142 | + --body "$(cat <<'EOF' |
| 143 | + # What Does This Do |
| 144 | +
|
| 145 | + This PR updates the pinned "latest" tool versions used by CI Visibility smoke tests: |
| 146 | + - Gradle: ${{ steps.gradle.outputs.version }} |
| 147 | + - Maven: ${{ steps.maven.outputs.version }} |
| 148 | + - Maven Surefire: ${{ steps.surefire.outputs.version }} |
| 149 | +
|
| 150 | + # Motivation |
| 151 | +
|
| 152 | + Keep smoke tests running against the latest stable versions of build tools. |
| 153 | +
|
| 154 | + # Contributor Checklist |
| 155 | +
|
| 156 | + - [ ] Verify smoke tests pass with the new versions |
| 157 | + EOF |
| 158 | + )" |
0 commit comments