From 83b2b6c4d9142d9ede2b168569f9b33ef6f4562b Mon Sep 17 00:00:00 2001 From: nhz2 Date: Mon, 3 Mar 2025 21:02:45 -0500 Subject: [PATCH 1/4] Save artifact download size --- src/ArtifactUtils.jl | 16 ++++++++++++---- test/runtests.jl | 40 ++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/ArtifactUtils.jl b/src/ArtifactUtils.jl index f27a9ea..3da3c3e 100644 --- a/src/ArtifactUtils.jl +++ b/src/ArtifactUtils.jl @@ -61,6 +61,8 @@ function add_artifact!( tarball_path = download(tarball_url) sha256 = sha256sum(tarball_path) + tarball_size = filesize(tarball_path) + iszero(tarball_size) && error("tarball has zero filesize") git_tree_sha1 = create_artifact() do artifact_dir unpack(tarball_path, artifact_dir) @@ -73,7 +75,7 @@ function add_artifact!( artifacts_toml, name, git_tree_sha1; - download_info = [(tarball_url, sha256)], + download_info = [(tarball_url, sha256, tarball_size)], options..., ) @@ -123,6 +125,7 @@ struct GistUploadResult localpath::Union{String,Nothing} url::String sha256::String + size::UInt64 private::Bool end @@ -169,6 +172,8 @@ function upload_to_gist( mkpath(dirname(tarball)) archive_artifact(artifact_id, tarball; archive_options...) sha256 = sha256sum(tarball) + tarball_size = filesize(tarball) + iszero(tarball_size) && error("tarball has zero filesize") url = gist_from_file(tarball; private = private) return GistUploadResult( artifact_id, @@ -176,6 +181,7 @@ function upload_to_gist( abspath(tarball), url, sha256, + tarball_size, private, ) end @@ -245,7 +251,9 @@ function upload_all_to_gist!( tarball_path = joinpath(tmpdir, up.name * extension) archive_artifact(up.git_tree_sha1, tarball_path) sha256 = sha256sum(tarball_path) - push!(artifacts[up.name]["download"], Dict{String,Any}("sha256" => sha256)) + tarball_size = filesize(tarball_path) + iszero(tarball_size) && error("tarball has zero filesize") + push!(artifacts[up.name]["download"], Dict{String,Any}("sha256" => sha256, "size" => tarball_size)) end @info "Uploading archive to gist" repo_http = with_new_gist(; private) do git_dir @@ -277,7 +285,7 @@ function add_artifact!( artifacts_toml, name, gist.artifact_id; - download_info = [(gist.url, gist.sha256)], + download_info = [(gist.url, gist.sha256, gist.size)], options..., ) end @@ -292,7 +300,7 @@ function print_artifact_entry( dict = Dict( name => Dict( "git-tree-sha1" => string(gist.artifact_id), - "download" => [Dict("url" => gist.url, "sha256" => gist.sha256)], + "download" => [Dict("url" => gist.url, "sha256" => gist.sha256, "size" => gist.size)], ), ) TOML.print(io, dict; sorted = true) diff --git a/test/runtests.jl b/test/runtests.jl index 8e0d6d9..82a2d5f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,21 @@ function _artifact(name, loc) eval(Expr(:macrocall, Symbol("@artifact_str"), LineNumberNode(1, Symbol(loc)), name)) end +expected_artifacts = Dict{String,Any}( + "JuliaMono" => Dict{String,Any}( + "git-tree-sha1" => "65279f9c8a3dd1e2cb654fdedbe8cd58889ae1bc", + "download" => Any[ + Dict{String,Any}( + "sha256" => "f1ab65231cda7981531398644a58fd5fde8f367b681e1b8e9c35d9b2aacfcb1c", + "url" => "https://github.com/cormullion/juliamono/releases/download/v0.007/JuliaMono.tar.gz", + "size" => UInt64(5752883), + ), + ], + ), + ) +expected_artifacts_nosize = deepcopy(expected_artifacts) +delete!(expected_artifacts_nosize["JuliaMono"]["download"][1], "size") + @testset "ArtifactUtils.jl" begin mktempdir() do tempdir artifact_file = joinpath(tempdir, "Artifacts.toml") @@ -19,17 +34,7 @@ end force=true, ) artifacts = TOML.parsefile(artifact_file) - @test artifacts == Dict{String,Any}( - "JuliaMono" => Dict{String,Any}( - "git-tree-sha1" => "65279f9c8a3dd1e2cb654fdedbe8cd58889ae1bc", - "download" => Any[ - Dict{String,Any}( - "sha256" => "f1ab65231cda7981531398644a58fd5fde8f367b681e1b8e9c35d9b2aacfcb1c", - "url" => "https://github.com/cormullion/juliamono/releases/download/v0.007/JuliaMono.tar.gz", - ), - ], - ), - ) + @test artifacts == expected_artifacts || artifacts == expected_artifacts_nosize ensure_artifact_installed("JuliaMono", artifact_file) @test ispath(_artifact("JuliaMono", tempdir)) hash = ArtifactUtils.sha256sum(joinpath(_artifact("JuliaMono", tempdir), "JuliaMono-Regular.ttf")) @@ -45,23 +50,14 @@ end "", "https://github.com/cormullion/juliamono/releases/download/v0.007/JuliaMono.tar.gz", "f1ab65231cda7981531398644a58fd5fde8f367b681e1b8e9c35d9b2aacfcb1c", + UInt64(5752883), false, ) mktempdir() do tempdir artifact_file = joinpath(tempdir, "Artifacts.toml") add_artifact!(artifact_file, "JuliaMono", gist) artifacts = TOML.parsefile(artifact_file) - @test artifacts == Dict{String,Any}( - "JuliaMono" => Dict{String,Any}( - "git-tree-sha1" => "65279f9c8a3dd1e2cb654fdedbe8cd58889ae1bc", - "download" => Any[ - Dict{String,Any}( - "sha256" => "f1ab65231cda7981531398644a58fd5fde8f367b681e1b8e9c35d9b2aacfcb1c", - "url" => "https://github.com/cormullion/juliamono/releases/download/v0.007/JuliaMono.tar.gz", - ), - ], - ), - ) + @test artifacts == expected_artifacts || artifacts == expected_artifacts_nosize end str = sprint(show, "text/plain", gist) @test occursin("upload_to_gist(", str) From d26dedcdbdb8775f3a92847080896a8fc6cce5f4 Mon Sep 17 00:00:00 2001 From: nhz2 Date: Mon, 3 Mar 2025 21:11:07 -0500 Subject: [PATCH 2/4] fix ci --- .github/workflows/ci.yml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2399382..d5e713b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,24 +18,15 @@ jobs: - macOS-latest - windows-latest arch: - - x64 + - 'default' fail-fast: false steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 - env: - cache-name: cache-artifacts - 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 }}- + show-versioninfo: true - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest - uses: julia-actions/julia-processcoverage@v1 @@ -51,8 +42,8 @@ jobs: name: Documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: '1' - run: | From 2063b34dc73334bfd7377b1fd444bb3ab119cabb Mon Sep 17 00:00:00 2001 From: nhz2 Date: Mon, 3 Mar 2025 21:12:43 -0500 Subject: [PATCH 3/4] fix ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5e713b..26a81b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: version: - - '1.6' + - 'lts' - '1' - 'nightly' os: From 63de442b7adfb0b0e992d0299ecc48fe419fb943 Mon Sep 17 00:00:00 2001 From: nhz2 Date: Tue, 25 Mar 2025 00:46:16 -0400 Subject: [PATCH 4/4] Update integer type --- src/ArtifactUtils.jl | 2 +- test/runtests.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ArtifactUtils.jl b/src/ArtifactUtils.jl index 3da3c3e..2eb9027 100644 --- a/src/ArtifactUtils.jl +++ b/src/ArtifactUtils.jl @@ -125,7 +125,7 @@ struct GistUploadResult localpath::Union{String,Nothing} url::String sha256::String - size::UInt64 + size::Int64 private::Bool end diff --git a/test/runtests.jl b/test/runtests.jl index 82a2d5f..633345f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,7 +16,7 @@ expected_artifacts = Dict{String,Any}( Dict{String,Any}( "sha256" => "f1ab65231cda7981531398644a58fd5fde8f367b681e1b8e9c35d9b2aacfcb1c", "url" => "https://github.com/cormullion/juliamono/releases/download/v0.007/JuliaMono.tar.gz", - "size" => UInt64(5752883), + "size" => Int64(5752883), ), ], ), @@ -50,7 +50,7 @@ end "", "https://github.com/cormullion/juliamono/releases/download/v0.007/JuliaMono.tar.gz", "f1ab65231cda7981531398644a58fd5fde8f367b681e1b8e9c35d9b2aacfcb1c", - UInt64(5752883), + Int64(5752883), false, ) mktempdir() do tempdir