Skip to content

Commit

Permalink
Test installing bundles cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly committed Feb 8, 2024
1 parent 832168f commit 594b2b7
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 18 deletions.
79 changes: 76 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
'
2 changes: 1 addition & 1 deletion src/code_stripping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
4 changes: 3 additions & 1 deletion src/install.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)))
Expand Down
14 changes: 2 additions & 12 deletions src/remove.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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__
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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})))'`,
Expand Down

0 comments on commit 594b2b7

Please sign in to comment.