Support multiple test pipelines

This commit is contained in:
southerntofu 2020-09-30 10:15:44 -04:00
parent f24977c14d
commit 72c269f766
11 changed files with 96 additions and 57 deletions

3
.gitmodules vendored
View File

@ -4,3 +4,6 @@
[submodule "themes/water"]
path = themes/water
url = https://tildegit.org/southerntofu/zola-water
[submodule "submodules/endpoints"]
path = submodules/endpoints
url = https://tildegit.org/forge/endpoints

View File

@ -43,6 +43,15 @@ suites = [ "forgebuild.sh", "forgebuild.rs" ]
number = 3
# Repositories the commits originate from
commiturls = [ "https://tildegit.org/forge/build.sh/commit/", "https://tildegit.org/forge/build.rs/commit/" ]
[extra.tests.pipelines.forgebuild]
repo = "https://tildegit.org/forge/build"
url = "https://tildegit.org/forge/build/commit/$id"
impl = [ { "name" = "forgebuild.sh", "repo" = "https://tildegit.org/forge/build.sh", "url" = "https://tildegit.org/forge/build.sh/commit/$id" },
{ "name" = "forgebuild.rs", "repo" = "https://tildegit.org/forge/build.rs", "url" = "https://tildegit.org/forge/build.rs/commit/$id" } ]
[extra.tests.pipelines.endpoints]
repo = "https://tildegit.org/forge/endpoints"
url = "https://tildegit.org/forge/endpoints/commit/$id"
impl = [ { "name" = "endpoints.php", "repo" = "https://tildegit.org/forge/endpoints.php", url = "https://tildegit.org/forge/endpoints.php/commit/$id" } ]
[translations]
[translations.fr]

View File

@ -9,6 +9,10 @@
---
[endpoints](@/endpoints.fr.md)
---
forgehook
---

View File

@ -9,6 +9,10 @@
---
[endpoints](@/endpoints.md)
---
forgehook
---

1
content/endpoints.fr.md Symbolic link
View File

@ -0,0 +1 @@
../submodules/endpoints/README.md

1
content/endpoints.md Symbolic link
View File

@ -0,0 +1 @@
../submodules/endpoints/README.md

@ -1 +1 @@
Subproject commit 71b77d90df574aac98c4383ed50a8799fbfd5895
Subproject commit ec018c892fdec76437bd5a500009464c20accef7

1
submodules/endpoints Submodule

@ -0,0 +1 @@
Subproject commit 304fd9429d8c70452e6bf0276144005fcf925034

11
templates/project.html Normal file
View File

@ -0,0 +1,11 @@
{% extends 'page.html' %}{% import "tests.html" as tests %}
{% block main %}
{{ super() }}
{% if page.extra.pipeline %}
{% if page.extra.pipeline in config.extra.tests.pipelines %}
{{ tests::pipeline(directory=config.extra.tests.directory, name=page.extra.pipeline) }}
{% else %}
<p>No such pipeline ({{ page.extra.pipeline }}) defined in config.extra.pipelines</p>
{% endif %}
{% endif %}
{% endblock %}

View File

