maven-ci.yml 2.5 KB
Newer Older
I
Ilkka Seppälä 已提交
1 2
#
# The MIT License
3
# Copyright © 2014-2021 Ilkka Seppälä
I
Ilkka Seppälä 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

I
Ilkka Seppälä 已提交
24 25 26
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

S
Subhrodip Mohanta 已提交
27
name: Java CI
I
Ilkka Seppälä 已提交
28 29 30 31 32

on:
  push:
    branches: [ master ]

33

I
Ilkka Seppälä 已提交
34
jobs:
35

I
Ilkka Seppälä 已提交
36 37
  build:

S
Subhrodip Mohanta 已提交
38
    runs-on: ubuntu-20.04
I
Ilkka Seppälä 已提交
39 40

    steps:
41

42
    - name: Checkout Code
43
      uses: actions/checkout@master
S
Subhrodip Mohanta 已提交
44 45 46
      with:
        # Disabling shallow clone for improving relevancy of SonarQube reporting
        fetch-depth: 0
47

I
Ilkka Seppälä 已提交
48
    - name: Set up JDK 11
49
      uses: actions/setup-java@master
I
Ilkka Seppälä 已提交
50 51
      with:
        java-version: 11
52
        distribution: 'adopt'
53 54

    - name: Cache SonarCloud packages
55
      uses: actions/cache@master
56 57 58 59 60
      with:
        path: ~/.sonar/cache
        key: ${{ runner.os }}-sonar
        restore-keys: ${{ runner.os }}-sonar

61
    - name: Cache Maven dependencies
62
      uses: actions/cache@master
S
Subhrodip Mohanta 已提交
63 64 65 66 67
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
68

I
Ilkka Seppälä 已提交
69
    # Some tests need screen access
I
Ilkka Seppälä 已提交
70
    - name: Install xvfb
S
Subhrodip Mohanta 已提交
71
      run: sudo apt-get install -y xvfb
72

73
    - name: Build with Maven and run SonarQube analysis
74
      run: xvfb-run ./mvnw clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
I
Ilkka Seppälä 已提交
75
      env:
I
Ilkka Seppälä 已提交
76
        # These two env variables are needed for sonar analysis
I
Ilkka Seppälä 已提交
77
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
I
Ilkka Seppälä 已提交
78
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}