From 410734b772ab44bf42c221f4d9f65e88173a2f66 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Fri, 7 Feb 2025 11:38:18 -0500 Subject: [PATCH 1/2] Run tests with code coverage enabled, and upload coverage to Codecov (attempt 2) --- .github/workflows/ci.yml | 15 ++++++++++++++- ci/ci_entrypoint.bash | 19 +++++++++++++++++++ test/runtests.jl | 2 +- test/script.bash | 9 +++++++++ test/script.jl | 2 -- 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100755 ci/ci_entrypoint.bash create mode 100755 test/script.bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8c925c..7f8d0f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,4 +44,17 @@ jobs: docker exec -t slurmctld srun -n 4 hostname - name: Test SlurmClusterManager run: | - docker exec -t slurmctld julia -e 'import Pkg; Pkg.activate("SlurmClusterManager"); Pkg.test()' + docker exec -t slurmctld /home/docker/SlurmClusterManager/ci/ci_entrypoint.bash + - run: find . -type f -name '*.cov' + - run: docker exec slurmctld /bin/bash -c 'cd /home/docker/SlurmClusterManager && tar -cf - src/*.cov' | tar -xvf - + - run: find . -type f -name '*.cov' + # - run: find . -type f -name '*.cov' -exec cat {} \; + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v5 + with: + files: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + # If this PR is from a fork, then do NOT fail CI if the Codecov upload errors. + # If this PR is NOT from a fork, then DO fail CI if the Codecov upload errors. + # If this is not a PR, then DO fail CI if the Codecov upload errors. + fail_ci_if_error: ${{ github.event_name != 'pull_request' || github.repository == github.event.pull_request.head.repo.full_name }} diff --git a/ci/ci_entrypoint.bash b/ci/ci_entrypoint.bash new file mode 100755 index 0000000..44ed677 --- /dev/null +++ b/ci/ci_entrypoint.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -euf -o pipefail + +set -x + +pwd + +ls -la . + +ls -la ./SlurmClusterManager + +julia --project=./SlurmClusterManager -e 'import Pkg; Pkg.instantiate()' + +julia --project=./SlurmClusterManager -e 'import Pkg; Pkg.status()' + +julia --project=./SlurmClusterManager -e 'import Pkg; Pkg.test(; coverage=true)' + +find . -type f -name '*.cov' diff --git a/test/runtests.jl b/test/runtests.jl index ad357e6..8772e5b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,7 +24,7 @@ end project_path = abspath(joinpath(@__DIR__, "..")) @info "" project_path jobid = withenv("JULIA_PROJECT"=>project_path) do - strip(read(`sbatch --export=ALL --parsable -n 4 -o test.out script.jl`, String)) + strip(read(`sbatch --export=ALL --parsable -n 4 -o test.out script.bash`, String)) end @info "" jobid diff --git a/test/script.bash b/test/script.bash new file mode 100755 index 0000000..c1b0289 --- /dev/null +++ b/test/script.bash @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -euf -o pipefail + +set -x + +pwd + +julia --code-coverage=user script.jl diff --git a/test/script.jl b/test/script.jl index f218f9f..68e6076 100644 --- a/test/script.jl +++ b/test/script.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - # We don't use `using Foo` here. # We either use `using Foo: hello, world`, or we use `import Foo`. # https://github.com/JuliaLang/julia/pull/42080 From 541b9abcc7cd3e1bd7b5428a701f70eb41a5f85b Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 9 Feb 2025 18:45:12 -0500 Subject: [PATCH 2/2] Add a name for a job --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f8d0f9..3dddbfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,8 @@ jobs: run: | docker exec -t slurmctld /home/docker/SlurmClusterManager/ci/ci_entrypoint.bash - run: find . -type f -name '*.cov' - - run: docker exec slurmctld /bin/bash -c 'cd /home/docker/SlurmClusterManager && tar -cf - src/*.cov' | tar -xvf - + - name: Copy .cov files out of the Docker container + run: docker exec slurmctld /bin/bash -c 'cd /home/docker/SlurmClusterManager && tar -cf - src/*.cov' | tar -xvf - - run: find . -type f -name '*.cov' # - run: find . -type f -name '*.cov' -exec cat {} \; - uses: julia-actions/julia-processcoverage@v1