Skip to content

Commit

Permalink
Issue checkstyle#15567: Fix the new workflow and Optimise it
Browse files Browse the repository at this point in the history
  • Loading branch information
piyush kumar sadangi authored and romani committed Aug 28, 2024
1 parent 9dac1f2 commit 2137cfd
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions .github/workflows/regression-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ jobs:
|| needs.handle_configs_in_pr_description.result == 'success')
runs-on: ubuntu-latest
outputs:
download_files_failed: ${{ steps.download_files.outputs.failed }}
branch: ${{ steps.set_branch.outputs.ref }}
commit_sha: ${{ steps.set_branch.outputs.commit_sha }}
steps:
Expand Down Expand Up @@ -557,38 +556,60 @@ jobs:
# should be always last step
send_message:
runs-on: ubuntu-latest
needs: [ check_pr_status, parse_comment, download_configs, make_report ]
if: failure() || success()
needs: [
handle_generated_config_bundle,
download_configs,
make_report ]
if: always()
&& (needs.make_report.outputs.message != ''
|| needs.download_configs.result == 'failure'
|| needs.handle_generated_config_bundle.result == 'failure')
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get message
env:
MSG: ${{ needs.make_report.outputs.message }}
DOWNLOAD_FAILED: ${{ needs.download_configs.outputs.download_files_failed }}
DOWNLOAD_RESULT: ${{ needs.download_configs.result }}
GENERATED_CONFIG_RESULT: ${{ needs.handle_generated_config_bundle.result }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p .ci-temp
JOBS_LINK="https://github.com/checkstyle/checkstyle/actions/runs/${{github.run_id}}"
if [ "$DOWNLOAD_FAILED" == "true" ]; then
echo "Report generation failed. Please use 'GitHub, generate report for" \
"check_name/example_type'<br>Link: $JOBS_LINK" > .ci-temp/message
if [ "$DOWNLOAD_RESULT" == "failure" ]; then
{
echo "Failed to download or process the specified configuration(s)."
echo "Error details: $DOWNLOAD_ERROR"
echo "<br>Please ensure you've used one of the following commands correctly:"
echo "- 'GitHub, generate report for <config_name>'"
echo "- 'GitHub, generate report by config from <file_path>'"
echo "- 'GitHub, generate report for configs in PR description'"
echo "<br>And check that all specified configs or files exist and are valid."
echo "<br>Link: $JOBS_LINK"
} > .ci-temp/message
elif [ "$GENERATED_CONFIG_RESULT" == "failure" ]; then
{
echo "Failed to generate config from the specified file."
echo "Please ensure the file exists and the path is correct."
echo "<br>Usage: 'GitHub, generate report by config from <file_path>'"
echo "<br>Link: $JOBS_LINK"
} > .ci-temp/message
elif [ -z "$MSG" ]; then
API_LINK="https://api.github.com/repos/checkstyle/checkstyle/actions/runs/"
API_LINK="${API_LINK}${{github.run_id}}/jobs"
API_LINK="https://api.github.com/repos/checkstyle/checkstyle/actions/runs/${{github.run_id}}/jobs"
curl --fail-with-body -X GET "${API_LINK}" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token $GITHUB_TOKEN" \
-o .ci-temp/info.json
jq '.jobs' .ci-temp/info.json > ".ci-temp/jobs"
jq '.[] | select(.conclusion == "failure") | .name' .ci-temp/jobs > .ci-temp/job_name
jq '.[] | select(.conclusion == "failure") | .steps' .ci-temp/jobs > .ci-temp/steps
jq '.[] | select(.conclusion == "failure") | .name' .ci-temp/steps > .ci-temp/step_name
echo "Report generation failed on phase $(cat .ci-temp/job_name)," > .ci-temp/message
echo "step $(cat .ci-temp/step_name).<br>Link: $JOBS_LINK" >> .ci-temp/message
{
echo "Report generation failed on phase $(cat .ci-temp/job_name),"
echo "step $(cat .ci-temp/step_name)."
echo "<br>Link: $JOBS_LINK"
} > .ci-temp/message
else
echo "$MSG" > .ci-temp/message
fi
Expand Down

0 comments on commit 2137cfd

Please sign in to comment.