Skip to content

Commit

Permalink
Consistency in simulation invocation service naming
Browse files Browse the repository at this point in the history
  • Loading branch information
flawmop committed Feb 9, 2024
1 parent d27b86a commit 00d15f1
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 5 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/acceptance-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Acceptance Stage
on:
workflow_run:
workflows: ['Commit Stage']
types: [completed]
branches: main
concurrency: acceptance

env:
OWNER: flawmop
REGISTRY: ghcr.io
APP_REPO: simulation-invoke-svc
DEPLOY_REPO: portal-deploy
VERSION: ${{ github.sha }}

jobs:
functional:
name: Functional Acceptance Tests
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
steps:
- run: echo "Running functional acceptance tests"
performance:
name: Performance Tests
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
steps:
- run: echo "Running performance tests"
security:
name: Security Tests
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
steps:
- run: echo "Running security tests"
deliver:
name: Deliver release candidate to production
needs: [ functional, performance, security ]
runs-on: ubuntu-22.04
steps:
- name: Deliver application to production
uses: peter-evans/[email protected]
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: ${{ env.OWNER }}/${{ env.DEPLOY_REPO }}
event-type: app_acceptance_delivery
client-payload: '{
"app_image": "${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.APP_REPO }}",
"app_name": "${{ env.APP_REPO }}",
"app_version": "${{ env.VERSION }}"
}'
105 changes: 105 additions & 0 deletions .github/workflows/commit-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Commit Stage
on: push

env:
OWNER: flawmop
REGISTRY: ghcr.io
IMAGE_NAME: flawmop/simulation-invoke-svc
APP_REPO: simulation-invoke-svc
DEPLOY_REPO: portal-deploy
VERSION: ${{ github.sha }}

jobs:
build:
name: Build and Test
runs-on: ubuntu-22.04
permissions:
contents: read
security-events: write
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 21
cache: gradle
- name: Build, unit tests and integration tests
run: |
chmod +x gradlew
./gradlew build
- name: Code vulnerability scanning
uses: anchore/scan-action@v3
id: scan
with:
path: "${{ github.workspace }}"
fail-build: false
severity-cutoff: high
- name: Prepare Validate Kubernetes manifests
uses: alexellis/arkade-get@master
with:
kubectl: v1.28.2
kubeval: v0.16.1
- name: Validate Kubernetes manifests
# Different schema required because of https://github.com/instrumenta/kubeval/issues/301
run: |
kustomize build k8s | kubeval --strict --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master -
package:
name: Package and Publish
if: ${{ github.ref == 'refs/heads/main' }}
needs: [ build ]
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
security-events: write
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 21
cache: gradle
- name: Build container image
run: |
chmod +x gradlew
./gradlew bootBuildImage \
--imageName ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- name: OCI image vulnerability scanning
uses: anchore/scan-action@v3
id: scan
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
fail-build: false
severity-cutoff: high
- name: Log into container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish container image
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- name: Publish container image (latest)
run: |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
deliver:
name: Deliver dev candidate
needs: [ build, package ]
runs-on: ubuntu-22.04
steps:
- name: Deliver dev candidate
uses: peter-evans/[email protected]
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: ${{ env.OWNER }}/${{ env.DEPLOY_REPO }}
event-type: app_commit_delivery
client-payload: '{
"app_image": "${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.APP_REPO }}",
"app_name": "${{ env.APP_REPO }}",
"app_version": "${{ env.VERSION }}"
}'
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import reactor.core.publisher.Flux;

@Configuration
public class InvokeSimulationConfig {
public class SimulationInvokeConfig {

private static final Logger log = LoggerFactory.getLogger(InvokeSimulationConfig.class);
private static final Logger log = LoggerFactory.getLogger(SimulationInvokeConfig.class);

@Bean
Consumer<Flux<SimulationMessage>> invokeSimulation() {
Consumer<Flux<SimulationMessage>> simulationInvoke() {
return flux -> flux.map(simulationMessage -> simulationMessage.modelId())
.doOnNext(modelId -> log.info("The simulation with model id {} is invoked", modelId))
.subscribe();
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ spring:
multiplier: 1.1
stream:
bindings:
invokeSimulation-in-0:
destination: invoke-simulation
simulationInvoke-in-0:
destination: simulation-invoke
group: ${spring.application.name}
lifecycle:
timeout-per-shutdown-phase: 15s
Expand Down

0 comments on commit 00d15f1

Please sign in to comment.