bug/486_ossindex-fails-in-ci-build #698
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| matrix-build: | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| java: [17] | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| java: 21 | |
| - os: ubuntu-latest | |
| java: 25 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-os-${{ matrix.os }}-java-${{ matrix.java }} | |
| cancel-in-progress: true | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: "bash" | |
| name: "Build on ${{ matrix.os }} with Java ${{ matrix.java }}" | |
| env: | |
| DEFAULT_JAVA: 17 | |
| DEFAULT_OS: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-java@v5 | |
| name: Set up Java ${{ matrix.java }} | |
| with: | |
| distribution: "temurin" | |
| java-version: ${{ matrix.java }} | |
| cache: "maven" | |
| server-id: ossindex | |
| server-username: ${{ secrets.OSSINDEX_USERNAME }} | |
| server-password: ${{ secrets.OSSINDEX_TOKEN }} | |
| # TODO: Remove this once OSSIndex CI issue is resolved | |
| - name: Debug Maven settings.xml (redacted) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| SETTINGS="${HOME}/.m2/settings.xml" | |
| if [[ ! -f "$SETTINGS" ]]; then | |
| echo "No Maven settings.xml found at: $SETTINGS" | |
| exit 0 | |
| fi | |
| echo "Maven settings.xml at: $SETTINGS" | |
| # Redact common sensitive tags + any <passphrase> if present | |
| sed -E \ | |
| -e 's#(<username>)(</username>)#\1***EMPTY***\2#g; s#(<username>)[^<]+(</username>)#\1***REDACTED***\2#g' \ | |
| -e 's#(<password>)(</password>)#\1***EMPTY***\2#g; s#(<password>)[^<]+(</password>)#\1***REDACTED***\2#g' \ | |
| -e 's#(<passphrase>)(</passphrase>)#\1***EMPTY***\2#g; s#(<passphrase>)[^<]+(</passphrase>)#\1***REDACTED***\2#g' \ | |
| -e 's#(<token>)(</token>)#\1***EMPTY***\2#g; s#(<token>)[^<]+(</token>)#\1***REDACTED***\2#g' \ | |
| -e 's#(<privateKey>)(</privateKey>)#\1***EMPTY***\2#g; s#(<privateKey>)[^<]+(</privateKey>)#\1***REDACTED***\2#g' \ | |
| -e 's#(<secret>)(</secret>)#\1***EMPTY***\2#g; s#(<secret>)[^<]+(</secret>)#\1***REDACTED***\2#g' \ | |
| "$SETTINGS" | |
| - name: Cache SonarQube packages | |
| if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }} | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Build with Java ${{ matrix.java }} | |
| run: | | |
| # TODO: Remove this once OSSIndex CI issue is resolved. | |
| echo "Checking whether the correct Maven settings.xml is used by examination of effective settings:" | |
| mvn -q --batch-mode help:effective-settings -Doutput=effective-settings.xml | |
| grep -n "<id>ossindex</id>" -n effective-settings.xml || true | |
| mvn --batch-mode -T 1C clean org.jacoco:jacoco-maven-plugin:prepare-agent install \ | |
| -Djava.version=${{ matrix.java }} | |
| - name: Sonar analysis | |
| if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java && env.SONAR_TOKEN != null }} | |
| run: | | |
| mvn --batch-mode org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ | |
| -Dsonar.token=$SONAR_TOKEN | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| - name: Verify reproducible build | |
| # Build fails on Windows with error: "Failed to execute goal org.apache.maven.plugins:maven-artifact-plugin:3.5.0:compare (default-cli) on project openfasttrace-reporter-plaintext: Could not copy D:\a\openfasttrace\openfasttrace\reporter\plaintext\target\openfasttrace-reporter-plaintext-3.8.0.buildcompareto D:\a\openfasttrace\openfasttrace\target\openfasttrace-root-0.0.0.buildcompare" | |
| if: ${{ matrix.os != 'windows-latest' }} | |
| run: | | |
| mvn --batch-mode -T 1C clean verify artifact:compare -DskipTests \ | |
| -Djava.version=${{ matrix.java }} | |
| - name: Archive oft binary | |
| uses: actions/upload-artifact@v6 | |
| if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }} | |
| with: | |
| name: openfasttrace-binaries | |
| path: | | |
| product/target/openfasttrace-*.jar | |
| !product/target/openfasttrace-*-javadoc.jar | |
| !product/target/openfasttrace-*-sources.jar | |
| if-no-files-found: error | |
| - name: Run self-trace | |
| run: ./oft-self-trace.sh | |
| - name: Upload self-tracing report | |
| uses: actions/upload-artifact@v6 | |
| if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }} | |
| with: | |
| name: self-tracing-report | |
| path: target/self-trace-report.html | |
| if-no-files-found: error | |
| - name: Check shell scripts | |
| if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }} | |
| run: .github/workflows/run_shellcheck.sh | |
| build: | |
| needs: matrix-build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: echo "Build successful" |