From af03ab4bfca32bb2cdaa793413856b75ba6d72e6 Mon Sep 17 00:00:00 2001 From: Fabian Kreis Date: Sun, 4 Jul 2021 16:28:04 +0200 Subject: [PATCH 1/2] Create ci.yml --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..52ac83b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ feature/* ] + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a single command using the runners shell + - name: Run a one-line script + run: echo Hello, world! + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + echo Add other actions to build, + echo test, and deploy your project. From 5516e42268fe7823e34af038650789b995623b1c Mon Sep 17 00:00:00 2001 From: Fabian Date: Sun, 4 Jul 2021 17:22:18 +0200 Subject: [PATCH 2/2] integrate sonarCloud --- .github/workflows/ci.yml | 56 +++++++------- .gitignore | 11 +-- pom.xml | 78 ++++++++++++++++++++ src/main/java/com/mycompany/app/App.java | 13 ++++ src/test/java/com/mycompany/app/AppTest.java | 20 +++++ 5 files changed, 140 insertions(+), 38 deletions(-) create mode 100644 pom.xml create mode 100644 src/main/java/com/mycompany/app/App.java create mode 100644 src/test/java/com/mycompany/app/AppTest.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52ac83b..bfb4b7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,36 +1,36 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the workflow will run +name: Build on: - # Triggers the workflow on push or pull request events but only for the master branch push: - branches: [ feature/* ] + branches: + - master pull_request: - branches: [ master ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel + types: [opened, synchronize, reopened] jobs: - # This workflow contains a single job called "build" build: - # The type of runner that the job will run on + name: Build runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - - # Runs a single command using the runners shell - - name: Run a one-line script - run: echo Hello, world! - - # Runs a set of commands using the runners shell - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your project. + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - 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 -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0e13eeb..15aedc7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,2 @@ target/ -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -# https://github.com/takari/maven-wrapper#usage-without-binary-jar -.mvn/wrapper/maven-wrapper.jar +.idea diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b4941e7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + com.mycompany.app + github-trial + 1.0-SNAPSHOT + + github-trial + + http://www.example.com + + + UTF-8 + 1.7 + 1.7 + fkreis_github-trial + fkreis + https://sonarcloud.io + + + + + junit + junit + 4.11 + test + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/src/main/java/com/mycompany/app/App.java b/src/main/java/com/mycompany/app/App.java new file mode 100644 index 0000000..77cf3e0 --- /dev/null +++ b/src/main/java/com/mycompany/app/App.java @@ -0,0 +1,13 @@ +package com.mycompany.app; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/src/test/java/com/mycompany/app/AppTest.java b/src/test/java/com/mycompany/app/AppTest.java new file mode 100644 index 0000000..81ac345 --- /dev/null +++ b/src/test/java/com/mycompany/app/AppTest.java @@ -0,0 +1,20 @@ +package com.mycompany.app; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +}