Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,25 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version:
- "nightly"
os:
- ubuntu-latest
julia-arch:
- x64
include:
- os: ubuntu-latest
julia-arch: x64
julia-version: 'nightly'
- os: windows-latest
julia-arch: x64
julia-version: 'nightly'
- os: macos-latest
julia-arch: aarch64
julia-version: 'nightly'
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- name: Cache artifacts
uses: actions/cache@v2
env:
cache-name: cache-artifacts
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v2
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-uploadcodecov@v0.1
continue-on-error: true
- uses: julia-actions/julia-uploadcoveralls@v0.1
continue-on-error: true
files: lcov.info
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Manifest.toml
61 changes: 59 additions & 2 deletions src/LazyArtifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,64 @@ using Artifacts: Artifacts,
export artifact_exists, artifact_path, artifact_meta, artifact_hash,
select_downloadable_artifacts, find_artifacts_toml, @artifact_str

# define a function for satisfying lazy Artifact downloads
using Pkg.Artifacts: ensure_artifact_installed
using Base.BinaryPlatforms: AbstractPlatform, HostPlatform
using Base: SHA1

"""
ensure_artifact_installed(name::String, artifacts_toml::String;
platform::AbstractPlatform = HostPlatform(),
pkg_uuid::Union{Base.UUID,Nothing}=nothing,
verbose::Bool = false,
quiet_download::Bool = false,
io::IO=stderr)

Ensures an artifact is installed, downloading it via the download information stored in
`artifacts_toml` if necessary. Throws an error if unable to install.
"""
function ensure_artifact_installed(name::String, artifacts_toml::String;
platform::AbstractPlatform=HostPlatform(),
pkg_uuid::Union{Base.UUID,Nothing}=nothing,
verbose::Bool=false,
quiet_download::Bool=false,
io::IO=stderr)
meta = artifact_meta(name, artifacts_toml; pkg_uuid=pkg_uuid, platform=platform)
if meta === nothing
error("Cannot locate artifact '$(name)' in '$(artifacts_toml)'")
end

return ensure_artifact_installed(name, meta, artifacts_toml;
platform, verbose, quiet_download, io)
end

function ensure_artifact_installed(name::String, meta::Dict, artifacts_toml::String;
platform::AbstractPlatform=HostPlatform(),
verbose::Bool=false,
quiet_download::Bool=false,
io::IO=stderr)

hash = SHA1(meta["git-tree-sha1"])
if !artifact_exists(hash)
# loading Pkg is a bit slow, so we only do it if we need to
# and do it in a subprocess to avoid precompilation complexity
code = """
Pkg = Base.require_stdlib(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"));
ret = Pkg.Artifacts.try_artifact_download_sources(
$(repr(name)),
Base.$(repr(hash)),
$(repr(meta)),
$(repr(artifacts_toml));
platform = Base.BinaryPlatforms.$(repr(platform)),
verbose = $(repr(verbose)),
quiet_download = $(repr(quiet_download)),
io = stderr
)
println(stdout, ret)
"""
ret = String(readchomp(pipeline(`$(Base.julia_cmd()) -e $code`, stderr=io)))
return ret
Comment thread
IanButterworth marked this conversation as resolved.
Outdated
else
return artifact_path(hash)
end
end

end