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