Skip to content

Commit

Permalink
Merge pull request #7 from maeworkshop/dev
Browse files Browse the repository at this point in the history
PR
  • Loading branch information
maemresen committed May 8, 2024
2 parents e5b80fa + 475797b commit b06b623
Show file tree
Hide file tree
Showing 38 changed files with 870 additions and 1,464 deletions.
1,340 changes: 0 additions & 1,340 deletions .editorconfig

This file was deleted.

70 changes: 52 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
name: Java CI with Gradle
name: Build Branch

on:
push:
branches:
- feature/**
- bugfix/**

- dev
workflow_dispatch:
jobs:
build:
build-jar:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
BUILD_NUMBER: ${{ steps.build-number.outputs.BUILD_NUMBER }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: build-number
name: Configuring Build Number
run: |
echo "BUILD_NUMBER=$(git rev-parse --abbrev-ref HEAD | tr '/' '-')-$(git rev-parse --short=8 HEAD)" >> $GITHUB_OUTPUT
- name: Get current branch name
id: get_branch
run: echo "CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
- name: Test Build Number
run: echo "${{ steps.build-number.outputs.BUILD_NUMBER }}"
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
Expand All @@ -21,22 +33,44 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3.1.0
- name: Build
run: ./gradlew build
run: CI=true ./gradlew clean assemble -Pversion=${{ steps.build-number.outputs.BUILD_NUMBER }}
- name: Test
run: ./gradlew test
run: CI=true ./gradlew test
- name: Integration Test
run: ./gradlew integrationTest

dependency-submission:
run: CI=true ./gradlew integrationTest
- name: Sonar Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
BRANCH_NAME: ${{ env.CURRENT_BRANCH_NAME }}
run: |
echo "Branch name $BRANCH_NAME"
CI=true ./gradlew sonar --info -Dsonar.branch.name=$BRANCH_NAME
- name: Uploading DataGenerator Jars
uses: actions/upload-artifact@master
with:
name: k8s-workshop-data-generator-jar
path: module/app/k8s-workshop-data-generator/build/libs
build-k8s-workshop-data-generator-image:
needs:
- build-jar
name: Data Generator - Build & Push Docker Image
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
java-version: '21'
distribution: 'temurin'
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3.1.0
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: module/app/k8s-workshop-data-generator
push: true
tags: ghcr.io/maeworkshop/k8s-workshop-data-generator:${{ needs.build-jar.outputs.BUILD_NUMBER }}
40 changes: 40 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check Branch
on:
push:
branches:
- feature/**
- bugfix/**
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Get current branch name
id: get_branch
run: echo "CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3.1.0
- name: Build
run: CI=true ./gradlew clean assemble
- name: Test
run: CI=true ./gradlew test
- name: Integration Test
run: CI=true ./gradlew integrationTest
- name: Sonar Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
BRANCH_NAME: ${{ env.CURRENT_BRANCH_NAME }}
run: |
echo "Branch name $BRANCH_NAME"
CI=true ./gradlew sonar --info -Dsonar.branch.name=$BRANCH_NAME
2 changes: 1 addition & 1 deletion .run/Data Generator.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</option>
<option name="taskNames">
<list>
<option value=":module:app:data-generator:bootRun" />
<option value=":module:app:k8s-workshop-data-generator:bootRun" />
</list>
</option>
<option name="vmOptions" />
Expand Down
2 changes: 1 addition & 1 deletion .run/Listener.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</option>
<option name="taskNames">
<list>
<option value=":module:app:listener:bootRun" />
<option value=":module:app:k8s-workshop-listener:bootRun" />
</list>
</option>
<option name="vmOptions" />
Expand Down
24 changes: 24 additions & 0 deletions .run/Sonar Scan.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Sonar Scan" type="GradleRunConfiguration" factoryName="Gradle" folderName="00-build">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-Dsonar.branch.name=local" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="sonar" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
49 changes: 48 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import org.gradle.plugins.ide.idea.model.IdeaModel

plugins {
id("org.sonarqube") version "4.4.1.3373"
}

sonar {
properties {
property("sonar.projectKey", "maeworkshop_k8s-workshop")
property("sonar.organization", "maeworkshop")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.verbose", "true")
property("sonar.coverage.jacoco.xmlReportPaths", "**/build/reports/jacoco/test/jacocoTestReport.xml")
}
}

subprojects {
pluginManager.withPlugin("java") {
val integrationTestSrcPath = "src/integrationTest"
val integrationTestTaskName = "integrationTest"

group = "com.maemresen.ecommerce"
version = "0.01-SNAPSHOT"

repositories {
mavenCentral()
Expand Down Expand Up @@ -47,13 +60,47 @@ subprojects {

withType<Test> {
useJUnitPlatform()
jvmArgs("-XX:+EnableDynamicAgentLoading")
}

named("check") {
dependsOn(integrationTestTaskName)
}
}

pluginManager.withPlugin("jacoco") {
tasks {
named("test") {
finalizedBy(named("jacocoTestReport"))
}

named("jacocoTestReport") {
dependsOn("test")
}
}


}

pluginManager.withPlugin("jacoco") {
tasks {
named("test") {
finalizedBy(named("jacocoTestReport"))
}


named("jacocoTestReport") {
dependsOn("test")
}

withType<JacocoReport> {
reports {
xml.required = true
}
}
}
}

pluginManager.withPlugin("idea") {
extensions.configure<IdeaModel> {
module {
Expand Down
Loading

0 comments on commit b06b623

Please sign in to comment.