Skip to content

Commit

Permalink
Update to latest conventions (#272)
Browse files Browse the repository at this point in the history
* Update to latest conventions

* Fix build
  • Loading branch information
big-andy-coates authored Jan 16, 2024
1 parent ab09878 commit 1acac84
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 27 deletions.
5 changes: 1 addition & 4 deletions .creek/service_template/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/basic-kafka-streams-demo/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"]
2 changes: 1 addition & 1 deletion .creek/service_template/example-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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 Down
15 changes: 11 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
contents: read

jobs:
build:
build_linux:
if: ${{ github.run_number != 1 }}
runs-on: ubuntu-latest
steps:
Expand All @@ -24,7 +24,10 @@ 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
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
Expand All @@ -35,7 +38,7 @@ jobs:
permissions:
contents: write
packages: write
needs: build
needs: build_linux
runs-on: ubuntu-latest
concurrency:
group: "${{ github.repository }}-release"
Expand All @@ -51,7 +54,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: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
Expand Down
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
5 changes: 4 additions & 1 deletion .github/workflows/test-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ 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
5 changes: 4 additions & 1 deletion .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ 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
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"
}
25 changes: 18 additions & 7 deletions buildSrc/src/main/kotlin/common-convention.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
*
* <p>Apply to all java modules, usually excluding the root project in multi-module sets.
*
* <p>Version: 1.7
* <p>Versions:
* - 1.10: Add ability to exclude containerised tests
* - 1.9: Add `allDeps` task.
* - 1.8: Tweak test config to reduce build speed.
* - 1.7: Switch to setting Java version via toolchain
* - 1.6: Remove GitHub packages for snapshots
* - 1.5: Add filters to exclude generated sources
* - 1.4: Add findsecbugs-plugin
* - 1.3: Fail on warnings for test code too.
*/

plugins {
Expand Down Expand Up @@ -62,8 +64,8 @@ tasks.withType<JavaCompile> {

tasks.test {
useJUnitPlatform()
setForkEvery(1)
maxParallelForks = 4
setForkEvery(5)
maxParallelForks = Runtime.getRuntime().availableProcessors()
testLogging {
showStandardStreams = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
Expand All @@ -75,7 +77,7 @@ tasks.test {

spotless {
java {
googleJavaFormat("1.15.0").aosp()
googleJavaFormat("1.15.0").aosp().reflowLongStrings()
indentWithSpaces()
importOrder()
removeUnusedImports()
Expand Down Expand Up @@ -109,17 +111,26 @@ if (rootProject.name != project.name) {
}
}

tasks.register("format") {
val format = tasks.register("format") {
group = "creek"
description = "Format the code"

dependsOn("spotlessCheck", "spotlessApply")
}

tasks.register("static") {
val static = tasks.register("static") {
group = "creek"
description = "Run static code analysis"

dependsOn("checkstyleMain", "checkstyleTest", "spotbugsMain", "spotbugsTest")

shouldRunAfter(format)
}

tasks.test {
shouldRunAfter(static)
}

// See: https://solidsoft.wordpress.com/2014/11/13/gradle-tricks-display-dependencies-for-all-subprojects-in-multi-project-build/
tasks.register<DependencyReportTask>("allDeps") {}

6 changes: 1 addition & 5 deletions handle-occurrence-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ ENV VERSION=$APP_VERSION

LABEL org.opencontainers.image.source=https://github.com/creek-service/basic-kafka-streams-demo/tree/main/handle-occurrence-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"]
2 changes: 1 addition & 1 deletion handle-occurrence-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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 Down

0 comments on commit 1acac84

Please sign in to comment.