codacy / codacy-coverage-reporter-action

GitHub Action for the codacy-coverage-reporter
Other
58 stars 15 forks source link

[CY-3463] Split partial and final steps #26

Closed drdanz closed 3 years ago

drdanz commented 3 years ago

In order to send coverage from more than one of the github jobs, it would be useful to have some option to specify to run only the "partial" or only the "final" step. For example something like this:

name: codacy-coverage-reporter

on: ["push"]

jobs:
  job1:
    runs-on: ubuntu-latest
    name: build1
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Build
        # [...]

      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@master
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: cobertura.xml
          partial: true

  job2:
    runs-on: ubuntu-latest
    name: build2
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Build
        # [...]

      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@master
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: cobertura.xml
          partial: true

  finalize-coverage-report:
    runs-on: ubuntu-latest
    name: finalize-coverage-report
    needs: [job1, job2]
    steps:
      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@master
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: cobertura.xml
          final: true
github-actions[bot] commented 3 years ago

Internal ticket created : CY-3463

franciscodua commented 3 years ago

Hi @drdanz

For this kind of use case, we suggest using the script directly. In this case, you described, you could something like:

name: codacy-coverage-reporter

on: ["push"]

jobs:
  job1:
    runs-on: ubuntu-latest
    name: build1
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Build
        # [...]

      - name: Run codacy-coverage-reporter
      run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r cobertura.xml -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial

  job2:
    runs-on: ubuntu-latest
    name: build2
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Build
        # [...]

      - name: Run codacy-coverage-reporter
        run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r cobertura.xml -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial

  finalize-coverage-report:
    runs-on: ubuntu-latest
    name: finalize-coverage-report
    needs: [job1, job2]
    steps:
      - name: Run codacy-coverage-reporter
        run: bash <(curl -Ls https://coverage.codacy.com/get.sh) final -t ${{ secrets.CODACY_PROJECT_TOKEN }}

It's likely an easy change in your workflow. The main idea behind the action is to cover the most common use case, and for these different ones, we suggest using the coverage script directly.

Let us know if this helped you

drdanz commented 3 years ago

This was just a suggestion, I think it would just be nicer and less error prone to have an action to do that... Anyway the coverage script works, thanks!

franciscodua commented 3 years ago

Anyway the coverage script works, thanks!

Nice!

This was just a suggestion, I think it would just be nicer and less error prone to have an action to do that...

We appreciate the feedback and feel free to keep it coming 👍 . This feedback will be taken into account when planning future work here. Thanks.

Meanwhile, I'll close this issue. Since you have a solution