Skip to content

Commit

Permalink
feat: add external-mocks-application with skilllab mock
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter committed Nov 8, 2024
1 parent de169dc commit 25a1835
Show file tree
Hide file tree
Showing 28 changed files with 1,424 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/aam-backend-service-analyse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- 'application/aam-backend-service/**'
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
paths:
- '.github/workflows/aam-backend-service-analyse.yml'
- 'application/aam-backend-service/**'

jobs:
test_coverage:
Expand Down
142 changes: 142 additions & 0 deletions .github/workflows/aam-external-mock-service-build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: aam-external-mock-service-build-and-publish

on:
pull_request:
paths:
- '.github/workflows/aam-external-mock-service-build-and-publish.yml'
- 'application/aam-external-mock-service/**'
push:
tags:
- "*"
paths:
- '.github/workflows/aam-external-mock-service-build-and-publish.yml'
- 'application/aam-external-mock-service/**'

env:
REGISTRY_IMAGE: ghcr.io/aam-digital/aam-external-mock-service

jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
os:
- ubuntu-latest
- [ self-hosted, Linux, ARM64 ]
exclude:
- platform: linux/arm64
os: ubuntu-latest
- platform: linux/amd64
os: [ self-hosted, Linux, ARM64 ]
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository files
uses: actions/checkout@v4

- name: Extract tag (release)
if: ${{ github.event.ref != '' }}
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Extract tag (pull request)
if: ${{ github.event.ref == '' }}
run: echo "TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV

- name: Prepare Platform
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create export directories
run: |
mkdir -p ./tmp/build
mkdir -p ./tmp/build/${{ env.PLATFORM_PAIR }}
mkdir -p ./tmp/digests
- name: Build Image and push by digest
id: build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
context: ./application/aam-external-mock-service
target: build
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=min
env:
SOURCE_DATE_EPOCH: 0

- name: Export digest
run: |
digest="${{ steps.build.outputs.digest }}"
touch "./tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ./tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ./tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: ./tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
3 changes: 3 additions & 0 deletions application/aam-external-mock-service/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
40 changes: 40 additions & 0 deletions application/aam-external-mock-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Kotlin ###
.kotlin
10 changes: 10 additions & 0 deletions application/aam-external-mock-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM gradle:8.10.2-jdk21-alpine AS build
WORKDIR /opt/app
COPY . .
RUN gradle installDist

FROM amazoncorretto:21-alpine
WORKDIR /opt/app
COPY --from=build /opt/app/build/install/aam-external-mock-service /opt/app
EXPOSE 8080
CMD ./bin/aam-external-mock-service
85 changes: 85 additions & 0 deletions application/aam-external-mock-service/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
plugins {
application
distribution
jacoco
kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.25"
kotlin("plugin.jpa") version "1.9.25"
id("org.springframework.boot") version "3.3.5"
id("io.spring.dependency-management") version "1.1.6"
id("org.jetbrains.kotlin.kapt") version "1.9.25"
id("io.sentry.jvm.gradle") version "4.11.0"
}

group = "com.aam-digital"
version = "0.0.1-SNAPSHOT"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}

application {
mainClass.set("com.aamdigital.aamexternalmockservice.ApplicationKt")
}

repositories {
mavenCentral()
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
implementation("org.apache.commons:commons-lang3")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("io.micrometer:micrometer-tracing-bridge-otel")
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("io.github.serpro69:kotlin-faker:1.16.0")


runtimeOnly("org.postgresql:postgresql")

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")

testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testImplementation("org.springframework.security:spring-security-test")

testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

jacoco {
toolVersion = "0.8.12"
}

tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
html.required.set(false)
csv.required.set(true)
xml.required.set(true)
}
}

kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
}
}

tasks.withType<Test> {
useJUnitPlatform()
}
9 changes: 9 additions & 0 deletions application/aam-external-mock-service/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
postgres:
image: postgres:16
environment:
- POSTGRES_USER=docker
- POSTGRES_PASSWORD=docker
- POSTGRES_DB=postgres
ports:
- "5666:5432"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 25a1835

Please sign in to comment.