From 1f311ef2056ec3ce93e99b2307375c300846295c Mon Sep 17 00:00:00 2001 From: Christina Tempelaar-Lietz Date: Wed, 3 May 2023 23:28:39 -0700 Subject: [PATCH] Update SonarCloud job to use github action to install sonar-scanner and build-wrapper. Signed-off-by: Christina Tempelaar-Lietz --- .github/workflows/analysis_workflow.yml | 24 +- .github/workflows/ci_workflow.yml | 553 ++---------------------- 2 files changed, 62 insertions(+), 515 deletions(-) diff --git a/.github/workflows/analysis_workflow.yml b/.github/workflows/analysis_workflow.yml index 17712af634..96b336409b 100644 --- a/.github/workflows/analysis_workflow.yml +++ b/.github/workflows/analysis_workflow.yml @@ -7,10 +7,14 @@ name: Analysis on: - schedule: + # schedule: # Weekly Sunday build - - cron: "0 0 * * 0" - workflow_dispatch: + # - cron: "0 0 * * 0" + # workflow_dispatch: + # + pull-request: + branches: + - main permissions: contents: read @@ -33,6 +37,7 @@ jobs: env: CXX: g++ CC: gcc + BUILD_WRAPPER_OUT_DIR: bw-output steps: # TODO: Remove this workaround following resolution of: # https://github.com/AcademySoftwareFoundation/aswf-docker/issues/43 @@ -41,7 +46,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - fetch-depth: 50 + # Disabling shallow clone is recommended for improving the + # relevancy of reporting + fetch-depth: 0 + - name: Install sonar-scanner and build-wrapper + uses: sonarsource/sonarcloud-github-c-cpp@v1 - name: Create build directories run: | mkdir _install @@ -66,7 +75,8 @@ jobs: - name: Build OpenEXR with build-wrapper shell: bash run: | - build-wrapper-linux-x86-64 --out-dir bw_output \ + build-wrapper-linux-x86-64 \ + --out-dir "${{ env.BUILD_WRAPPER_OUT_DIR }}" \ cmake --build . \ --target install \ --config Release @@ -86,7 +96,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: sonar-scanner -X -Dsonar.login=$SONAR_TOKEN + run: sonar-scanner -X -Dsonar.login=$SONAR_TOKEN \ + --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" + # ------------------------------------------------------------------------------ # Valgrind memcheck test diff --git a/.github/workflows/ci_workflow.yml b/.github/workflows/ci_workflow.yml index e361fd1add..455c06814c 100644 --- a/.github/workflows/ci_workflow.yml +++ b/.github/workflows/ci_workflow.yml @@ -30,548 +30,83 @@ permissions: contents: read jobs: - # Linux jobs run in Docker containers, so the latest OS version is OK. macOS - # and Windows jobs need to be locked to specific virtual environment - # versions to mitigate issues from OS updates, and will require maintenance - # as OS versions are retired. - # - # GH Actions (Free plan) supports 20 concurrent jobs, with 5 concurrent macOS - # jobs. This workflow tries to utilize (but not exceed) that budget to - # promote timely CI. # --------------------------------------------------------------------------- - # Linux + # SonarCloud static analysis # --------------------------------------------------------------------------- - # TODO: Add ARM build. Add sanitize build. - linux: - name: 'Linux ${{ matrix.label }}VFXP-${{ matrix.vfx-cy }} centos7 - <${{ matrix.compiler-desc }}, - C++${{ matrix.cxx-standard }}, - config=${{ matrix.build-type }}, - shared=${{ matrix.build-shared }}, - threads=${{ matrix.threads-enabled }}>' + linux_sonarcloud: + name: 'SonarCloud Linux CentOS 7 VFX CY2022 ' + if: github.repository == 'AcademySoftwareFoundation/openexr' # GH-hosted VM. The build runs in CentOS 7 'container' defined below. runs-on: ubuntu-latest container: # DockerHub: https://hub.docker.com/u/aswf # Source: https://github.com/AcademySoftwareFoundation/aswf-docker - image: aswf/ci-openexr:${{ matrix.vfx-cy }} - strategy: - matrix: - build: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] - include: - - # ------------------------------------------------------------------- - # VFX CY2022 - GCC - # ------------------------------------------------------------------- - # Shared, Release - - build: 1 - build-type: Release - build-shared: 'ON' - cxx-standard: 17 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc9.3.1 - label: - threads-enabled: 'ON' - vfx-cy: 2022 - exclude-tests: - - # Shared, Release, Threads OFF - - build: 2 - build-type: Release - build-shared: 'ON' - cxx-standard: 17 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc9.3.1 - label: - threads-enabled: 'OFF' - vfx-cy: 2022 - exclude-tests: - - # Shared, Debug - - build: 3 - build-type: Debug - build-shared: 'ON' - cxx-standard: 17 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc9.3.1 - label: - threads-enabled: 'ON' - vfx-cy: 2022 - exclude-tests: - - # Static, Release - - build: 4 - build-type: Release - build-shared: 'ON' - cxx-standard: 17 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc9.3.1 - label: - threads-enabled: 'ON' - vfx-cy: 2022 - exclude-tests: - - # Static, Debug - - build: 5 - build-type: Debug - build-shared: 'OFF' - cxx-standard: 17 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc9.3.1 - label: - threads-enabled: 'ON' - vfx-cy: 2022 - exclude-tests: - - # ------------------------------------------------------------------- - # VFX CY2021 - Clang - # ------------------------------------------------------------------- - # Release - - build: 6 - build-type: Release - build-shared: 'ON' - cxx-standard: 17 - cxx-compiler: clang++ - cc-compiler: clang - compiler-desc: clang10 - label: - threads-enabled: 'ON' - vfx-cy: 2022 - exclude-tests: - - # Debug - - build: 7 - build-type: Debug - build-shared: 'ON' - cxx-standard: 17 - cxx-compiler: clang++ - cc-compiler: clang - compiler-desc: clang10 - label: - threads-enabled: 'ON' - vfx-cy: 2022 - exclude-tests: - - # Static, Release - - build: 8 - build-type: Release - build-shared: 'ON' - cxx-standard: 17 - cxx-compiler: clang++ - cc-compiler: clang - compiler-desc: clang10 - label: - threads-enabled: 'ON' - vfx-cy: 2022 - exclude-tests: - - # Static, Debug - - build: 9 - build-type: Debug - build-shared: 'OFF' - cxx-standard: 17 - cxx-compiler: clang++ - cc-compiler: clang - compiler-desc: clang10 - label: - threads-enabled: 'ON' - vfx-cy: 2022 - exclude-tests: - - # ------------------------------------------------------------------- - # VFX CY2021 - GCC, Release - # ------------------------------------------------------------------- - # Shared, Release - - build: 10 - build-type: Release - build-shared: 'ON' - cxx-standard: 17 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc9.3.1 - label: - threads-enabled: 'ON' - vfx-cy: 2021 - exclude-tests: - - # ------------------------------------------------------------------- - # VFX CY2020 - GCC, Release - # ------------------------------------------------------------------- - # Shared, Release - - build: 11 - build-type: Release - build-shared: 'ON' - cxx-standard: 14 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc6.3.1 - label: - threads-enabled: 'ON' - vfx-cy: 2020 - exclude-tests: - - # ------------------------------------------------------------------- - # VFX CY2019 - GCC, Release - # ------------------------------------------------------------------- - # Shared, Release - - build: 12 - build-type: Release - build-shared: 'ON' - cxx-standard: 14 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc6.3.1 - label: - threads-enabled: 'ON' - vfx-cy: 2019 - exclude-tests: - - # ------------------------------------------------------------------- - # Legacy - VFX CY2019 - C++11 - # ------------------------------------------------------------------- - # Shared, Release - - build: 13 - build-type: Release - build-shared: 'ON' - cxx-standard: 11 - cxx-compiler: g++ - cc-compiler: gcc - compiler-desc: gcc6.3.1 - label: 'Legacy ' - threads-enabled: 'ON' - vfx-cy: 2019 - exclude-tests: - + image: aswf/ci-openexr:2022 env: - CXX: ${{ matrix.cxx-compiler }} - CC: ${{ matrix.cc-compiler }} + CXX: g++ + CC: gcc + BUILD_WRAPPER_OUT_DIR: bw-output steps: + # TODO: Remove this workaround following resolution of: + # https://github.com/AcademySoftwareFoundation/aswf-docker/issues/43 + - name: Setup container + run: sudo rm -rf /usr/local/lib64/cmake/glew - name: Checkout uses: actions/checkout@v3 + with: + # Disabling shallow clone is recommended for improving the + # relevancy of reporting + fetch-depth: 0 + - name: Install sonar-scanner and build-wrapper + uses: sonarsource/sonarcloud-github-c-cpp@v1 - name: Create build directories run: | mkdir _install mkdir _build - mkdir _examples - name: Configure run: | cmake .. \ -DCMAKE_INSTALL_PREFIX=../_install \ - -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} \ - -DCMAKE_CXX_FLAGS=${{ matrix.cxx-flags }} \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_STANDARD=14 \ + -DCMAKE_CXX_FLAGS="-g -O0 -fprofile-arcs -ftest-coverage" \ + -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON \ + -DCMAKE_C_FLAGS="-g -O0 -fprofile-arcs -ftest-coverage" \ + -DCMAKE_C_OUTPUT_EXTENSION_REPLACE=ON \ + -DCMAKE_EXE_LINKER_FLAGS="-lgcov" \ -DCMAKE_VERBOSE_MAKEFILE:BOOL='OFF' \ - -DBUILD_SHARED_LIBS=${{ matrix.build-shared }} \ + -DBUILD_SHARED_LIBS='OFF' \ -DOPENEXR_BUILD_TOOLS='ON' \ -DOPENEXR_RUN_FUZZ_TESTS='OFF' \ - -DOPENEXR_ENABLE_THREADING=${{ matrix.threads-enabled }} - working-directory: _build - - name: Build - run: | - cmake --build . \ - --target install \ - --config ${{ matrix.build-type }} - working-directory: _build - - name: Validate - run: | - share/ci/scripts/linux/validate_openexr_libs.sh _install - - name: Examples - run: | - # Make sure we can build the examples when configured as a - # standalone application linking against the just-installed - # OpenEXR library. - cmake ../src/examples \ - -DCMAKE_PREFIX_PATH=../../_install \ - -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} \ - -DCMAKE_CXX_FLAGS=${{ matrix.cxx-flags }} - cmake --build . \ - --config ${{ matrix.build-type }} - # Confirm the examples program runs - ./bin/OpenEXRExamples - working-directory: _examples - - name: Test - run: | - ctest -T Test ${{ matrix.exclude-tests }} \ - -C ${{ matrix.build-type }} \ - --timeout 7200 \ - --output-on-failure \ - -VV - working-directory: _build - - # --------------------------------------------------------------------------- - # macOS - # --------------------------------------------------------------------------- - # TODO: Add ARM64/x86_64 (universal 2) build - - macos: - name: 'Mac VFXP-${{ matrix.vfx-cy }} macos-${{ matrix.osver }} - <${{ matrix.compiler-desc }}, - C++${{ matrix.cxx-standard }}, - config=${{ matrix.build-type }}, - shared=${{ matrix.build-shared }}, - cxx=${{ matrix.cxx-standard }}>' - runs-on: macos-${{ matrix.osver }} - strategy: - matrix: - build: [1, 2, 3, 4] - include: - # ------------------------------------------------------------------- - # VFX CY2023 - C++17 - MacOS 11.0 - # ------------------------------------------------------------------- - # Shared, Release - - build: 1 - build-type: Release - build-shared: 'ON' - compiler-desc: AppleClang11.0 - cxx-standard: 17 - osver: 11.0 - exclude-tests: - vfx-cy: 23 - - # Static, Release - - build: 2 - build-type: Release - build-shared: 'OFF' - compiler-desc: AppleClang11.0 - cxx-standard: 17 - osver: 11.0 - exclude-tests: - vfx-cy: 23 - - # Shared, Debug - - build: 3 - build-type: Debug - build-shared: 'ON' - compiler-desc: AppleClang11.0 - cxx-standard: 17 - osver: 11.0 - exclude-tests: - vfx-cy: 23 - - # ------------------------------------------------------------------- - # VFX CY2023 - C++17 - MacOS 12 - # ------------------------------------------------------------------- - # Shared, Release - - build: 4 - build-type: Release - build-shared: 'ON' - compiler-desc: AppleClang11.0 - cxx-standard: 17 - osver: 12.0 - exclude-tests: - vfx-cy: 23 - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Create build directories - run: | - mkdir _install - mkdir _build - mkdir _examples - - name: Configure - run: | - cmake .. \ - -DCMAKE_INSTALL_PREFIX=../_install \ - -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} \ - -DCMAKE_CXX_FLAGS=${{ matrix.cxx-flags }} \ - -DCMAKE_VERBOSE_MAKEFILE:BOOL='OFF' \ - -DBUILD_SHARED_LIBS=${{ matrix.build-shared }} \ - -DOPENEXR_BUILD_TOOLS='ON' \ - -DOPENEXR_RUN_FUZZ_TESTS='OFF' - working-directory: _build - - name: Build - run: | - cmake --build . \ - --target install \ - --config ${{ matrix.build-type }} + -DOPENEXR_ENABLE_THREADING='ON' working-directory: _build - - name: Examples - run: | - # Make sure we can build the examples when configured as a - # standalone application linking against the just-installed - # OpenEXR library. - cmake ../src/examples \ - -DCMAKE_PREFIX_PATH=../../_install \ - -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} \ - -DCMAKE_CXX_FLAGS=${{ matrix.cxx-flags }} - cmake --build . \ - --config ${{ matrix.build-type }} - # Confirm the examples program runs - ./bin/OpenEXRExamples - working-directory: _examples - - name: Test - run: | - ctest -T Test ${{matrix.exclude-tests }} \ - -C ${{matrix.build-type}} \ - --timeout 7200 \ - --output-on-failure \ - -VV - working-directory: _build - - # --------------------------------------------------------------------------- - # Windows - # --------------------------------------------------------------------------- - # TODO: Debug mode is catatonically slow under windows - windows: - name: 'Windows VFXP-${{ matrix.vfx-cy }} - <${{ matrix.compiler-desc }}, - config=${{ matrix.build-type }}, - shared=${{ matrix.build-shared }}, - cxx=${{ matrix.cxx-standard }}>' - runs-on: windows-${{ matrix.osver }} - strategy: - matrix: - build: [1, 2, 3, 4] - include: - # ------------------------------------------------------------------- - # VFX CY2023 - C++17 - Windows 2022 runner - MSVC 2022 (17.5) - # ------------------------------------------------------------------- - # Shared, Release - - build: 1 - build-type: Release - build-shared: 'ON' - compiler-desc: msvc17.5 - cxx-standard: 17 - vfx-cy: 2023 - exclude-tests: '' - osver: 2022 - - # Static, Release - - build: 2 - build-type: Release - build-shared: 'OFF' - compiler-desc: msvc17.5 - cxx-standard: 17 - vfx-cy: 2023 - exclude-tests: '' - osver: 2022 - - # ------------------------------------------------------------------- - # VFX CY2022 - C++17 - Windows 2019 runner - MSVC 2019 (16.11) - # ------------------------------------------------------------------- - # Shared, Release - - build: 3 - build-type: Release - build-shared: 'ON' - compiler-desc: msvc16.11 - cxx-standard: 17 - vfx-cy: 2022 - exclude-tests: '' - osver: 2019 - - # Static, Release - - build: 4 - build-type: Release - build-shared: 'OFF' - compiler-desc: msvc16.11 - cxx-standard: 17 - vfx-cy: 2022 - exclude-tests: '' - osver: 2019 - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Create build directories - run: | - mkdir _install - mkdir _build - mkdir _examples + - name: Build OpenEXR with build-wrapper shell: bash - ## - name: Install Dependences - ## run: | - ## share/ci/scripts/windows/install_python.ps1 ${{ matrix.python-version }} $HOME - ## share/ci/scripts/windows/install_boost.ps1 ${{ matrix.boost-version }} $HOME 3.8 - ## share/ci/scripts/windows/install_zlib.ps1 ${{ matrix.zlib-version }} $HOME - ## shell: powershell - - name: Configure run: | - cmake .. \ - -DCMAKE_INSTALL_PREFIX=../_install \ - -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} \ - -DCMAKE_CXX_FLAGS=${{ matrix.cxx-flags }} \ - -DCMAKE_VERBOSE_MAKEFILE:BOOL='OFF' \ - -DBUILD_SHARED_LIBS=${{ matrix.build-shared }} \ - -DOPENEXR_BUILD_TOOLS='ON' \ - -DOPENEXR_RUN_FUZZ_TESTS='OFF' - shell: bash - working-directory: _build - - name: Build - run: | - cmake --build . \ - --target install \ - --config ${{ matrix.build-type }} - shell: bash + build-wrapper-linux-x86-64 \ + --out-dir "${{ env.BUILD_WRAPPER_OUT_DIR }}" \ + cmake --build . \ + --target install \ + --config Release working-directory: _build - ## - name: Examples - ## run: | - ## # Make sure we can build the examples when configured as a - ## # standalone application linking against the just-installed - ## # OpenEXR library. - ## cmake ../src/examples \ - ## -DCMAKE_PREFIX_PATH=../../_install \ - ## -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - ## -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} \ - ## -DCMAKE_CXX_FLAGS=${{ matrix.cxx-flags }} - ## cmake --build . \ - ## --config ${{ matrix.build-type }} - ## # Confirm the examples program runs - ## ./bin/OpenEXRExamples - ## shell: bash - ## working-directory: _examples - name: Test run: | - ctest -T Test ${{ matrix.exclude-tests }} \ - -C ${{ matrix.build-type }} \ + ctest -T Test \ + -C Release \ --timeout 7200 \ --output-on-failure \ -VV - shell: bash working-directory: _build + - name: Coverage + run: share/ci/scripts/linux/run_gcov.sh + shell: bash + - name: Sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: sonar-scanner -X -Dsonar.login=$SONAR_TOKEN \ + --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" - Docs: - # Build the documentation, using a process that mimics the readthedoc build. - # - # Note that this job does not actually build OpenEXR libraries or - # programs, it just runs doxygen, sphinx, and the - # docs/script/test_images.py script to generate the "Test Images" - # page. - - name: 'Docs' - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Create build directory - run: mkdir _build - - name: Install doxygen & imagemagick - # Need imagemagick for convert, to convert "Test Image" exrs to jpgs - # Need openexr for exrheader - # Need help2man for tool manpages - run: sudo apt-get install -y doxygen imagemagick openexr help2man - - name: Install sphinx requirements - run: pip3 install -r docs/requirements.txt - - name: Configure - run: cmake .. -DBUILD_DOCS='ON' - working-directory: _build - - name: Build - run: | - cmake --build . \ - --target docs \ - --config Release - working-directory: _build -