Skip to content

Commit

Permalink
Project preparation...
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniotarricone committed Mar 15, 2023
1 parent 6ded249 commit 7d34d07
Show file tree
Hide file tree
Showing 9 changed files with 479 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!target/*-runner
!target/*-runner.jar
!target/lib/*
!target/quarkus-app/*
58 changes: 58 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Pull request validation

on:
pull_request:
branches:
- main
types:
- opened
- edited
- synchronize

jobs:
pr-validation:
runs-on: ubuntu-latest

steps:
- name: PR title validation
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
docs
refactor
chore
fix
feat
breaking
requireScope: false
subjectPattern: ^[A-Z].+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
doesn't match the configured pattern. Please ensure that the subject
starts with an uppercase character.
wip: false

- name: Checkout the repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build dependencies with Maven
run: mvn clean validate -Pbootstrap --no-transfer-progress

#- name: Execute unit-testing
# run: mvn clean test

- name: Execute unit-test + Calculate test coverage + SCA with Sonar
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn verify -Pvalidate --no-transfer-progress
150 changes: 150 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Release a new version

on:
pull_request:
types:
- closed
branches:
- main

jobs:
release:
if: github.event.pull_request.merged == true

runs-on: ubuntu-latest

outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}

steps:
#
# Checkout the source code.
#
- name: Checkout the source code
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_PAT }}
fetch-depth: 0

#
# Calculation of the new version (dry-run).
#
- name: Calculation of the new version (dry-run)
uses: cycjimmy/semantic-release-action@v3
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
semantic_version: 19
branch: main
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
dry_run: true

#
# Setup the JDK.
#
- name: Setup the JDK
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven

#
# Update of pom.xml with the new version + Git add + commit + push of the updated pom.xml.
#
- name: Update of pom.xml with the new version + Git add + commit + push of the updated pom.xml
if: steps.semantic.outputs.new_release_published == 'true'
run: |
mvn versions:set -DnewVersion=${{ steps.semantic.outputs.new_release_version }} --no-transfer-progress
git config user.name "GitHub Workflow"
git config user.email "<>"
git add pom.xml
git commit -m "pom.xml updated with new version ${{ steps.semantic.outputs.new_release_version }}"
git push origin main
#
# Sleep for 60s to avoid this issue: https://github.com/semantic-release/semantic-release/issues/2204
#
- name: Sleep for 60s to avoid the issue 2204
if: steps.semantic.outputs.new_release_published == 'true'
run: sleep 60s

#
# Calculation of the new version (again) with tagging + releasing + etc.
#
- name: Calculation of the new version (again) with tagging + releasing + etc
if: steps.semantic.outputs.new_release_published == 'true'
uses: cycjimmy/semantic-release-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
semantic_version: 19
branch: main
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
dry_run: false

#
# Build dependencies + Execute unit-test + Calculate test coverage + SCA with Sonar + Build native image + Docker build + Docker login + Docker push
#
- name: Build dependencies + Execute unit-test + Calculate test coverage + SCA with Sonar + Build native image + Docker build + Docker login + Docker push
if: steps.semantic.outputs.new_release_published == 'true'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn clean validate -Pbootstrap --no-transfer-progress
mvn verify -Pvalidate --no-transfer-progress
mvn clean package -Pnative -Dmaven.test.skip=true --no-transfer-progress
docker build -f src/main/docker/Dockerfile.native-micro -t ghcr.io/${{ github.repository }}:latest -t ghcr.io/${{ github.repository }}:${{ steps.semantic.outputs.new_release_version }} .
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker push -a ghcr.io/${{ github.repository }}
deploy:
needs: release

if: needs.release.outputs.new_release_published == 'true'

runs-on: ubuntu-latest

environment: dev-cd

permissions:
id-token: write

steps:
#
# Login to Azure.
#
- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

#
# Update Container App
#
- name: Update Container App
uses: azure/CLI@v1
with:
inlineScript: |
az config set extension.use_dynamic_install=yes_without_prompt
az containerapp update -n ${{ secrets.AZURE_CONTAINER_APP_NAME }} -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --image s${{ needs.release.outputs.new_release_version }}
# Run Integration Test
#- name: Integration Test
#- uses: actions/setup-node@v3
# with:
# node-version: 18.12.0
# run: |
# npm install -g newman
# newman run src/test/postman/Payment_Notice_Service.postman_collection.json -e src/test/postman/Azure_DEV.postman_environment.json --bail

# TODO: Run Performance Test
29 changes: 29 additions & 0 deletions .github/workflows/validate-manually.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Validate

on:
workflow_dispatch:

jobs:
validation:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build dependencies with Maven
run: mvn clean validate -Pbootstrap --no-transfer-progress

- name: SCA with Sonar
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn verify -Pvalidate --no-transfer-progress
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
.flattened-pom.xml

# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode
.factorypath

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Local environment
.env

.sonar
.scannerwork

#
# Terraform
#
src/main/terraform/identity/.terraform/
.terraform.lock.hcl


/.apt_generated/
/.apt_generated_tests/
1 change: 1 addition & 0 deletions .mvn/wrapper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maven-wrapper.jar
Loading

0 comments on commit 7d34d07

Please sign in to comment.