@ -1,60 +1,7 @@
{% extends "index.html" %}
{% extends "index.html" %}{% import "tests.html" as tests %}
{% block title %}{{ page.title }}{% endblock title %}
{% block main %}
<h2>forgebuild</h2>
{% set latest = [] %}
{% set data = [] %}
{% for suite in config.extra.tests.suites %}
{# Don't forget to trim() to remove confusing trailing newline #}
{% set_global latest = latest | concat(with=load_data(path="static/"~config.extra.tests.directory~"/"~suite~"/latest")|trim()) %}
{% set_global data = data | concat(with=load_data(path="static/"~config.extra.tests.directory~"/"~suite~"/results.toml")) %}
{% endfor %}
<table>
<tr>
<th>Test</th>
{% for suite in config.extra.tests.suites %}
<th>{{ suite }}
<br>{{ latest[loop.index0] | split(pat="-") | nth(n=0) | int | date(format=trans(key="dateFormat", lang=lang)) }}
</th>
{% endfor %}
</tr>
{% for testname, result in data | first | get(key=latest[0]) %}
<tr>
<td>{{ testname }}</td>
{% for suite in config.extra.tests.suites %}
{% set lastrun = latest[loop.index0] %}
<td>
<a href="{{ get_url(path=config.extra.tests.directory~"/"~suite~"/"~lastrun|split(pat="-")|nth(n=0)) }}">
{{ data[loop.index0][lastrun][testname] }}
</a>
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% for suite in config.extra.tests.suites %}
{% set suite_index = loop.index0 %}
<h2>{{ suite }}</h2>
{# This is a hack because we can't reverse a map (only arrays) #}
{% set_global runs = [] %}
{% for key, val in data[suite_index] %}{% set_global runs = runs | concat(with=key) %}{% endfor %}
{% for run in runs | reverse %}
{# TODO: configure in config.extra how many commits to display #}
{% if loop.index > config.extra.tests.number|default(value=10) %}{% break %}{% endif %}
{% set date_commit = run | split(pat="-") %}
<details class="testrun">
<summary><a href="{{ get_url(path=config.extra.tests.directory~"/"~suite~"/" ~ date_commit.0) }}">{{ date_commit[0] | int | date(format=trans(key="dateFormat", lang=lang)) }}</a> (commit {% if config.extra.tests.commiturls %}<a href="{{ config.extra.tests.commiturls[suite_index] }}{{ date_commit[1] }}">{{ date_commit[1] }}</a>{% else %}{{ date_commit[1] }}{% endif %})</summary>
<ul>
{% for testname, result in data[suite_index][run] %}
<li>{{ result }} {{ testname }}</li>
{% endfor %}
</ul>
</details>
{% endfor %}
{% for pipeline_name, _ in config.extra.tests.pipelines %}
{{ tests::pipeline(directory=config.extra.tests.directory, name=pipeline_name) }}
{% endfor %}
{% endblock main %}

58
templates/tests.html Normal file
View File

@ -0,0 +1,58 @@
{% macro pipeline(directory, name) %}
<h2>{{ name }}</h2>
{% set latest = [] %}
{% set data = [] %}
{% for impl in config.extra.tests.pipelines[name].impl %}
{# Don't forget to trim() to remove confusing trailing newline #}
{% set_global latest = latest | concat(with=load_data(path="static/"~config.extra.tests.directory~"/"~impl.name~"/latest")|trim()) %}
{% set_global data = data | concat(with=load_data(path="static/"~config.extra.tests.directory~"/"~impl.name~"/results.toml")) %}
{% endfor %}
<table>
<tr>
<th>Test</th>
{% for impl in config.extra.tests.pipelines[name].impl %}
<th>{{ impl.name }}
<br>{{ latest[loop.index0] | split(pat="-") | nth(n=0) | int | date(format=trans(key="dateFormat", lang=lang)) }}
</th>
{% endfor %}
</tr>
{% for testname, result in data | first | get(key=latest[0]) %}
<tr>
<td>{{ testname }}</td>
{% for impl in config.extra.tests.pipelines[name].impl %}
{% set lastrun = latest[loop.index0] %}
<td>
<a href="{{ get_url(path=config.extra.tests.directory~"/"~impl.name~"/"~lastrun|split(pat="-")|nth(n=0)) }}">
{{ data[loop.index0][lastrun][testname] }}
</a>
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% for impl in config.extra.tests.pipelines[name].impl %}
{% set suite_index = loop.index0 %}
<h2>{{ impl.name }}</h2>
{# This is a hack because we can't reverse a map (only arrays) #}
{% set_global runs = [] %}
{% for key, val in data[suite_index] %}{% set_global runs = runs | concat(with=key) %}{% endfor %}
{% for run in runs | reverse %}
{# TODO: configure in config.extra how many commits to display #}
{% if loop.index > config.extra.tests.number|default(value=10) %}{% break %}{% endif %}
{% set date_commit = run | split(pat="-") %}
<details class="testrun">
<summary><a href="{{ get_url(path=config.extra.tests.directory~"/"~impl.name~"/" ~ date_commit.0) }}">{{ date_commit[0] | int | date(format=trans(key="dateFormat", lang=lang)) }}</a> (commit {% if config.extra.tests.commiturls %}<a href="{{ config.extra.tests.commiturls[suite_index] }}{{ date_commit[1] }}">{{ date_commit[1] }}</a>{% else %}{{ date_commit[1] }}{% endif %})</summary>
<ul>
{% for testname, result in data[suite_index][run] %}
<li>{{ result }} {{ testname }}</li>
{% endfor %}
</ul>
</details>
{% endfor %}
{% endfor %}
{% endmacro pipeline %}