From fe8a6ee781e9a6da4b2d2ab3ab77922b95aa4147 Mon Sep 17 00:00:00 2001 From: MichaelHatherly Date: Thu, 20 Jun 2024 17:09:56 +0100 Subject: [PATCH] Isolated bundle tests --- .github/workflows/CI.yml | 63 +++++++++++++++++++++++++++++++++++++-- .gitignore | 1 + test/scripts/Project.toml | 4 +++ test/scripts/remove.jl | 13 ++++++++ test/scripts/verify.jl | 23 ++++++++++++++ 5 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 test/scripts/Project.toml create mode 100644 test/scripts/remove.jl create mode 100644 test/scripts/verify.jl diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5afea82..099ccc6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,15 +21,17 @@ permissions: jobs: finalize: timeout-minutes: 10 - needs: [test] + needs: [test, isolated-tests] if: always() runs-on: ubuntu-latest steps: - run: | echo test-bundle: ${{ needs.test.result }} + echo isolated-tests: ${{ needs.isolated-tests.result }} - run: exit 1 if: | - (needs.test.result != 'success') + (needs.test.result != 'success') || + (needs.isolated-tests.result != 'success') test: runs-on: ${{ matrix.os }} @@ -54,3 +56,60 @@ jobs: - uses: julia-actions/cache@d48542bb7b6239a9391789f01d21a6bdde9ad5df - uses: julia-actions/julia-buildpkg@90dd6f23eb49626e4e6612cb9d64d456f86e6a1c - uses: julia-actions/julia-runtest@79a7e100883947123f8263c5f06e6c0ea3eb972f + - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 + with: + name: bundle-${{ matrix.os }} + path: test/build/LocalCustomRegistry + + isolated-tests: + needs: [test] + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + version: + - "1.10" + os: + - macos-latest + - ubuntu-latest + - windows-latest + bundle: + - bundle-macos-latest + - bundle-ubuntu-latest + - bundle-windows-latest + + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + persist-credentials: false + + - uses: julia-actions/install-juliaup@2ad49a51b33d519705c111f7b6fe9d069f356da5 + with: + channel: "${{ matrix.version }}" + + - uses: julia-actions/cache@d48542bb7b6239a9391789f01d21a6bdde9ad5df + + - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e + with: + name: ${{ matrix.bundle }} + path: ${{ matrix.bundle }} + + - name: Initialize Julia Depot + run: julia -e 'import Pkg; Pkg.status()' + + - name: Install bundle + run: julia ${{ matrix.bundle }}/registry/install.jl + + - name: Installing the same bundle again should uninstall and reinstall + run: julia ${{ matrix.bundle }}/registry/install.jl + + - name: Instantiate scripts project + run: julia --startup-file=no --project=test/scripts -e 'import Pkg; Pkg.instantiate()' + + - name: Verify bundle + run: julia --startup-file=no --project=test/scripts test/scripts/verify.jl + + - name: Remove bundle + run: julia --startup-file=no --project=test/scripts test/scripts/remove.jl + if: always() diff --git a/.gitignore b/.gitignore index 9d00c51..86da307 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /Manifest.toml /test/Manifest.toml +/test/scripts/Manifest.toml /test/packages/**/Manifest.toml /test/environments/**/Manifest.toml *.pem diff --git a/test/scripts/Project.toml b/test/scripts/Project.toml new file mode 100644 index 0000000..069cc88 --- /dev/null +++ b/test/scripts/Project.toml @@ -0,0 +1,4 @@ +[deps] +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/scripts/remove.jl b/test/scripts/remove.jl new file mode 100644 index 0000000..117ccc6 --- /dev/null +++ b/test/scripts/remove.jl @@ -0,0 +1,13 @@ +using Test + +@testset "Remove Bundles" begin + count = 0 + for depot in DEPOT_PATH + path = joinpath(depot, "registries", "LocalCustomRegistry", "remove.jl") + if isfile(path) + run(`julia --startup-file=no $path`) + count += 1 + end + end + @test count == 1 +end diff --git a/test/scripts/verify.jl b/test/scripts/verify.jl new file mode 100644 index 0000000..aa719cf --- /dev/null +++ b/test/scripts/verify.jl @@ -0,0 +1,23 @@ +using Test +import Pkg +import TOML + +@testset "Verify Bundles" begin + count = 0 + env_dir = joinpath(DEPOT_PATH[1], "environments") + for named_env in readdir(env_dir) + if contains(named_env, "Bundle") + manifest_toml_file = joinpath(env_dir, named_env, "Manifest.toml") + @assert isfile(manifest_toml_file) + manifest_toml = TOML.parsefile(manifest_toml_file) + resolved_version = manifest_toml["julia_version"] + output = readchomp( + `julia +$resolved_version --startup-file=no --project=@$named_env -e "import TestPackage; TestPackage.greet()"`, + ) + package_version = manifest_toml["deps"]["TestPackage"][1]["version"] + @test contains(output, "Hello, $(package_version)!") + count += 1 + end + end + @test count == 4 +end