Skip to content

Commit

Permalink
Merge pull request #26
Browse files Browse the repository at this point in the history
develop
  • Loading branch information
GAulombard authored Jan 16, 2023
2 parents 82bd96f + 4ea3010 commit 05d4d64
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Build, Code Analysis and Test Cover
name: Build, Analyse and Test

on:
workflow_dispatch:
pull_request:
types: [ opened, synchronize, reopened ]
push:
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/maven-built-param.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build, Analyse and Test - with parameters

on:
workflow_dispatch:

env:
# Mysql
MYSQL_DATABASE: dummy_db_test
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
# Java
JAVA_VERSION: 19
# DockerHub
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REPOSITORY: hod0r/dummy-api
# Git
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Sonar
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_KEY: ${{ secrets.SONAR_KEY }}

jobs:
build_and_test:
name: Build, Code Analysis and Test Cover
runs-on: ubuntu-latest
services:
mysql:
image: mysql
ports:
- '3307:3306'
env:
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: checkout Git repository
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'

- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn clean install org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ env.SONAR_KEY }} -DMYSQL_USER=${{ env.MYSQL_USER }} -DMYSQL_PORT=3307 -DMYSQL_PASSWORD=${{ env.MYSQL_ROOT_PASSWORD }}

- name: Add coverage to PR
id: jacoco
uses: madrapps/jacoco-report@v1.3
with:
paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 90
min-coverage-changed-files: 90

0 comments on commit 05d4d64

Please sign in to comment.