1+ # just configurations
2+ # setting tempdir to local path makes julia macro artifact"..." work
3+ set tempdir := " ./tmp"
4+
5+ # global variables
6+ docker_image_name := " rqatest"
7+
18default :
29 just --list
310
11+ init :
12+ #!/usr/bin/env bash
13+ set -euxo pipefail
14+ # setup pre-commit hooks via pythons uv tooling manager
15+ curl -LsSf https:// astral.sh/ uv/ install.sh | sh
16+ source ~/ .local/ bin/ env
17+ uv tool install pre-commit
18+ uvx pre-commit install
19+ # the julia formatting hook needs JuliaFormatter installed globally
20+ julia -e ' import Pkg; Pkg.add("JuliaFormatter")'
21+
422# create precompile statements used for `just packagecompile`
523precompilestatements :
624 julia --project -e ' import Pkg; Pkg.test(julia_args=`--trace-compile=packagecompiler/precompile_statements.jl`)'
@@ -9,11 +27,11 @@ precompilestatements:
927packagecompile :
1028 #!/ usr/ bin/ env -S julia --project=packagecompiler
1129 using PackageCompiler
12- if isdir(" packagecompiler/app" )
30+ if isdir(" packagecompiler/app" )
1331 rm(" packagecompiler/app.backup" , recursive=true , force=true )
1432 mv(" packagecompiler/app" , " packagecompiler/app.backup" )
1533 end
16- PackageCompiler.create_app(" ." , " packagecompiler/app" ;
34+ PackageCompiler.create_app(" ." , " packagecompiler/app" ;
1735 precompile_statements_file=" packagecompiler/precompile_statements.jl" ,
1836 # see https:// github.com/ JuliaLang/ PackageCompiler.jl/ issues/ 994
1937 include_lazy_artifacts=true ,
@@ -23,19 +41,50 @@ packagecompile:
2341 # lets have an easy check whether this actually worked
2442 touch(" packagecompiler/app/done" )
2543
26- # test the app `packagecompiler/app/RQADeforestation` with testdata, writing data to `test/tmp/apptestdata`
27- testapp :
44+ # downloads the Artifact test data to tmp/apptestdata
45+ download-test-data $ tmpdir = " tmp/apptestdata":
46+ #!/ usr/ bin/ env -S julia --project
47+ import Pkg: Artifacts.@artifact_str
48+ testdatapath = artifact" rqatestdata/RQADeforestationTestData-2.0"
49+ testdir = ENV[" tmpdir" ]
50+ rm(testdir, recursive=true , force=true )
51+ mkpath(testdir)
52+ cp(testdatapath, joinpath(testdir, " in" ))
53+
54+ # test the app `packagecompiler/app/RQADeforestation` with testdata, writing data to `tmp/apptestdata`
55+ test-app $ tmpdir = " tmp/apptestdata": (download-test-data tmpdir)
56+ #!/usr/bin/env bash
57+ set -euxo pipefail
58+ indir=" $tmpdir/in"
59+ outdir=" $tmpdir/out.zarr"
60+ ./ packagecompiler/ app/ bin/ RQADeforestation --tile E051 N018 T3 --continent EU --start-date " 2021-01-01" --end-date " 2022-01-01" --in-dir " $indir" --out-dir " $outdir"
61+
62+ # builds the standard docker
63+ build-docker :
64+ docker build -t " {{ docker_image_name}} " -f Dockerfile .
65+
66+ # tests the build docker image using the Artifact test data, writing data to `tmp/apptestdata`
67+ test-docker $ tmpdir = " tmp/apptestdata": (download-test-data tmpdir)
68+ #!/usr/bin/env bash
69+ set -euxo pipefail
70+ indir=" $tmpdir/in"
71+ outdir=" $tmpdir/out.zarr"
72+ docker run --user $(id -u):$(id -g) --rm -v " $PWD/$tmpdir" :" /$tmpdir" " {{ docker_image_name}} " --tile E051 N018 T3 --continent EU --start-date " 2021-01-01" --end-date " 2022-01-01" --in-dir " /$indir" --out-dir " /$outdir"
73+
74+ # compiles rqatrend to its own c-library using StaticCompiler.jl
75+ staticcompile :
2876 #!/usr/bin/env bash
29- cd test
30- indir=" tmp/apptestdata/in"
31- outdir=" tmp/apptestdata/out.zarr"
32- julia --project -e '
33- import Pkg: Artifacts.@artifact_str, ensure_artifact_installed
34- ensure_artifact_installed("rqatestdata", "Artifacts.toml")
35- testdatapath = joinpath(artifact"rqatestdata", "RQADeforestationTestData-1.0")
36- testdir = dirname(ARGS[1])
37- rm(testdir, recursive=true, force=true)
38- mkpath(testdir)
39- cp(testdatapath, ARGS[1])
40- ' -- " $indir"
41- ../ packagecompiler/ app/ bin/ RQADeforestation --tile E051 N018 T3 --continent EU --in-dir " $indir" --out-dir " $outdir"
77+ set -euxo pipefail
78+ if [ -d staticcompiler/ lib ]; then
79+ if [ -d staticcompiler/ lib.backup ]; then
80+ rm -rf staticcompiler/ lib.backup
81+ fi
82+ mv staticcompiler/ lib staticcompiler/ lib.backup
83+ fi
84+ # using progress plain is important as staticcompiler.jl
85+ # outputs warnings instead of errors if things may not work
86+ docker build --progress=plain -t temp-image -f Dockerfile.staticcompiler .
87+ docker create --name temp-container temp-image
88+ docker cp temp-container:/ app/ staticcompiler/ lib " $PWD/staticcompiler/lib"
89+ docker rm temp-container
90+ docker rmi temp-image
0 commit comments