This repository was archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprepare_reports.lua
More file actions
72 lines (54 loc) · 2.18 KB
/
Copy pathprepare_reports.lua
File metadata and controls
72 lines (54 loc) · 2.18 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
local pl = require "pl.import_into"()
local config = require "ci_config"
local pkg_name = os.getenv("PKG_NAME") or error("PKG_NAME must be set")
local pkg_output_dir = os.getenv("PKG_OUTPUT_DIR") or error("PKG_OUTPUT_DIR must be set")
local cloned_repo = os.getenv("CLONED_REPO") or error("CLONED_REPO must be set")
local function run_cmd(cmd)
print("+ " .. cmd)
local ok = pl.utils.execute(cmd)
if not ok then
os.exit(1)
end
end
local function write_file(path, content)
local file, err = io.open(path, "w")
if not file then
print("Something went wrong writing '" .. path .. "': " .. err)
os.exit(1)
end
file:write(content)
file:close()
end
local datayml = "name: Linux\nversions:\n"
for _, version in ipairs(config.versions) do
local dir = pl.path.join(pkg_output_dir, version)
local report = ""
local status = true
for _, task in ipairs(config.tasks) do
local status_file_path = pl.path.join(dir, task.task_id() .. "_status")
local status_file_content = pl.file.read(status_file_path)
if status_file_content then
status = status and (status_file_content == "success")
else
io.stderr:write("Could not open file '" .. task.task_id() .. "_status'")
status = false
end
local file_path = pl.path.join(dir, task.task_id() .. "_report.md")
local content = pl.file.read(file_path)
report = report .. "# Report for task '" .. task.task_id() .. "'\n\n"
if content then
report = report .. content .. "\n"
else
report = report .. "Error: Report file not found. Please check Travis log. "
end
end
local version_string = string.sub(version, ("lua "):len() + 1)
local dest_dir = pl.path.join(cloned_repo, "packages", pkg_name, "linux", version_string)
run_cmd("mkdir -p \"" .. dest_dir .. "\"")
write_file(pl.path.join(dest_dir, "install.md"), report)
datayml = datayml .. " - version: " .. version_string .. "\n"
datayml = datayml .. " success: " .. (status and "true" or "false") .. "\n"
end
local ymlfile_dir = pl.path.join(cloned_repo, "_data", "packages", pkg_name)
run_cmd("mkdir -p \"" .. ymlfile_dir .. "\"")
write_file(pl.path.join(ymlfile_dir, "linux.yml"), datayml)