From 9dcfd29b18858c4551ce16d4539e753cdacc186e Mon Sep 17 00:00:00 2001 From: Michel Hartmann Date: Thu, 5 Oct 2023 21:20:40 +0200 Subject: [PATCH] Standardize builds (#69) * Standardize builds Issues: IN-440 * Align Gradle version Issues: IN-440 * Align Gradle build with standard Issues: IN-440 * Update to JDK 17 (LTS) Issues: IN-440 * Setting executable for tests dos not work with gradle 7.6 Issues: IN-440 --------- Co-authored-by: Michel Hartmann --- .github/dependabot.yml | 13 ++++- .github/workflows/build.yml | 31 ----------- .github/workflows/codeql-analysis.yml | 14 ++--- .github/workflows/pull-request.yml | 17 ++++++ .github/workflows/release.yml | 2 +- .github/workflows/snapshot.yml | 3 +- build.gradle | 70 +++++++++++++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- 8 files changed, 84 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 12320b7..46c2e3d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,8 +1,15 @@ version: 2 updates: - directory: / - schedule: - interval: daily package-ecosystem: gradle + schedule: + interval: weekly + assignees: + - MichelHartmann + - meiXXI + - directory: / + package-ecosystem: github-actions + schedule: + interval: weekly assignees: - - MichelHartmann \ No newline at end of file + - MichelHartmann diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 09235cf..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Build - -on: - pull_request: - -jobs: - build: - strategy: - matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] - java: [ 16 ] - runs-on: ${{ matrix.os }} - name: Java build on ${{ matrix.os }} with JDK ${{ matrix.java }} - steps: - - name: Setup JDK ${{ matrix.java }} - uses: actions/setup-java@v2 - with: - distribution: 'adopt' - java-version: ${{ matrix.java }} - - - name: Check out sources... - uses: actions/checkout@v2 - - - name: Build with Gradle - run: ./gradlew test jacocoTestReport - - - name: Submit Code coverage - uses: codecov/codecov-action@v2 - with: - flags: ${{ matrix.os }}, JDK ${{ matrix.java }} - file: build/reports/jacoco/test/jacocoTestReport.xml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 56e751d..ec9dcad 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -37,18 +37,12 @@ jobs: # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: - - name: Setup JDK 16 - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - java-version: 16 - - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -59,7 +53,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -73,4 +67,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..4d946b2 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,17 @@ +name: Pull-Request + +# This build process is triggered in case a new pull request on master has been created. +# This process takes the latest changes of the branch, and build and test the new version. The process's aim is to +# check validity of changes prior to merging to master. + +on: + pull_request: + branches: [ main ] + +jobs: + call-workflow: + name: 🏭 + uses: cip4/.github/.github/workflows/pull-request.yml@master + with: + java-version: 17 + codecov-enabled: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9bc3645..18c7555 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: name: 🏭 uses: cip4/.github/.github/workflows/tool-release.yml@master with: - java-version: 16 + java-version: 17 confluence-label: alces confluence-content-id: 1181122563 apple-bundle-id: org.cip4.alces diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 0eb59a6..19d9196 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -9,7 +9,8 @@ jobs: name: 🏭 uses: cip4/.github/.github/workflows/tool-snapshot.yml@master with: - java-version: 16 + java-version: 17 + codecov-enabled: true confluence-label: alces confluence-content-id: 1457554021 apple-bundle-id: org.cip4.alces diff --git a/build.gradle b/build.gradle index 3796a4c..f6e0df6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,6 @@ import org.apache.tools.ant.filters.ReplaceTokens +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { id 'org.springframework.boot' version '2.7.0' @@ -9,18 +11,24 @@ plugins { id 'jacoco' } -mainClassName = 'org.cip4.tools.alces.Application' def simpleProjectName = "Alces" +mainClassName = 'org.cip4.tools.alces.Application' +group = 'org.cip4.tools.alces' +description = 'CIP4 ' + simpleProjectName +version = project.hasProperty('projectVersion') ? project.projectVersion : 'development' -sourceCompatibility = 16 -targetCompatibility = 16 - -if (project.hasProperty('projectVersion')) { - version = project.projectVersion -} else { - version = 'development' +java { + archivesBaseName = simpleProjectName + withJavadocJar() + withSourcesJar() + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } } +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + repositories { mavenCentral() maven { @@ -30,9 +38,10 @@ repositories { processResources { filesMatching(['**/*.properties', '**/*.yml']) { - filter(ReplaceTokens, tokens: [ + filter(ReplaceTokens, tokens: [ 'name': project.properties['name'], 'version': project.properties['version'], + 'artifactId': project.properties['name'], 'timestamp': new Date().format('yyyy-MM-dd HH:mm:ss') ]) } @@ -42,10 +51,6 @@ application { mainClass = 'org.cip4.tools.alces.Application' } -test { - useJUnitPlatform() -} - dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.codehaus.groovy:groovy:+' @@ -105,12 +110,6 @@ runtime { } } -test { - dependsOn(jre) - useJUnitPlatform() - executable = jre.getJreDir().dir("bin").file("java").getAsFile().getAbsolutePath() -} - jacocoTestReport { dependsOn test reports { @@ -118,10 +117,39 @@ jacocoTestReport { html.required = false } } +test { + useJUnitPlatform() + dependsOn(jre) + if (GradleVersion.current() >= GradleVersion.version("8.0")) { + executable = jre.getJreDir().dir("bin").file("java").getAsFile().getAbsolutePath() + } +} -java { - archivesBaseName = simpleProjectName + +jar { + manifest { + attributes( + "Implementation-Title": project.description, + "Implementation-Version": project.version, + "Implementation-Vendor-Id": project.group, + "Specification-Title": project.description, + "Specification-Version": project.version, + "Build-Jdk": JavaVersion.current(), + ) + } } + startScripts { applicationName = simpleProjectName +} + +tasks.withType(Test) { + testLogging { + events TestLogEvent.FAILED, + TestLogEvent.SKIPPED + exceptionFormat TestExceptionFormat.FULL + showExceptions true + showCauses true + showStackTraces true + } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fbce071..f42e62f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists