Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run coverage for multiple packages in a mono_repo #525

Open
dcharkes opened this issue Feb 16, 2024 · 1 comment
Open

How to run coverage for multiple packages in a mono_repo #525

dcharkes opened this issue Feb 16, 2024 · 1 comment

Comments

@dcharkes
Copy link
Contributor

Sometimes I want to gather coverage for multiple packages in a mono_repo.

I tried to be smart, and run things in parallel, but that doesn't work:

$ (cd ../native_assets_cli/ && dart pub global run coverage:test_with_coverage) & (cd ../native_assets_builder/ && dart pub global run coverage:test_with_coverage) & (cd ../native_toolchain_c/ && dart pub global run coverage:test_with_coverage) && wait
[1] 88093
[2] 88094
The Dart VM service is listening on http://127.0.0.1:8181/
Could not start the VM service: localhost:8181 is already in use.
Could not start the VM service: localhost:8181 is already in use.

Maybe there is a better way to gather coverage for multiple packages.

@phcs971
Copy link

phcs971 commented Feb 26, 2024

We are using melos to manage our mono repo,

We created two scripts to handle test coverages:

  test:coverage:
    name: Test and Check Coverage
    description: "Run test in packages with test directory and generate coverage"
    run: flutter test --coverage
    exec:
      concurrency: 5
      failFast: true
    packageFilters:
      dirExists: test

  test:coverage:all:
    name: Test All and Check Coverage
    description: "Run test in all packages with test directory and generate coverage"
    run: melos run test:coverage --no-select

We send results via github actions

name: Test
on: pull_request

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: 📚 Checkout
        uses: actions/checkout@v3

      - name: 🐦 Setup Flutter
        uses: subosito/flutter-action@v2

      - name: ⚙️ Setup Melos
        uses: bluefireteam/melos-action@v2

      - name: 🧪 Test
        run: melos run test:coverage:all

      - name: 📊 Upload Coverage to Codecov
        uses: codecov/codecov-action@v3
        with:
          token: ...
          fail_ci_if_error: true

@mosuem mosuem transferred this issue from dart-archive/coverage Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants