-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathruntestrunner.jl
More file actions
55 lines (43 loc) · 1.86 KB
/
runtestrunner.jl
File metadata and controls
55 lines (43 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using JSON
# Setup GHA logger in CI
using Logging: global_logger
using GitHubActions: GitHubActionsLogger, set_output
get(ENV, "GITHUB_ACTIONS", "false") == "true" && global_logger(GitHubActionsLogger())
# Dir to store generated test results in
results_dir = mktempdir(; prefix="jl_test-runner_results_", cleanup=false)
# In CI, set results directory as output
set_output("results-path", results_dir)
include("eachexercise.jl")
eachexercise(ARGS) do exercise, exercise_type, exercise_path, example_path
@info "[$(uppercase(exercise_type))] Testing $exercise"
# Determine file name of the solution
meta_cfg = JSON.parsefile(joinpath(exercise_path, ".meta", "config.json"))
solution_file = meta_cfg["files"]["solution"][1]
# Copy solution to temporary directory
tmp = mktempdir(; prefix="jl_$(exercise)_")
cp(example_path, joinpath(tmp, solution_file))
# Copy auxiliary files to temporary directory
if haskey(meta_cfg["files"], "auxiliary")
for aux_file in meta_cfg["files"]["auxiliary"]
cp(joinpath(exercise_path, aux_file), joinpath(tmp, aux_file))
end
end
# Copy editor files to temporary directory
if haskey(meta_cfg["files"], "editor")
for aux_file in meta_cfg["files"]["editor"]
cp(joinpath(exercise_path, aux_file), joinpath(tmp, aux_file))
end
end
# Copy runtests.jl to temporary directory
cp(joinpath(exercise_path, "runtests.jl"), joinpath(tmp, "runtests.jl"))
# Run test-runner
run(`docker run
--network none
--read-only
--mount type=bind,src=$tmp,dst=/solution
--mount type=bind,src=$tmp,dst=/output
--mount type=tmpfs,dst=/tmp
exercism/julia-test-runner $exercise /solution /output`
)
cp(joinpath(tmp, "results.json"), joinpath(results_dir, "$(exercise_type)_$exercise.json"))
end