|
| 1 | +name: Tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + pull_request: |
| 7 | + types: [opened, synchronize, reopened] |
| 8 | + |
| 9 | +jobs: |
| 10 | + output-test: |
| 11 | + name: Test action outputs |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] |
| 15 | + cache: [true, false] |
| 16 | + include: |
| 17 | + - arch: X64 |
| 18 | + - os: macos-latest |
| 19 | + arch: ARM64 |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + # Specifying a specific architecture of the runner is not possible for Github hosted runners |
| 23 | + # We can only check if the runner architecture matches the expected one |
| 24 | + - name: check_runner_arch |
| 25 | + shell: bash |
| 26 | + run: | |
| 27 | + echo "Runner architecture: ${{ runner.arch }}" |
| 28 | + if [[ "${{ runner.arch }}" != "${{ matrix.arch }}" ]]; then |
| 29 | + echo "##[error]Runner architecture does not match the expected one" |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | +
|
| 33 | + - uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 36 | + |
| 37 | + - name: Run SonarQube Cloud C/C++ action |
| 38 | + id: run-action |
| 39 | + uses: ./ |
| 40 | + with: |
| 41 | + cache-binaries: ${{ matrix.cache }} |
| 42 | + |
| 43 | + - name: SONAR_HOST_URL is set |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + [[ $SONAR_HOST_URL == "https://sonarcloud.io" ]] |
| 47 | +
|
| 48 | + - name: sonar-scanner is installed and in PATH |
| 49 | + run: | |
| 50 | + sonar-scanner --help | grep "usage: sonar-scanner " |
| 51 | +
|
| 52 | + - name: sonar-scanner-binary output is correct |
| 53 | + shell: bash |
| 54 | + env: |
| 55 | + BINARY: ${{ steps.run-action.outputs.sonar-scanner-binary }} |
| 56 | + run: | |
| 57 | + "$BINARY" --help | grep "usage: sonar-scanner " |
| 58 | +
|
| 59 | + # build-wrapper does not have --help or equivalent option. |
| 60 | + # Pass to few arguments and ignore error code |
| 61 | + - name: build-wrapper is installed and in PATH on Windows |
| 62 | + if: runner.os == 'Windows' |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + (build-wrapper-win-x86-64.exe || true) | grep "build-wrapper, version " |
| 66 | +
|
| 67 | + - name: build-wrapper is installed and in PATH on Linux |
| 68 | + if: runner.os == 'Linux' |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + (build-wrapper-linux-x86-64 || true) | grep "build-wrapper, version " |
| 72 | +
|
| 73 | + - name: build-wrapper is installed and in PATH on macOS |
| 74 | + if: runner.os == 'macOs' |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + (build-wrapper-macosx-x86 || true) | grep "build-wrapper, version " |
| 78 | +
|
| 79 | + - name: build-wrapper-binary output is correct |
| 80 | + shell: bash |
| 81 | + env: |
| 82 | + BINARY: ${{ steps.run-action.outputs.build-wrapper-binary }} |
| 83 | + run: | |
| 84 | + ("$BINARY" || true) | grep "build-wrapper, version " |
0 commit comments