Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions buildenv/jenkins/clang_format/clangFormatCheck.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright IBM Corp. and others 2025
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/

timestamps {
timeout(time: 8, unit: 'HOURS') {
stage('Queue') {
node('Linux && x86') {
def tmpDesc = currentBuild.description ? currentBuild.description + "<br>" : ""
currentBuild.description = tmpDesc + "<a href=${JENKINS_URL}computer/${NODE_NAME}>${NODE_NAME}</a>"
try {
def gitConfig = scm.getUserRemoteConfigs().get(0)
def refspec = gitConfig.getRefspec() ? gitConfig.getRefspec() : ""
checkout changelog: false, poll: false,
scm: [$class: 'GitSCM',
branches: [[name: scm.branches[0].name]],
userRemoteConfigs: [[
refspec: "${refspec}",
url: "${gitConfig.getUrl()}"]]
]
stage('Pull Infra') {
sh "buildenv/jenkins/clang_format/pullInfra.sh"
}
stage('Docker Build') {
dir('buildenv/jenkins/clang_format') {
sh "docker build -t clang-format -f Dockerfile ."
}
}
stage('Format Check') {
sh "buildenv/jenkins/clang_format/clangFormatCheck.sh"
}
stage('Cleanup Infra') {
sh "buildenv/jenkins/clang_format/cleanupInfra.sh"
}
} finally {
cleanWs()
}
}
}
}
}
65 changes: 65 additions & 0 deletions buildenv/jenkins/clang_format/clangFormatCheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash -f
###############################################################################
# Copyright IBM Corp. and others 2025
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
# or the Apache License, Version 2.0 which accompanies this distribution and
# is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following
# Secondary Licenses when the conditions for such availability set
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
# General Public License, version 2 with the GNU Classpath
# Exception [1] and GNU General Public License, version 2 with the
# OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] https://openjdk.org/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
###############################################################################

allFiles=$(git diff -C --diff-filter=ACM --name-only origin/master HEAD --)
if [ x"$allFiles" = x ] ; then
echo "There are no files to check for code formatting."
else
lines='-----------------------------------'
badFiles=
for file in $allFiles ; do
case "$file" in
runtime/compiler/*.c | \
runtime/compiler/*.cpp | \
runtime/compiler/*.h | \
runtime/compiler/*.hpp)
echo "file:$file"
good="$file.good"
docker run --rm -v "$WORKSPACE:/src" clang-format:latest clang-format -style=file:runtime/compiler/.clang-format "/src/$file" > "$good"
diffOutput=$(diff -u "$file" "$good")
if [ "$diffOutput" != "" ] ; then
echo "ERROR - not formatted as expected: '$file'"
echo "$diffOutput"
echo "$lines"
badFiles="$badFiles $file"
rm -f "$good"
fi
;;
*)
;;
esac
done

if [ x"$badFiles" = x ] ; then
echo "All modified files appear to have correct code formatting."
else
hashes='###################################'
echo "$hashes"
echo "The following files were modified and have incorrect code formatting:"
for file in $badFiles ; do
echo "$file"
done
echo "$hashes"
exit 1
fi
fi
26 changes: 26 additions & 0 deletions buildenv/jenkins/clang_format/cleanupInfra.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -f
###############################################################################
# Copyright IBM Corp. and others 2025
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
# or the Apache License, Version 2.0 which accompanies this distribution and
# is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following
# Secondary Licenses when the conditions for such availability set
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
# General Public License, version 2 with the GNU Classpath
# Exception [1] and GNU General Public License, version 2 with the
# OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] https://openjdk.org/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
###############################################################################

rm -f runtime/compiler/.clang-format
rm -f buildenv/jenkins/clang_format/Dockerfile
rm -f buildenv/jenkins/clang_format/clang-format-wrapper.sh
26 changes: 26 additions & 0 deletions buildenv/jenkins/clang_format/pullInfra.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -f
###############################################################################
# Copyright IBM Corp. and others 2025
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
# or the Apache License, Version 2.0 which accompanies this distribution and
# is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following
# Secondary Licenses when the conditions for such availability set
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
# General Public License, version 2 with the GNU Classpath
# Exception [1] and GNU General Public License, version 2 with the
# OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] https://openjdk.org/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
###############################################################################

wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/compiler/.clang-format runtime/compiler/
wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/buildenv/jenkins/clang_format/Dockerfile buildenv/jenkins/clang_format/
wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/buildenv/jenkins/clang_format/clang-format-wrapper.sh buildenv/jenkins/clang_format/
Comment on lines +24 to +26
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/compiler/.clang-format runtime/compiler/
wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/buildenv/jenkins/clang_format/Dockerfile buildenv/jenkins/clang_format/
wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/buildenv/jenkins/clang_format/clang-format-wrapper.sh buildenv/jenkins/clang_format/
wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/compiler/.clang-format -P runtime/compiler/
wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/buildenv/jenkins/clang_format/Dockerfile -P buildenv/jenkins/clang_format/
wget https://raw.githubusercontent.com/eclipse-omr/omr/refs/heads/master/buildenv/jenkins/clang_format/clang-format-wrapper.sh -P buildenv/jenkins/clang_format/

Missed the -P flag.