Search code examples
fluttergithub-actionscode-coveragecicd

Issue uploading CodeCov file after running "Very Good Workflows" in my GitHub workflow


I an using the very_good_workflows action to recursively run tests on my app and all the local packages contained in the project.

I want to generate and upload a codeCov file after all the tests are run, but I get the error that no such file exits.

This is my current setup:

name: Flutter CI

# This workflow is triggered on pushes and pull requests to the repository.
on:
  workflow_dispatch:
  pull_request:
    branches:
      - main

jobs:
  build:
    # Install very good cli
    uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1
    with:
      coverage_excludes: '*.g.dart *.freezed.dart'
      flutter_channel: 'stable'
      flutter_version: "3.13.x"
      test_recursion: true
      min_coverage: 70

  visualize:
    needs: build
    runs-on: ubuntu-latest
    steps:
      # Check out repository
      - uses: actions/checkout@v3

      # Setup the flutter environment
      - uses: subosito/flutter-action@v2
        with:
          channel: "stable"
          flutter-version: "3.13.x"

      # Upload coverage report to Codecov
      - name: Upload coverage report to Codecov
        uses: codecov/codecov-action@v3
        env:
          CODECOV_TOKEN: ${{ secrets.MY_CODECOV_TOKEN }}

Has anyone had any success with uploading code coverage files to codecov after a successful very good workflow run?


Solution

  • The build and visualize jobs are run in different runners.

    The reusable workflow that you're using checks out your repo, installs deps, runs tests, calculates code coverage, etc., but it doesn't upload the coverage file. So, the generated coverage file remains on the runner used to run your build job.

    One possible solution could be to run all these steps in your own workflow and add the upload step at the end of that.

    You may leverage the mechanism of passing data between jobs in a workflow as artifacts if you decide to divide your workflow in multiple jobs.