Skip to content

Commit deb1546

Browse files
committed
Rework git-log section in build website
Inline the separate git-log page into the main page of a build as a details section and simplify it: Instead of listing all commits per changed repository, it just provide links to the corresponding GitHub repositories, that compare the current build's tag with the baseline tag and consequently let GH render the commit list and diffs. For I/Y-builds, the baseline tag is the previous I/Y-build (as it used to be previously). When promoting an I-build to a stable- or release-build, the baseline-tag is updated to be the previous build of same kind (the list of changed repositories is updated accordingly). So an S-build (milestone or RC) is compared to the previous S-build and a release is compared to the previous release.
1 parent 553a2cd commit deb1546

File tree

9 files changed

+149
-116
lines changed

9 files changed

+149
-116
lines changed

JenkinsJobs/Builds/build.jenkinsfile

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,11 @@ pipeline {
134134
git describe --tags --match "${BUILD_TYPE}*" --abbrev=0 > "${WORKSPACE}/lastTag"
135135
'''
136136
}
137-
script { // Check for changes and abort if nothing changed since the last build
137+
script {
138+
assignEnvVariable('GIT_BASELINE_TAG', readFile("${WORKSPACE}/lastTag").trim())
139+
// Check for changes and abort if nothing changed since the last build
138140
def boolean isScheduledBuild = !currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').isEmpty()
139-
if (isScheduledBuild && sh(script: 'git diff $(cat "${WORKSPACE}/lastTag")..HEAD --name-only', returnStdout: true).trim().isEmpty()) {
141+
if (isScheduledBuild && sh(script: 'git diff ${GIT_BASELINE_TAG}..HEAD --name-only', returnStdout: true).trim().isEmpty()) {
140142
emailext subject: "${RELEASE_VER} ${BUILD_TYPE}-Build: ${BUILD_ID} - Build skipped", body: """\
141143
No changes have been made since the last successful ${BUILD_TYPE}-Build and therefore this scheduled build was skipped:
142144
${BUILD_URL}console
@@ -168,43 +170,10 @@ pipeline {
168170
'''
169171
}
170172
// Git log creation
171-
sh '''#!/bin/bash -xe
172-
reportTimestamp=$(TZ='UTC' date +%Y%m%d-%H%M)
173-
export lastTag=$(cat "${WORKSPACE}/lastTag")
174-
if [[ -n "$lastTag" ]]; then
175-
export gitLogFile="${DROP_DIR}/$BUILD_ID/gitLog.json"
176-
mkdir -p $(dirname "${gitLogFile}")
177-
178-
echo '{' > $gitLogFile
179-
echo "\\"label\\": \\"${BUILD_ID}\\"," >> $gitLogFile
180-
echo "\\"logFrom\\": \\"${lastTag}\\"," >> $gitLogFile
181-
echo "\\"logTo\\": \\"${BUILD_ID}\\"," >> $gitLogFile
182-
echo "\\"timestamp\\": \\"${reportTimestamp}\\"," >> $gitLogFile
183-
echo "\\"repositories\\": [" >> $gitLogFile >> $gitLogFile
184-
185-
function createGitLog() {
186-
gitURL=$(git config remote.origin.url | sed --expression 's,git@github.com:,https://github.com/,' | sed 's/\\.git$//')
187-
gitName="${gitURL##*/}"
188-
#TODO: handle potential double-quotes in commit message?
189-
gitLog=$(git log $lastTag..$BUILD_ID --date=short --format=format:"{ \\"date\\": \\"%cd\\", \\"message\\": \\"%s\\", \\"author\\": \\"%aN\\", \\"url\\": \\"${gitURL}/commit/%H\\"},")
190-
if [ -n "$gitLog" ]; then
191-
echo "Record changes in ${gitName}"
192-
echo "{" >> $gitLogFile
193-
echo "\\"name\\": \\"${gitName}\\"," >> $gitLogFile
194-
echo "\\"commits\\": [" >> $gitLogFile
195-
echo "${gitLog%,}" >> $gitLogFile
196-
echo "]}," >> $gitLogFile
197-
fi
198-
}
199-
export -f createGitLog
200-
createGitLog
201-
git submodule foreach 'createGitLog'
202-
203-
echo "{}]}" >> $gitLogFile # Append empty object to keep JSON valid
204-
else
205-
echo -e "\n\tGit log not generated because a reasonable previous tag could not be found." > $gitLogFile
206-
fi
207-
'''
173+
script {
174+
def gitReposChanged = utilities.listChangedGitRepositoryURLs("${GIT_BASELINE_TAG}", "${BUILD_ID}")
175+
assignEnvVariable('GIT_REPOS_CHANGED', gitReposChanged.join(','))
176+
}
208177
}
209178
}
210179
}
@@ -261,6 +230,7 @@ pipeline {
261230
source $CJE_ROOT/buildproperties.shsource
262231

263232
# Gather maven properties
233+
mkdir -p ${DROP_DIR}/$BUILD_ID
264234
cp ${AGG_DIR}/eclipse-platform-parent/target/mavenproperties.properties ${DROP_DIR}/$BUILD_ID/mavenproperties.properties
265235
comparatorRepo=$(grep '^comparator.repo=' ${DROP_DIR}/${BUILD_ID}/mavenproperties.properties | cut -d'=' -f2-)
266236

@@ -439,6 +409,8 @@ pipeline {
439409

440410
java \
441411
-DdropDirectory=${DROP_DIR}/${BUILD_ID} \
412+
-DgitBaselineTag=${GIT_BASELINE_TAG} \
413+
-DgitReposChanged=${GIT_REPOS_CHANGED} \
442414
${SCRIPTS}/releng/BuildDropDataGenerator.java mainEclipse
443415
java \
444416
-DdropDirectory=${DROP_DIR}/${BUILD_ID} \

JenkinsJobs/Releng/promoteBuild.jenkinsfile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,29 @@ pipeline {
143143

144144
echo 'Promote Eclipse'
145145
dir("${WORKSPACE}/eclipse") {
146-
renameBuildDrop('eclipse/downloads/drops4', "${DROP_ID}", "${BUILD_LABEL}", "${DL_DROP_ID}", "${DL_LABEL}")
146+
renameBuildDrop('eclipse/downloads/drops4', "${DROP_ID}", "${BUILD_LABEL}", "${DL_DROP_ID}", "${DL_LABEL}") { buildProperties ->
147+
script {
148+
def baselineBuilds = utilities.listBuildDropDirectoriesOnRemote("${EP_ROOT}/eclipse/downloads/drops4", "${DL_TYPE}*") // sorted in ascending order
149+
if (baselineBuilds.isEmpty() && "${DL_TYPE}" == 'S') { // For M1 usually no previous stable build exists
150+
baselineBuilds = utilities.listBuildDropDirectoriesOnRemote("${EP_ROOT}/eclipse/downloads/drops4", 'R*')
151+
}
152+
buildProperties.gitTag = utilities.stableBuildGitTag("${DL_DROP_ID}")
153+
buildProperties.gitBaselineTag = utilities.stableBuildGitTag("${baselineBuilds.last()}")
154+
echo "gitTag: ${buildProperties.gitTag}, gitBaselineTag: ${buildProperties.gitBaselineTag}"
155+
dir("${WORKSPACE}/repository") {
156+
def changedRepositories = utilities.listChangedGitRepositoryURLs(buildProperties.gitBaselineTag, buildProperties.gitTag)
157+
echo "Changed repositories: ${changedRepositories}"
158+
buildProperties.gitReposChanged = changedRepositories
159+
}
160+
}
161+
}
147162
}
148163
}
149164
}
150165
}
151166
stage('Tag Build') {
152167
environment {
153-
TAG = "${DL_TYPE}${BUILD_MAJOR}_${BUILD_MINOR}${(CHECKPOINT || BUILD_SERVICE != '0') ? ('_' + BUILD_SERVICE) : ''}${CHECKPOINT ? ('_' + CHECKPOINT) : ''}"
168+
TAG = "${utilities.stableBuildGitTag(DL_DROP_ID)}"
154169
}
155170
steps {
156171
dir("${WORKSPACE}/repository") {
@@ -312,7 +327,7 @@ pipeline {
312327
}
313328
}
314329

315-
def renameBuildDrop(String baseDropPath, String oldDropID, String oldBuildLabel, String newDropID, String newBuildLabel) {
330+
def renameBuildDrop(String baseDropPath, String oldDropID, String oldBuildLabel, String newDropID, String newBuildLabel, Closure extraModification = null) {
316331
def sourcePath="${EP_ROOT}/${baseDropPath}/${oldDropID}"
317332
def targetPath="${EP_ROOT}/${env.DRY_RUN_PREFIX ?: ''}${baseDropPath}/${newDropID}"
318333

@@ -353,6 +368,9 @@ EOF
353368
utilities.modifyJSON('buildproperties.json') { buildProperties ->
354369
buildProperties.identifier = newDropID
355370
buildProperties.label = newBuildLabel
371+
if (extraModification) {
372+
extraModification.call(buildProperties)
373+
}
356374
// Update filenames in lists
357375
for (value in buildProperties.values()) {
358376
if (value instanceof List) {

JenkinsJobs/shared/utilities.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ def matchBuildIdentifier(String dropID, Closure iBuildHandler, Closure sBuildHan
3131
])
3232
}
3333

34+
@NonCPS
35+
def String stableBuildGitTag(Map<String, String> id) {
36+
def service = id.service ?: '0'
37+
return "${id.type}${id.major}_${id.minor}${(id.checkpoint || service != '0') ? ('_' + service) : ''}${id.checkpoint ? ('_' + id.checkpoint) : ''}"
38+
}
39+
40+
def stableBuildGitTag(CharSequence dropID) {
41+
return stableBuildGitTag(matchBuildIdentifier(dropID, null, { }))
42+
}
43+
3444
// --- local file modifications ---
3545

3646
def replaceAllInFile(String filePath, Map<String,String> replacements) {
@@ -97,6 +107,27 @@ def forEachGitSubmodule(Closure task) {
97107
}
98108
}
99109

110+
def listChangedGitRepositoryURLs(String fromTag, String toTag) {
111+
// Diff the relative path's of each sub-module from within the aggregator (not from within each submodule)
112+
// to avoid the need to clone each submodule in full depth (just to test if something changed, not necessarily what changed)
113+
def gitReposChanged = sh(script: """
114+
echoURLOfChangedRepository() {
115+
if ! git diff ${fromTag}..${toTag} --quiet \$1; then
116+
pushd "\$1" > /dev/null
117+
git config remote.origin.url
118+
popd > /dev/null
119+
fi
120+
}
121+
echoURLOfChangedRepository
122+
for submodulePath in \$(git submodule foreach --quiet 'echo \$sm_path'); do
123+
echoURLOfChangedRepository \$submodulePath
124+
done
125+
""", returnStdout: true).split('\\s+')
126+
return gitReposChanged.collect{ url ->
127+
return url.endsWith('.git') ? url.substring(0, url.length() - 4) : url
128+
}
129+
}
130+
100131
def gitCommitAllExcludingSubmodules(String commitMessage) {
101132
withEnv(["COMMIT_MESSAGE=${commitMessage}"]) {
102133
sh '''

scripts/releng/BuildDropDataGenerator.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
* Considered JVM properties are:
2626
* <ul>
2727
* <li>{@code directory} (required) -- path to the drop directory root.</li>
28+
* <li>{@code gitBaselineTag} (required for {@code mainEclipse}) -- the Git
29+
* baseline tag.</li>
30+
* <li>{@code gitReposChanged} (required for {@code mainEclipse}) -- The comma
31+
* separated list of URLs of Git repositories that changed since the
32+
* baseline.</li>
2833
* <li>{@code filesList} (optional) -- path to a file listing all files and
2934
* their size in the directory.<br>
3035
* Can be generated using the UNIX command
@@ -54,6 +59,9 @@ void main(String[] args) throws IOException {
5459
final Pattern COMMA = Pattern.compile(",");
5560

5661
void mainEclipsePageData() throws IOException {
62+
String gitBaselineTag = OS.readProperty("gitBaselineTag").trim();
63+
List<String> gitReposChanged = List.of(OS.readProperty("gitReposChanged").trim().split(","));
64+
5765
Map<Path, Long> files = OS.listFileTree(DIRECTORY, FILES_LIST_FILE, null, 1);
5866
Map<String, String> properties = OS.loadProperties(DIRECTORY.resolve("buildproperties.properties"));
5967
String buildId = properties.get("BUILD_ID");
@@ -69,6 +77,16 @@ void mainEclipsePageData() throws IOException {
6977
buildProperties.add("previousReleaseAPILabel", JSON.String.create(previousReleaseAPILabel(properties)));
7078
buildProperties.add("timestamp", JSON.String.create(buildDate.toString()));
7179

80+
// git log
81+
buildProperties.add("gitTag", JSON.String.create(buildId));
82+
buildProperties.add("gitBaselineTag", JSON.String.create(gitBaselineTag));
83+
if (!gitBaselineTag.isEmpty()) {
84+
buildProperties.add("gitReposChanged",
85+
gitReposChanged.stream().map(JSON.String::create).collect(JSON.Array.toJSONArray()));
86+
} else {
87+
IO.println("Git log not generated because a reasonable previous tag could not be found.");
88+
}
89+
7290
// tests
7391
JSON.Array testConfigurations = COMMA.splitAsStream(properties.get("TEST_CONFIGURATIONS_EXPECTED")).map(c -> {
7492
var config = c.split("-");

sites/eclipse/build/gitLog.html

Lines changed: 0 additions & 67 deletions
This file was deleted.

sites/eclipse/build/index.html

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ <h4 id="tests">Test Results Summary</h4>
5151
</thead>
5252
</table>
5353

54-
<h4 id="git-log">Git Log</h4>
55-
<ul>
56-
<li><a href="gitLog.html">Git log</a></li>
57-
</ul>
54+
<details>
55+
<summary id="git-log" class="toc-level-4">Git Log</summary>
56+
<div style="padding: 5px;">
57+
<p>
58+
The following Git repositories changed since <b class="data-ref">${gitBaselineTag}</b> until this build (<b class="data-ref">${gitTag}</b>):
59+
<ul id="git-log-repo-list">
60+
</ul>
61+
</p>
62+
</div>
63+
</details>
5864

5965
<h4 id="signatures">Checksums&nbsp;(SHA 512) and GPG&nbsp;Signatures</h4>
6066
<ul>
@@ -170,6 +176,19 @@ <h3 id="swt">SWT Binary and Source
170176
For details, see <a href="${build.signOffIssue}">${signOffLabel}</a>.`
171177
}
172178

179+
// Inject git log
180+
const gitLogRepoList = document.getElementById('git-log-repo-list')
181+
for (let repoURL of build.gitReposChanged) {
182+
if (repoURL.endsWith('.git')) {
183+
repoURL = repoURL.substring(0, repoURL.length - 4)
184+
}
185+
186+
const repoName = repoURL.substring(repoURL.indexOf('github.com') + 10 + 1, repoURL.length)
187+
const repoItem = document.createElement('li')
188+
repoItem.innerHTML = `<b><a href="${repoURL}/compare/${build.gitBaselineTag}...${build.gitTag}">${repoName}</a></b>`
189+
gitLogRepoList.appendChild(repoItem)
190+
}
191+
173192
// Inject resource files
174193
const dataTables = Array.from(mainElement.getElementsByClassName('files-table'))
175194
for (const table of dataTables) {

sites/eclipse/page.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@import "https://fonts.googleapis.com/css2?family=Libre+Franklin:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap";
33

44
:root {
5+
interpolate-size: allow-keywords;
56
--marker-error: red;
67
--marker-warning: orange;
78
--marker-info: dodgerblue;
@@ -78,6 +79,45 @@ li.toc-item a {
7879
text-decoration: none;
7980
}
8081

82+
/* Details sections */
83+
84+
details {
85+
background-color: whitesmoke;
86+
}
87+
88+
details summary {
89+
font-weight: bold;
90+
background-color: lightsteelblue;
91+
padding: 5px;
92+
cursor: pointer;
93+
/* Ensure state triangle in closed state */
94+
display: list-item;
95+
list-style-type: disclosure-closed;
96+
}
97+
98+
details[open] summary {
99+
/* Ensure state triangle in open state */
100+
list-style-type: disclosure-open;
101+
}
102+
103+
details summary:hover {
104+
color: white;
105+
background-color: #4B78B4;
106+
}
107+
108+
/* Slide down/up animation when opening/closing details */
109+
details::details-content {
110+
transition: height 0.5s ease, opacity 0.5s ease;
111+
height: 0;
112+
opacity: 0;
113+
overflow: hidden;
114+
}
115+
116+
details[open]::details-content {
117+
height: auto;
118+
opacity: 1;
119+
}
120+
81121
.error-message-box {
82122
background-color: #ffdddd;
83123
border-left: 6px solid crimson;

0 commit comments

Comments
 (0)