notebook badges

This commit is contained in:
Jukka Aho
2015-07-06 19:00:08 +03:00
parent 849d1653ad
commit 03d559e777
3 changed files with 23 additions and 7 deletions
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="107" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h63v20H0z"/><path fill="#e05d44" d="M63 0h44v20H63z"/><path fill="url(#b)" d="M0 0h107v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="31.5" y="15" fill="#010101" fill-opacity=".3">notebook</text><text x="31.5" y="14">notebook</text><text x="84" y="15" fill="#010101" fill-opacity=".3">failing</text><text x="84" y="14">failing</text></g></svg>

After

Width:  |  Height:  |  Size: 744 B

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="116" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="116" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h63v20H0z"/><path fill="#4c1" d="M63 0h53v20H63z"/><path fill="url(#b)" d="M0 0h116v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="31.5" y="15" fill="#010101" fill-opacity=".3">notebook</text><text x="31.5" y="14">notebook</text><text x="88.5" y="15" fill="#010101" fill-opacity=".3">passing</text><text x="88.5" y="14">passing</text></g></svg>

After

Width:  |  Height:  |  Size: 745 B

+21 -7
View File
@@ -1,5 +1,7 @@
# Automatically run notebooks and generate rst table for results
include("badges.jl")
""" rst file parser to find title, author and factcheck status.
"""
function parse_rst(filename)
@@ -82,7 +84,7 @@ end
Make rows from results ready to tabular form
"""
function makerows(results)
rows = ["id" "author" "description" "last run" "runtime (s)" "status" "ipynb" "pdf"]
rows = ["id" "author" "description" "status" "ipynb" "pdf" "last run" "runtime (s)"]
for (i, data) in enumerate(results)
row = ["na" "unknown" "unknown" "unknown" "unknown" "unknown" "na" "na"]
println(i)
@@ -94,17 +96,20 @@ function makerows(results)
row[2] = data["author"]
fn = data["filename"][1:end-6]
row[3] = ":doc:`$desc <$fn>`"
row[4] = Libc.strftime("%Y-%m-%d %H:%M:%S", data["last_run"])
row[5] = string(round(data["runtime"], 2))
if data["status"] == 0
row[6] = "PASS"
row[4] = ".. image:: /badges/notebook-passing.svg"
else
row[6] = "FAIL"
row[4] = ".. image:: /badges/notebook-failing.svg"
end
fn = data["filename"]
row[7] = ":download:`ipynb <$fn>`"
row[5] = ":download:`ipynb <$fn>`"
fn = data["filename"][1:end-6]*".pdf"
row[8] = ":download:`pdf <$fn>`"
row[6] = ":download:`pdf <$fn>`"
row[7] = Libc.strftime("%Y-%m-%d %H:%M:%S", data["last_run"])
row[8] = string(round(data["runtime"], 2))
rows = vcat(rows, row)
end
return rows
@@ -176,6 +181,14 @@ end
function main()
results = run_notebooks()
notebooks_total = 0
notebooks_passing = 0
for result in results
notebooks_total += 1
if result["status"] == 0
notebooks_passing += 1
end
end
rows = makerows(results)
table = write_rst_table(rows)
println(table)
@@ -183,6 +196,7 @@ function main()
open("tutorials/notebooks.rst", "w") do fid
write(fid, table)
end
make_badge("notebooks", notebooks_passing, notebooks_total, "badges/notebooks-status.svg")
end
end