|
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +# contributor license agreements. See the NOTICE file distributed with |
| 4 | +# this work for additional information regarding copyright ownership. |
| 5 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | +# (the "License"); you may not use this file except in compliance with |
| 7 | +# the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +name: SonarBuild |
| 19 | + |
| 20 | +on: |
| 21 | + pull_request: |
| 22 | + branches: |
| 23 | + - main |
| 24 | + paths-ignore: |
| 25 | + - README.md |
| 26 | + - SECURITY.md |
| 27 | + - Jenkinsfile |
| 28 | + - Jenkinsfile.* |
| 29 | + - NOTICE.txt |
| 30 | + |
| 31 | +permissions: |
| 32 | + contents: read |
| 33 | + |
| 34 | +concurrency: |
| 35 | + group: sonar-pr-${{ github.event.pull_request.head.repo.full_name }}-${{ github.event.pull_request.head.ref }} |
| 36 | + cancel-in-progress: true |
| 37 | + |
| 38 | +jobs: |
| 39 | + build: |
| 40 | + if: github.repository == 'apache/camel' |
| 41 | + name: Build for Sonar Analysis |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 45 | + with: |
| 46 | + persist-credentials: false |
| 47 | + |
| 48 | + - id: install-packages |
| 49 | + uses: ./.github/actions/install-packages |
| 50 | + |
| 51 | + - name: Set up JDK 21 |
| 52 | + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| 53 | + with: |
| 54 | + distribution: 'temurin' |
| 55 | + java-version: '21' |
| 56 | + cache: 'maven' |
| 57 | + |
| 58 | + - name: Build with Maven |
| 59 | + run: ./mvnw install -B -Dquickly |
| 60 | + |
| 61 | + # Run core tests with JaCoCo and generate aggregated coverage report. |
| 62 | + # Core modules need the aggregated report because camel-core tests |
| 63 | + # exercise classes from camel-core-model, camel-core-processor, etc. |
| 64 | + - name: Run core tests with coverage |
| 65 | + run: > |
| 66 | + ./mvnw verify -B -Dcoverage |
| 67 | + -pl core/camel-api,core/camel-util,core/camel-support,core/camel-management-api,core/camel-management,core/camel-base,core/camel-base-engine,core/camel-core-engine,core/camel-core-languages,core/camel-core-model,core/camel-core-processor,core/camel-core-reifier,core/camel-core,coverage |
| 68 | + -Dmaven.test.failure.ignore=true |
| 69 | +
|
| 70 | + # Run tests on PR-affected modules with JaCoCo coverage. |
| 71 | + # Each component module generates its own per-module report |
| 72 | + # (target/site/jacoco/jacoco.xml) covering its own classes. |
| 73 | + - name: Run incremental tests with coverage |
| 74 | + uses: ./.github/actions/incremental-build |
| 75 | + with: |
| 76 | + pr-id: ${{ github.event.pull_request.number }} |
| 77 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + artifact-upload-suffix: sonar |
| 79 | + env: |
| 80 | + MVND_OPTS: "-Dcoverage -Dmaven.test.failure.ignore=true" |
| 81 | + |
| 82 | + - name: Prepare compiled classes artifact |
| 83 | + shell: bash |
| 84 | + run: find . -name "target" -type d | tar -czf target.tar.gz -T - |
| 85 | + |
| 86 | + - name: Upload compiled classes artifact |
| 87 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 88 | + id: target-upload |
| 89 | + with: |
| 90 | + name: sonar-target |
| 91 | + path: target.tar.gz |
| 92 | + if-no-files-found: error |
| 93 | + retention-days: 1 |
| 94 | + |
| 95 | + - name: Prepare pull request metadata |
| 96 | + shell: bash |
| 97 | + run: | |
| 98 | + echo "${{ github.event.pull_request.number }}" > pr-event.txt |
| 99 | + echo "${{ github.event.pull_request.head.ref }}" >> pr-event.txt |
| 100 | + echo "${{ github.event.pull_request.base.ref }}" >> pr-event.txt |
| 101 | + echo "${{ github.event.pull_request.head.sha }}" >> pr-event.txt |
| 102 | + echo "${{ steps.target-upload.outputs.artifact-id }}" >> pr-event.txt |
| 103 | +
|
| 104 | + - name: Upload pull request metadata |
| 105 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 106 | + with: |
| 107 | + name: sonar-pr-event |
| 108 | + path: pr-event.txt |
| 109 | + if-no-files-found: error |
| 110 | + retention-days: 1 |
0 commit comments