PavanMudigonda / jacoco-reporter

GitHub Action to Publish JaCoCo Format Code Coverage XML and attach it to the Workflow Run as a Check Run. Also can enforce Coverage Quality Gate.
https://linkedin.com/in/PavanMudigonda
MIT License
74 stars 7 forks source link

Can't get coverageSummary from outputs #56

Open 9b9 opened 9 months ago

9b9 commented 9 months ago

Describe the bug When I echo the outputs.coverageSummary, nothing is printed. I noticed that the variable is marked. Does it still work?

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Get the core coverage summary from outputs variable.

By the way, there is one less white space in the sample code:

     # ...
# ↓ 6 spaces
      - name: JaCoCo Code Coverage Report
         ...

# ↓ 5 spaces
     - name: Add Coverage Job Summary
       ...

And the GitHub will throw an error about yaml syntax:

Invalid workflow file: .github/workflows/java-pipeline.yml#L18 You have an error in your yaml syntax on line 18

atokartricentis commented 4 months ago

For me version from PR as of https://github.com/PavanMudigonda/jacoco-reporter/pull/58/commits/68322527ed7e4c03b9dd6ed43431099e498de593 is failing with:

Error: Unable to process file command 'output' successfully.
Error: Invalid format '# Coverage Report: Coverage'

for:

Run PavanMudigonda/jacoco-reporter@56-cant-get-coveragesummary-from-outputs
  with:
    coverage_results_path: /home/runner/work/project/project/jacoco.xml
    coverage_report_name: JaCoCo
    coverage_report_title: Coverage
    github_token: ***
    skip_check_run: false
    minimum_coverage: 80
    fail_below_threshold: false
    publish_only_summary: false

Other outputs are available in main branch though, so I posted summary as:

      - name: Grenerate Jacoco report
        id: jacoco_reporter
        uses: PavanMudigonda/jacoco-reporter@v5.0
        with:
          coverage_results_path: ${{ github.workspace }}/jacoco.xml
          coverage_report_name: Jacoco
          github_token: ${{ secrets.GITHUB_TOKEN }}
          skip_check_run: false
          minimum_coverage: 80
          fail_below_threshold: false
          publish_only_summary: false

      - name: Add Jacocoo report to workflow run summary
        run: |
          echo "| Outcome | Value |" >> $GITHUB_STEP_SUMMARY
          echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
          echo "| Code Coverage % | ${{ steps.jacoco_reporter.outputs.coverage_percentage }} |" >> $GITHUB_STEP_SUMMARY
          echo "| :heavy_check_mark: Number of Lines Covered | ${{ steps.jacoco_reporter.outputs.covered_lines }} |" >> $GITHUB_STEP_SUMMARY
          echo "| :x: Number of Lines Missed | ${{ steps.jacoco_reporter.outputs.missed_lines }} |" >> $GITHUB_STEP_SUMMARY
          echo "| Total Number of Lines | ${{ steps.jacoco_reporter.outputs.total_lines }} |" >> $GITHUB_STEP_SUMMARY

Here is the result look of the summary:

image

where Maven test is the name of the job.

PavanMudigondaTR commented 4 months ago

@atokartricentis I have updated the above solution in README.md for now. I will fix the variable in coming days. Thank you !