Skip to content

Build & Code Quality Checks #267

Build & Code Quality Checks

Build & Code Quality Checks #267

name: Build & Code Quality Checks
on:
pull_request:
branches: [ 'master', 'develop' ]
types: [ 'opened', 'reopened', 'synchronize' ]
jobs:
unit_test_and_build:
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@17f84c3641ba7b8f6deff6309fc4c864478f5d62 # v3.14.1
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Set up Maven
uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f # v4.5
with:
maven-version: 3.8.6
- name: Cache local Maven repository
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache SonarCloud packages
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
- name: Setup
run: mvn clean && mvn templating:filter-sources
- name: Unit Test and Build
run: mvn clean install
# - name: Jacoco Badge generator
# uses: cicirello/jacoco-badge-generator@v2
# with:
# generate-summary: true
# jacoco-csv-file: analytics-cli/target/site/jacoco-aggregate/jacoco.csv
#
# - name: Commit and push the badge (if it changed)
# uses: EndBug/add-and-commit@v9.1.1
# with:
# default_author: github_actions
# message: 'commit badge'
# add: '*.svg'
- name: Upload coverage report
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
with:
name: Coverage report
path: |
analytics-cli/target/site/jacoco-aggregate/
- name: PMD lint checking
run: |
mvn pmd:pmd
mvn pmd:cpd
- name: Upload PMD lint report
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
with:
name: PMD lint report
path: |
analytics-core/target/site
analytics/target/site
- name: Checkstyle lint checking
run: mvn checkstyle:checkstyle
- name: Upload Checklist lint report
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
with:
name: Checklist lint report
path: |
analytics-core/target/site
analytics/target/site
- name: Sonar analysis
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 -Dsonar.projectKey=rudderlabs_rudder-sdk-java