Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/ISSUE_TEMPLATE/unit-coverage-failure.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ coverage" fails when the suite covers less than 30% of the production lines. The
2. If the stage is `run_unit_tests_with_coverage`, a unit test failed; fix the code or the test.
3. If the stage is `check_line_coverage`, add unit tests for the new or changed code. The coverage report is in
the job log and in the `wp-compat-unit-coverage` artifact.
4. Re-run the workflow.
4. If the stage is `upload_coverage`, Codacy did not receive the coverage report. Check that the
`CODACY_PROJECT_TOKEN` secret holds a current repository API token from Codacy (the repository's
Settings > API tokens; Codacy shows a new token once, and each one expires within a year), and
read the step's log for the reporter's error. The tests and the minimum coverage passed.
5. Re-run the workflow.

This issue was automatically created by the CI/CD pipeline.
30 changes: 29 additions & 1 deletion .github/workflows/wp-compatibility-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,33 @@ jobs:
}
' "$RUNNER_TEMP/es-optimizer-diagnostics/clover.xml" "$MINIMUM_LINE_COVERAGE"

- name: Upload coverage to Codacy
id: upload_coverage
# Dependabot's and forks' pull requests get no secrets, so they skip the upload. A failed
# upload fails the job on pushes; on a pull request it is reported without blocking it.
if: ${{ github.actor != 'dependabot[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
continue-on-error: ${{ github.event_name == 'pull_request' }}
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
# Codacy's coverage reporter, pinned: update the version and the SHA-512 together, from
# the release's codacy-coverage-reporter-linux.SHA512SUM file
# (https://github.com/codacy/codacy-coverage-reporter/releases). Dependabot does not track it.
CODACY_REPORTER_VERSION: '14.1.3'
CODACY_REPORTER_SHA512: '73a6c93fc5db509fd0423d6e545759c3f61d8360ee12054e32a9277daab6add0da6c6639248f6ed6c0042366440293ebc0b6144325aef52c5d3d4b230d65eb17'
# Codacy analyzes a pull request's head commit, not the merge commit GitHub checks out
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
if [ -z "$CODACY_PROJECT_TOKEN" ]; then
echo "::error::The CODACY_PROJECT_TOKEN secret is not set, so Codacy cannot receive this commit's coverage."
exit 1
fi
reporter="$RUNNER_TEMP/codacy-coverage-reporter"
curl --proto '=https' --fail --silent --show-error --location --retry 3 --output "$reporter" \
"https://github.com/codacy/codacy-coverage-reporter/releases/download/$CODACY_REPORTER_VERSION/codacy-coverage-reporter-linux"
echo "$CODACY_REPORTER_SHA512 $reporter" | sha512sum --check --strict -
chmod +x "$reporter"
"$reporter" report --commit-uuid "$COMMIT_SHA" -r "$RUNNER_TEMP/es-optimizer-diagnostics/clover.xml"

- name: Preserve diagnostic summary
id: preserve_diagnostics
if: ${{ always() }}
Expand All @@ -1389,6 +1416,7 @@ jobs:
install_composer_dependencies=${{ steps.install_composer_dependencies.outcome }}
run_unit_tests_with_coverage=${{ steps.run_unit_tests_with_coverage.outcome }}
check_line_coverage=${{ steps.check_line_coverage.outcome }}
upload_coverage=${{ steps.upload_coverage.outcome }}
run: |
mkdir -p "$RUNNER_TEMP/es-optimizer-diagnostics"
printf '%s\n' "$STEP_RESULTS" > "$RUNNER_TEMP/es-optimizer-diagnostics/steps.txt"
Expand Down Expand Up @@ -1429,7 +1457,7 @@ jobs:
uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FAILURE_STAGE: ${{ steps.checkout_code.outcome == 'failure' && 'checkout_code' || steps.setup_php_8_4.outcome == 'failure' && 'setup_php_8_4' || steps.install_composer_dependencies.outcome == 'failure' && 'install_composer_dependencies' || steps.run_unit_tests_with_coverage.outcome == 'failure' && 'run_unit_tests_with_coverage' || steps.check_line_coverage.outcome == 'failure' && 'check_line_coverage' || 'unknown_or_canceled' }}
FAILURE_STAGE: ${{ steps.checkout_code.outcome == 'failure' && 'checkout_code' || steps.setup_php_8_4.outcome == 'failure' && 'setup_php_8_4' || steps.install_composer_dependencies.outcome == 'failure' && 'install_composer_dependencies' || steps.run_unit_tests_with_coverage.outcome == 'failure' && 'run_unit_tests_with_coverage' || steps.check_line_coverage.outcome == 'failure' && 'check_line_coverage' || steps.upload_coverage.outcome == 'failure' && 'upload_coverage' || 'unknown_or_canceled' }}
PHP_VERSION: '8.4'
RUN_ID: ${{ github.run_id }}
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
Expand Down
Loading