diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ade688048..a21f04c7c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -447,6 +447,11 @@ jobs: ranks: - 2 - 4 + include: + # Instrument one existing cell; the other nine keep their normal cost. + - version: '1' + ranks: 2 + coverage: true steps: - uses: actions/checkout@v7 - uses: julia-actions/setup-julia@v3 @@ -463,7 +468,15 @@ jobs: - name: Instantiate CPU MPI environment run: julia --project=test/mpi/env -e 'using Pkg; Pkg.develop([PackageSpec(path=pwd()), PackageSpec(path="lib/TimespanLogging")]); Pkg.instantiate()' - name: Run CPU MPI tests - run: julia --project=test/mpi/env test/mpi/run.jl ${{ matrix.ranks }} 2 test/mpi/cpu.jl + run: julia ${{ matrix.coverage && '--code-coverage=user' || '' }} --project=test/mpi/env test/mpi/run.jl ${{ matrix.ranks }} 2 test/mpi/cpu.jl + - uses: julia-actions/julia-processcoverage@v1 + if: matrix.coverage + - uses: codecov/codecov-action@v7 + if: matrix.coverage + with: + files: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: false mpi-opencl: # OpenCL runs against a CPU-backed ICD (no physical GPU required), unlike diff --git a/AGENTS.md b/AGENTS.md index b08bc83a7..65af69798 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1247,3 +1247,9 @@ this section verbatim). Each entry is one bullet starting with `- `. bare `julia` through `PATH`, so select the driver's executable directory around its calls before choosing version-dependent flags. Check actual Distributed worker versions rather than assuming a remote path matches. + +112. **Enable coverage in MPI ranks, not only in their launcher.** Selecting + `Base.julia_cmd().exec[1]` keeps the executable but drops coverage options. + A launcher can therefore be instrumented while the extension exercised by + every rank reports zero hits. Forward the enabled mode/path and merge the + PID-qualified rank reports. diff --git a/test/mpi/run.jl b/test/mpi/run.jl index a670d63fb..ec86deae2 100644 --- a/test/mpi/run.jl +++ b/test/mpi/run.jl @@ -16,9 +16,23 @@ script = ARGS[3] extra = ARGS[4:end] project = Base.active_project() juliabin = Base.julia_cmd().exec[1] +# Base.julia_cmd().exec[1] selects only the executable. Preserve enabled +# instrumentation explicitly so ranks emit coverage too. Each rank uses +# Julia's default PID-qualified .cov files, which the coverage action merges. +options = Base.JLOptions() +coverage_args = if options.code_coverage == 1 + ["--code-coverage=user"] +elseif options.code_coverage == 2 + ["--code-coverage=all"] +elseif options.code_coverage == 3 + ["--code-coverage=@$(unsafe_string(options.tracked_path))"] +else + String[] +end + MPI.mpiexec() do mpiexec - cmd = `$mpiexec -n $nranks $juliabin --project=$project --threads=$threads $script $extra` + cmd = `$mpiexec -n $nranks $juliabin $coverage_args --project=$project --threads=$threads $script $extra` @info "Launching MPI job" nranks threads script proc = run(ignorestatus(cmd)) exit(proc.exitcode)