From 594b2b76be080db19025e85d9fbd8fde54e55638 Mon Sep 17 00:00:00 2001 From: MichaelHatherly Date: Thu, 8 Feb 2024 19:25:09 +0000 Subject: [PATCH] Test installing bundles cross-platform --- .github/workflows/CI.yml | 79 ++++++++++++++++++++++++++++++++++++++-- src/code_stripping.jl | 2 +- src/install.jl | 4 +- src/remove.jl | 14 +------ test/runtests.jl | 2 +- 5 files changed, 83 insertions(+), 18 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 95e2019..7f06218 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,20 +15,21 @@ concurrency: cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} permissions: + actions: write contents: read jobs: finalize: timeout-minutes: 10 - needs: [test] + needs: [test-bundle] if: always() runs-on: ubuntu-latest steps: - run: | - echo test: ${{ needs.test.result }} + echo test: ${{ needs.test-bundle.result }} - run: exit 1 if: | - (needs.test.result != 'success') + (needs.test-bundle.result != 'success') test: runs-on: ${{ matrix.os }} @@ -50,5 +51,77 @@ jobs: - uses: julia-actions/setup-julia@a1561e938c17e7aaf8236334d6d533e774c71dcd with: version: ${{ matrix.version }} + - uses: julia-actions/cache@dc1a3cdeacb521b0ca93cfc66143fcadb15a5bd0 - uses: julia-actions/julia-buildpkg@90dd6f23eb49626e4e6612cb9d64d456f86e6a1c - uses: julia-actions/julia-runtest@79a7e100883947123f8263c5f06e6c0ea3eb972f + + - run: mv test/build/LocalCustomRegistry test/build/LocalCustomRegistry-${{ matrix.os }} + + - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + with: + name: bundle-${{ matrix.os }} + path: test/build/LocalCustomRegistry-${{ matrix.os }} + + test-bundle: + 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: julia-actions/setup-julia@a1561e938c17e7aaf8236334d6d533e774c71dcd + with: + version: ${{ matrix.version }} + + - uses: julia-actions/cache@dc1a3cdeacb521b0ca93cfc66143fcadb15a5bd0 + + - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe + 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: Resolve environment and precompile + run: | + julia --project=@CustomEnv -e ' + pushfirst!(LOAD_PATH, "@stdlib") + import Pkg + Pkg.status() + Pkg.resolve() + Pkg.precompile("CairoMakie") + ' + + - name: Load packages + run: julia --project=@CustomEnv -e 'import CairoMakie' + + - name: Remove bundle + run: | + julia -e ' + for depot in DEPOT_PATH + path = joinpath(depot, "registries", "LocalCustomRegistry", "remove.jl") + if isfile(path) + run(`julia $path`) + break + end + end + ' diff --git a/src/code_stripping.jl b/src/code_stripping.jl index 42b42b6..2a1ba42 100644 --- a/src/code_stripping.jl +++ b/src/code_stripping.jl @@ -48,7 +48,7 @@ function _generate_stripped_bundle(; if isdir(".git") error("Unreachable reached, this shouldn't be a git repo already.") else - run(`$gitcmd init`) + run(`$gitcmd init -b main`) run(`$gitcmd config user.name "PackageBundler"`) run(`$gitcmd config user.email ""`) run(`$gitcmd config core.autocrlf false`) diff --git a/src/install.jl b/src/install.jl index 7f14bea..63881c0 100644 --- a/src/install.jl +++ b/src/install.jl @@ -28,6 +28,7 @@ function main() registry_toml_file = joinpath(registry, "Registry.toml") registry_toml = TOML.parsefile(registry_toml_file) registry_name = registry_toml["name"] + registry_uuid = registry_toml["uuid"] current_registry = joinpath(depot, "registries", registry_name) current_registry_remover = joinpath(current_registry, "remove.jl") @@ -83,7 +84,8 @@ function main() if endswith(file, "remove.jl") content = replace( content, - "{{ARTIFACTS}}" => normpath(joinpath(@__DIR__, "..")), + "{{ENVIRONMENTS}}" => join(new_environments, " "), + "{{REGISTRY_UUID}}" => registry_uuid, ) end destination = normpath(joinpath(temp_dir, relpath(root, registry))) diff --git a/src/remove.jl b/src/remove.jl index 42cb70e..528645d 100644 --- a/src/remove.jl +++ b/src/remove.jl @@ -5,17 +5,11 @@ pushfirst!(LOAD_PATH, "@stdlib") import Pkg -import TOML popfirst!(LOAD_PATH) function main() - artifacts = "{{ARTIFACTS}}" - environments = normpath(joinpath(artifacts, "environments")) - packages = normpath(joinpath(artifacts, "packages")) - registry = normpath(joinpath(artifacts, "registry")) - current_environments = joinpath(@__DIR__, "..", "..", "environments") - environments_to_remove = readdir(environments) + environments_to_remove = strip.(split("{{ENVIRONMENTS}}")) @info "Removing environments" environments_to_remove for environment in environments_to_remove current_environment = joinpath(current_environments, environment) @@ -29,11 +23,7 @@ function main() @warn "Environment not found" environment end end - - resistry_toml_file = joinpath(registry, "Registry.toml") - registry_toml = TOML.parsefile(resistry_toml_file) - registry_uuid = registry_toml["uuid"] - Pkg.Registry.rm(Pkg.RegistrySpec(; uuid = registry_uuid)) + Pkg.Registry.rm(Pkg.RegistrySpec(; uuid = "{{REGISTRY_UUID}}")) end if abspath(PROGRAM_FILE) == @__FILE__ diff --git a/test/runtests.jl b/test/runtests.jl index ffc1dcf..bc91070 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,7 +23,7 @@ using Test, PackageBundler ) run(`$(Base.julia_cmd()) --startup-file=no $install_script`) run( - `$(Base.julia_cmd()) --startup-file=no --project=@CustomEnv -e 'push!(LOAD_PATH, "@stdlib"); import Pkg; Pkg.resolve(); Pkg.precompile()'`, + `$(Base.julia_cmd()) --startup-file=no --project=@CustomEnv -e 'push!(LOAD_PATH, "@stdlib"); import Pkg; Pkg.resolve(); Pkg.precompile("CairoMakie")'`, ) result = readchomp( `$(Base.julia_cmd()) --startup-file=no --project=@CustomEnv -e 'import CairoMakie; print(first(functionloc(CairoMakie.best_font, Tuple{Char})))'`,