• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: SonarCloud Build
2env:
3  SHOWCASE_VERSION: 0.27.0
4on:
5  push:
6    branches:
7      - main
8  pull_request:
9    types: [opened, synchronize, reopened]
10jobs:
11  build:
12    name: Build
13    runs-on: ubuntu-22.04
14    steps:
15      - uses: actions/checkout@v3
16        with:
17          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
18      - name: Set up JDK 11
19        uses: actions/setup-java@v3
20        with:
21          java-version: 11
22          distribution: temurin
23      - name: Cache SonarCloud packages
24        uses: actions/cache@v3
25        with:
26          path: ~/.sonar/cache
27          key: ${{ runner.os }}-sonar
28          restore-keys: ${{ runner.os }}-sonar
29      - name: Cache Maven packages
30        uses: actions/cache@v3
31        with:
32          path: ~/.m2
33          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
34          restore-keys: ${{ runner.os }}-m2
35      - name: Install showcase server
36        run: |
37            sudo mkdir -p /usr/src/showcase
38            sudo chown -R ${USER} /usr/src/
39            curl --location https://github.com/googleapis/gapic-showcase/releases/download/v${SHOWCASE_VERSION}/gapic-showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz --output /usr/src/showcase/showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz
40            cd /usr/src/showcase/
41            tar -xf showcase-*
42            ./gapic-showcase run &
43            cd -
44      - name: Build and analyze for full test coverage
45        env:
46          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
47          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
48        run: |
49          mvn -B verify -Dcheckstyle.skip \
50              -DenableFullTestCoverage \
51              -Penable-integration-tests \
52              org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
53              -Dsonar.projectKey=googleapis_gapic-generator-java \
54              -Dsonar.organization=googleapis \
55              -Dsonar.host.url=https://sonarcloud.io
56
57      - name: Build and analyze Showcase Integration Tests Coverage
58        env:
59          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
60          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
61        run: |
62          mvn -B clean verify -Dcheckstyle.skip \
63              -DskipUnitTests \
64              -Penable-integration-tests \
65              -DenableShowcaseTestCoverage \
66              org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
67              -Dsonar.projectKey=googleapis_gapic-generator-java_integration_tests \
68              -Dsonar.organization=googleapis \
69              -Dsonar.host.url=https://sonarcloud.io \
70              -Dsonar.projectName=java_showcase_integration_tests
71      - name: Build and analyze Showcase Unit Tests Coverage
72        env:
73          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
74          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
75        run: |
76          mvn -B clean test -Dcheckstyle.skip \
77              -DenableShowcaseTestCoverage \
78              org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
79              -Dsonar.projectKey=googleapis_gapic-generator-java_unit_tests \
80              -Dsonar.organization=googleapis \
81              -Dsonar.host.url=https://sonarcloud.io \
82              -Dsonar.projectName=java_showcase_unit_tests