Skip to content

Commit

Permalink
Latest build conventions (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
big-andy-coates authored Jun 23, 2024
1 parent ad7ed2b commit 5b1a04c
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 19 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ jobs:
with:
java-version: '17'
distribution: 'adopt'
cache: gradle

- name: Setup Gradle
uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c # v2.7.0
with:
gradle-home-cache-cleanup: true

- name: Build
run: ./gradlew test
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
name: Dependabot
on:
pull_request:
branches:
- main
branches: [ main ]

permissions:
contents: read
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ jobs:
with:
java-version: '17'
distribution: 'adopt'
cache: gradle

- name: Setup Gradle
uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c # v2.7.0
with:
gradle-home-cache-cleanup: true
- name: Run boostrap script
shell: zsh {0}
run: ./.creek/bootstrap.sh "some-User-name/a_Nother-REpo_name" "some-User-name"
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ jobs:
with:
java-version: '17'
distribution: 'adopt'
cache: gradle

- name: Setup Gradle
uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c # v2.7.0
with:
gradle-home-cache-cleanup: true
- name: Increment version
if: contains(fromJson('["Major", "Minor", "Patch"]'), github.event.inputs.part)
run: |
Expand Down
6 changes: 1 addition & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ subprojects {
set("junitVersion", "5.10.2") // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
set("junitPioneerVersion", "2.2.0") // https://mvnrepository.com/artifact/org.junit-pioneer/junit-pioneer
set("mockitoVersion", "5.12.0") // https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter
set("hamcrestVersion", "2.2") // https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core
}

val creekVersion : String by extra
Expand All @@ -68,7 +67,6 @@ subprojects {
val junitVersion: String by extra
val junitPioneerVersion: String by extra
val mockitoVersion: String by extra
val hamcrestVersion : String by extra

dependencies {
testImplementation("org.creekservice:creek-test-hamcrest:$creekVersion")
Expand All @@ -77,10 +75,8 @@ subprojects {
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testImplementation("org.junit-pioneer:junit-pioneer:$junitPioneerVersion")
testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion")
testImplementation("org.hamcrest:hamcrest-core:$hamcrestVersion")
testImplementation("com.google.guava:guava-testlib:$guavaVersion")
testImplementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
testImplementation("org.apache.logging.log4j:log4j-slf4j2-impl:$log4jVersion")
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j2-impl:$log4jVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
}

Expand Down
3 changes: 3 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
* limitations under the License.
*/

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0"
}
11 changes: 8 additions & 3 deletions buildSrc/src/main/kotlin/common-convention.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ repositories {

dependencies {
spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0")
checkstyle("com.puppycrawl.tools:checkstyle:10.17.0")
}

configurations.all {
Expand All @@ -61,9 +62,13 @@ tasks.withType<JavaCompile> {
}

tasks.test {
useJUnitPlatform()
setForkEvery(1)
maxParallelForks = 4
useJUnitPlatform() {
if (project.hasProperty("excludeContainerised")) {
excludeTags("ContainerisedTest")
}
}
setForkEvery(5)
maxParallelForks = Runtime.getRuntime().availableProcessors()
testLogging {
showStandardStreams = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/coverage-convention.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ val coverage = tasks.register<JacocoReport>("coverage") {

coveralls {
sourceDirs = allprojects.flatMap{it.sourceSets.main.get().allSource.srcDirs}.map{it.toString()}
jacocoReportPath = "$buildDir/reports/jacoco/coverage/coverage.xml"
jacocoReportPath = layout.buildDirectory.file("reports/jacoco/coverage/coverage.xml")
}

tasks.coveralls {
Expand Down
5 changes: 1 addition & 4 deletions example-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ ENV VERSION=$APP_VERSION

LABEL org.opencontainers.image.source=https://github.com/creek-service/aggregate-template/tree/main/example-service

RUN yum update -y
RUN yum install -y tar lsof

RUN mkdir -p /opt/creek

COPY bin /bin
COPY log4j /log

COPY ${APP_NAME}-${APP_VERSION}.tar /opt/creek
COPY ${APP_NAME}-${APP_VERSION} /opt/creek/${APP_NAME}-${APP_VERSION}
WORKDIR /opt/creek
RUN tar xf ${APP_NAME}-${APP_VERSION}.tar
RUN ln -s ${APP_NAME}-${APP_VERSION} service

ENTRYPOINT ["/bin/run.sh"]
12 changes: 11 additions & 1 deletion example-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ val buildAppImage = tasks.register<DockerBuildImage>("buildAppImage") {
buildArgs.put("APP_NAME", project.name)
buildArgs.put("APP_VERSION", "${project.version}")
images.add("ghcr.io/creek-service/${rootProject.name}-${project.name}:latest")

onlyIf {
// Exclude the task if running on Windows (as images don't build on Windows)
!System.getProperty("os.name").lowercase().contains("win")
}
images.add("ghcr.io/creek-service/${rootProject.name}-${project.name}:${project.version}")
}

Expand All @@ -57,7 +62,7 @@ tasks.register<Copy>("prepareDocker") {

from(
layout.projectDirectory.file("Dockerfile"),
layout.buildDirectory.file("distributions/${project.name}-${project.version}.tar"),
tarTree(layout.buildDirectory.file("distributions/${project.name}-${project.version}.tar")),
layout.projectDirectory.dir("include"),
)

Expand All @@ -67,6 +72,11 @@ tasks.register<Copy>("prepareDocker") {
tasks.register<DockerPushImage>("pushAppImage") {
dependsOn("buildAppImage")
images.add("ghcr.io/creek-service/${rootProject.name}-${project.name}:latest")

onlyIf {
// Exclude the task if running on Windows (as images don't build on Windows)
!System.getProperty("os.name").lowercase().contains("win")
}
images.add("ghcr.io/creek-service/${rootProject.name}-${project.name}:${project.version}")
}

0 comments on commit 5b1a04c

Please sign in to comment.