-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41087be
commit 8a9bdf9
Showing
21 changed files
with
407 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ QUBOTools = "0.10" | |
SQLite = "1" | ||
Pkg = "1" | ||
TOML = "1" | ||
julia = "1.9" | ||
julia = "1.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Build Process | ||
|
||
Building QUBOLib from scratch | ||
|
||
## Distribution Folder structure | ||
|
||
``` | ||
dist | ||
├── build | ||
│ ├── Artifact.toml | ||
│ ├── git-tree.hash | ||
│ ├── tar-ball.hash | ||
│ ├── last.tag | ||
│ └── next.tag | ||
└── cache | ||
└── collection... | ||
└── data | ||
qubolib | ||
├── archive.h5 | ||
└── index.db | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
function clear_build(path::AbstractString = QUBOLib.root_path()) | ||
rm(build_path(path; ifmissing = identity); force = true, recursive = true) | ||
|
||
return nothing | ||
end | ||
|
||
function clear_cache(path::AbstractString = QUBOLib.root_path()) | ||
rm(cache_path(path; ifmissing = identity); force = true, recursive = true) | ||
function clear_cache!(path::AbstractString = QUBOLib.root_path()) | ||
rm(QUBOLib.cache_path(path); force = true, recursive = true) | ||
|
||
return nothing | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,94 @@ | ||
function deploy(path::AbstractString) | ||
function deploy!(path::AbstractString) | ||
@assert Sys.islinux() | ||
|
||
# Calculate tree hash | ||
tree_hash = bytes2hex(Pkg.GitTools.tree_hash(build_path(path))) | ||
git_tree_hash = bytes2hex(Pkg.GitTools.tree_hash(QUBOLib.library_path(path))) | ||
|
||
# Build tarball | ||
temp_path = abspath(Tar.create(build_path(path))) | ||
temp_path = abspath(Tar.create(QUBOLib.library_path(path))) | ||
|
||
# Compress tarball | ||
run(`gzip -9 $temp_path`) | ||
|
||
# Move tarball | ||
file_path = mkpath(abspath(dist_path(path), "qubolib.tar.gz")) | ||
tar_ball_path = mkpath(abspath(QUBOLib.dist_path(path), "qubolib.tar.gz")) | ||
|
||
rm(file_path; force = true) | ||
rm(tar_ball_path; force = true) | ||
|
||
cp("$temp_path.gz", file_path; force = true) | ||
cp("$temp_path.gz", tar_ball_path; force = true) | ||
|
||
# Remove temporary files | ||
rm(temp_path; force = true) | ||
rm("$temp_path.gz"; force = true) | ||
|
||
# Write hash to file | ||
write(joinpath(dist_path(path), "tree.hash"), tree_hash) | ||
write(joinpath(QUBOLib.build_path(path), "git-tree.hash"), git_tree_hash) | ||
|
||
# Also, compute sha256 sum | ||
ball_hash = read(pipeline(`sha256sum -z $file_path`, `cut -d ' ' -f 1`), String) | ||
tar_ball_hash = read(pipeline(`sha256sum -z $tar_ball_path`, `cut -d ' ' -f 1`), String) | ||
|
||
write(joinpath(dist_path(path), "ball.hash"), ball_hash) | ||
|
||
return nothing | ||
end | ||
write(joinpath(QUBOLib.build_path(path), "tar-ball.hash"), tar_ball_hash) | ||
|
||
function next_tag(path::AbstractString) | ||
last_tag = if haskey(ENV, "LAST_QUBOLIB_TAG") | ||
x = tryparse(VersionNumber, ENV["LAST_QUBOLIB_TAG"]) | ||
# Retrieve last QUBOLib tag | ||
# last_tag = read(joinpath(QUBOLib.build_path(path), "last.tag"), String) | ||
# next_tag = next_data_tag(last_tag) | ||
|
||
if isnothing(x) | ||
@warn("Pushing tag forward") | ||
|
||
v"0.1.0" | ||
else | ||
x | ||
end | ||
else | ||
last_tag_path = abspath(path, "last.tag") | ||
# write(joinpath(QUBOLib.build_path(path), "next.tag"), next_tag) | ||
|
||
if isfile(last_tag_path) | ||
text = read(last_tag_path, String) | ||
# # Write Artifacts.toml entry | ||
# artifact_entry = """ | ||
# [qubolib] | ||
# git-tree-sha1 = "$(git_tree_hash)" | ||
# lazy = true | ||
|
||
m = match(r"tag:\s*v(.*)", text) | ||
# [[qubolib.download]] | ||
# url = "https://github.com/JuliaQUBO/QUBOLib.jl/releases/download/$(qubolib_tag)/qubolib.tar.gz" | ||
# sha256 = "$(tar_ball_hash)" | ||
# """ | ||
|
||
if isnothing(m) | ||
@error("Tag not found in '$last_tag_path'") | ||
# write(joinpath(QUBOLib.build_path(path), "Artifacts.toml"), artifact_entry) | ||
|
||
return nothing | ||
end | ||
|
||
exit(1) | ||
end | ||
function next_data_tag(last_tag::AbstractString)::String | ||
return next_data_tag(parse(VersionNumber, last_tag)) | ||
end | ||
|
||
parse(VersionNumber, m[1]) | ||
function next_data_tag(last_tag::VersionNumber)::String | ||
next_tag = if isempty(last_tag.prerelease) | ||
@assert isempty(last_tag.build) | ||
|
||
VersionNumber( | ||
last_tag.major, | ||
last_tag.minor, | ||
last_tag.patch, | ||
("data",), | ||
(1,), | ||
) | ||
else # !isempty(last_tag.prerelease) | ||
@assert only(last_tag.prerelease) == "data" | ||
|
||
if isempty(last_tag.build) | ||
VersionNumber( | ||
last_tag.major, | ||
last_tag.minor, | ||
last_tag.patch, | ||
last_tag.prerelease, | ||
(1,), | ||
) | ||
else | ||
@error("File '$last_tag_path' not found") | ||
|
||
exit(1) | ||
@assert only(last_tag.build) isa Integer "last_tag.build = $(last_tag.build)" | ||
|
||
VersionNumber( | ||
last_tag.major, | ||
last_tag.minor, | ||
last_tag.patch, | ||
last_tag.prerelease, | ||
(only(last_tag.build) + 1,) | ||
) | ||
end | ||
end | ||
|
||
next_tag = VersionNumber( | ||
last_tag.major, | ||
last_tag.minor, | ||
last_tag.patch + 1, | ||
last_tag.prerelease, | ||
last_tag.build, | ||
) | ||
|
||
return "v$next_tag" | ||
return "v$(next_tag)" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Test | ||
|
||
include("build.jl") | ||
|
||
function test_tags() | ||
@testset "▶ Tags" begin | ||
@test next_data_tag("v0.1.0") == "v0.1.0-data+1" | ||
@test next_data_tag("v1.2.3-data+2") == "v1.2.3-data+3" | ||
end | ||
|
||
return nothing | ||
end | ||
|
||
function test_main() | ||
@testset "♦ QUBOLib.jl/scripts/build test suite ♦" verbose = true begin | ||
test_tags() | ||
end | ||
|
||
return nothing | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include("build.jl") | ||
|
||
main() # Here we go! |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.