name: rocprofiler-systems Code Coverage permissions: contents: read on: workflow_call: env: ROCPROFSYS_TMPDIR: "%env{PWD}%/testing-tmp" jobs: rocprofiler-systems-code-coverage: runs-on: ubuntu-latest permissions: contents: read pull-requests: write strategy: fail-fast: false matrix: rocm-version: ['7.2'] container: image: dgaliffiamd/rocprofiler-systems:ci-rocm-${{ matrix.rocm-version }}-ubuntu-22.04 options: --cap-add CAP_SYS_ADMIN env: OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 ROCPROFSYS_CAUSAL_BACKEND: perf ROCPROFSYS_CI: 'ON' ROCPROFSYS_MAX_THREADS: '64' ROCPROFSYS_KEEP_TEST_OUTPUT: '0' steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: sparse-checkout: | projects/rocprofiler-systems/ .gitmodules - name: Configure ROCm Environment shell: bash run: | echo "/opt/rocm/bin" >> $GITHUB_PATH echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=/opt/rocm/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - name: Install Packages timeout-minutes: 25 uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 #v4.0.0 with: retry_wait_seconds: 30 timeout_minutes: 25 max_attempts: 5 command: | apt-get update && apt-get remove -y --purge 'libopenmpi-dev' 'libopenmpi3' 'openmpi-bin' 'openmpi-common' && apt-get autoremove -y --purge && apt-get upgrade -y && apt-get install -y libomp-dev libtbb-dev \ libdw-dev libdwarf-dev libelf-dev libiberty-dev \ libmpich-dev mpich && apt-get autoclean - name: Install gcovr timeout-minutes: 10 shell: bash run: pip3 install 'gcovr>=8.4' - name: Sync gcov with GCC shell: bash run: | GCC_VER=$(gcc -dumpversion | cut -d. -f1) echo "GCC version: ${GCC_VER}" update-alternatives \ --install /usr/bin/gcov gcov /usr/bin/gcov-${GCC_VER} 500 - name: Configure timeout-minutes: 15 shell: bash working-directory: projects/rocprofiler-systems/ env: GIT_DISCOVERY_ACROSS_FILESYSTEM: 1 run: | git config --global --add safe.directory ${GITHUB_WORKSPACE} git config --global --add safe.directory ${PWD} echo "CMake version: $(cmake --version | head -n 1)" echo "Compiler version: $(gcc --version | head -n 1)" cmake --preset coverage \ -DROCPROFSYS_PYTHON_PREFIX=/opt/conda/envs \ -DROCPROFSYS_PYTHON_ENVS=py3.12 \ "-DROCPROFSYS_DISABLE_EXAMPLES=transpose;rccl;videodecode;jpegdecode;openmp;roctx;scratch-memory;unified-memory;transferBench;hpc;sdma_test" \ -DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }} - name: Build timeout-minutes: 60 shell: bash working-directory: projects/rocprofiler-systems/ run: | cmake --build build/coverage --parallel $(nproc) - name: Unit Tests timeout-minutes: 10 shell: bash working-directory: projects/rocprofiler-systems/ run: | ./build/coverage/bin/rocprof-sys-unit-tests - name: Generate Unit Test Coverage if: always() timeout-minutes: 15 shell: bash working-directory: projects/rocprofiler-systems/ run: | python3 scripts/generate-coverage.py \ --build-dir build/coverage \ --source-dir . \ --output-dir .codecov \ --label unit-tests - name: E2E Tests timeout-minutes: 60 shell: bash working-directory: projects/rocprofiler-systems/ run: | find build/coverage -name '*.gcda' -delete ctest --test-dir build/coverage \ --output-on-failure \ -LE "network|gpu" \ --repeat until-pass:3 after-timeout:2 - name: Generate E2E Coverage if: always() timeout-minutes: 15 shell: bash working-directory: projects/rocprofiler-systems/ run: | python3 scripts/generate-coverage.py \ --build-dir build/coverage \ --source-dir . \ --output-dir .codecov \ --label e2e-tests - name: Generate Coverage Comment if: always() id: generatereport shell: bash working-directory: projects/rocprofiler-systems/ run: | get-md-contents() { if [ -f ".codecov/${1}.md" ]; then cat ".codecov/${1}.md"; else echo "_No report generated._"; fi; } { echo "# Code Coverage Report" echo "" echo "## Unit Tests" get-md-contents unit-tests echo "" echo "## E2E Tests" get-md-contents e2e-tests echo "" echo "" } > .codecov/report.md echo 'CODECOVERAGE_REPORT<> $GITHUB_OUTPUT cat .codecov/report.md >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - name: Write Code Coverage Comment if: github.event_name == 'pull_request' timeout-minutes: 5 uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 env: COMMENT_BODY: |

Code Coverage Report

${{ steps.generatereport.outputs.CODECOVERAGE_REPORT }}
with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const commentIdentifier = ''; const commentBody = process.env.COMMENT_BODY; const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.payload.pull_request.number, }); const existingComment = comments.find(comment => comment.body.includes(commentIdentifier)); if (existingComment) { await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: existingComment.id, body: commentBody, }); core.info(`Updated comment with ID: ${existingComment.id}`); } else { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.payload.pull_request.number, body: commentBody, }); core.info('Created a new comment.'); }