Skip to content
Snippets Groups Projects
Commit 8e0c0e45 authored by Martyn Welch's avatar Martyn Welch Committed by Emanuele Aina
Browse files

Separate out test case generation from deployment


Rather than looping over branches (in included template from `pages`),
generate the test cases here, provide these as an artifact and deploy
in a separate job. This avoids the regeneration of pages that have
not changed.

Use the apertis-test-cases-web as part of a multi-project pipeline to
deploy. Remove the deployment tools from this branch.

Whilst we are here, utilise an environment variable for the release to
make it easier to migrate this between releases.

Signed-off-by: default avatarMartyn Welch <martyn.welch@collabora.com>
parent 625c74bc
No related branches found
No related tags found
No related merge requests found
image: registry.gitlab.apertis.org/infrastructure/apertis-docker-images/v2021dev3-testcases-builder
variables:
release: v2021dev3
image: registry.gitlab.apertis.org/infrastructure/apertis-docker-images/${release}-testcases-builder
include:
- project: tests/apertis-test-cases
ref: pages
file: .gitlab-ci/templates-render-pages.yml
- /.gitlab-ci/templates-submit-tests.yml
test-renderer:
......@@ -11,8 +11,19 @@ test-renderer:
script:
- python3 -m unittest discover -v
pages:
extends: .render-pages
render-pages:
stage: test
script:
- ./atc -d ${release}/ --index-page test-cases/
artifacts:
paths:
- ${release}
deploy-pages:
stage: deploy
trigger:
project: tests/apertis-test-cases-web
branch: main
.minimal:
variables:
......
......@@ -22,7 +22,6 @@
###################################################################################
from atc_renderer import main
import atc_extra
from argparse import ArgumentParser
if '__main__' == __name__:
......
#!/usr/bin/env python3
import os
import pkg_resources
import shutil
from jinja2 import Environment, PackageLoader
PYTHON_PKGNAME='atc_extra'
def copy_files(directory, dirname, dirpath, msg):
"""
Only copy files if destination directory (dst_dir) is not in the cwd.
"""
dst_dir = os.path.join(os.path.realpath(directory), dirname)
if not os.path.isdir(dst_dir):
print("Creating directory", dst_dir)
os.mkdir(dst_dir)
print(msg, dst_dir)
files = os.listdir(dirpath)
for f in files:
shutil.copy2(os.path.join(dirpath, f), dst_dir)
def main(output_path, releases):
# Copy CSS
css_dir = pkg_resources.resource_filename(PYTHON_PKGNAME, 'css/')
copy_files(output_path, 'css/', css_dir, "Copying css style to")
# Get template from environment and render it.
env = Environment(loader=PackageLoader(PYTHON_PKGNAME, 'templates/'))
template_values = { 'index_files': releases}
data = env.get_template('menu.html').render(template_values)
output_path = os.path.join(output_path, "index.html")
with open(output_path, 'w') as index_html_file:
index_html_file.write(data)
This diff is collapsed.
This diff is collapsed.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="css/bootstrap.min.css" rel="stylesheet">
<title>Test Suites</title>
</head>
<body>
<main role="main" class="container" style="margin-top: 40px; margin-bottom: 40px">
<h2>Available Test Suites</h2>
<div class="list-group">
{% for name, filename in index_files %}
<a href="{{ filename }}" class="list-group-item list-group-item-action flex-column align-items-start">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1"><strong>{{ name }}</strong></h5>
</div>
</a>
{% endfor %}
</div>
</main>
</body>
</html>
#!/usr/bin/env python3
###################################################################################
# Main program to render test case files.
# Create a HTML page from a YAML test case file.
#
# Copyright (C) 2018
# Luis Araujo <luis.araujo@collabora.co.uk>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
###################################################################################
import os
from atc_extra import main
from pathlib import Path
from argparse import ArgumentParser
if '__main__' == __name__:
cli_parser = ArgumentParser(description="atc_menu (Test Case Menu Renderer)")
cli_parser.add_argument('-o', '--output-dir',
help="Directory path for generated index")
cli_parser.add_argument('test_cases',
help="Generated test case tree")
args = cli_parser.parse_args()
paths = Path(args.test_cases).iterdir()
output_path = "."
if args.output_dir:
output_path = args.output_dir
releases = []
for path in paths:
if not path.is_dir():
continue
name = os.path.relpath(path, args.test_cases)
link = os.path.relpath(path, output_path)
releases.append((name, link))
releases.sort()
main(output_path, releases)
exit(0)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Redirecting</title>
</head>
<body onload="redirect()">
<h1 style="text-align: center; padding-top: 50px; display: block;">Redirecting...</h1>
<script>
function redirect() {
setTimeout(munge_url, 100);
}
function munge_url() {
var url = window.location.pathname;
var url_parts = url.split("/");
var num = url_parts.length;
new_url = new URL(window.location);
if ((num == 2) && (url_parts[num - 1].endsWith(".html"))) {
new_url.pathname = ["latest", url_parts[num - 1]].join('/')
} else {
new_url.pathname = "";
}
window.location.replace(new_url);
}
</script>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment