From c4321e700906cb0906f8eec31ba0e083f0138c97 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Wed, 10 Feb 2021 16:30:51 +0100 Subject: [PATCH] Fix validation of the generated Gitlab pipeline files We are now fetching the JSON schema from the schema store and validate the generated YAML against it. --- unittests/test_ci.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/unittests/test_ci.py b/unittests/test_ci.py index 946e96cdf7..a3f221d24f 100644 --- a/unittests/test_ci.py +++ b/unittests/test_ci.py @@ -5,7 +5,9 @@ import io +import jsonschema import requests +import yaml import reframe.frontend.ci as ci import reframe.frontend.dependencies as dependencies @@ -24,9 +26,11 @@ def test_ci_gitlab_pipeline(): ) with io.StringIO() as fp: ci.emit_pipeline(fp, cases) - yaml = fp.getvalue() + pipeline = fp.getvalue() - response = requests.post('https://gitlab.com/api/v4/ci/lint', - data={'content': {yaml}}) + # Fetch the latest Gitlab CI JSON schema + response = requests.get('https://json.schemastore.org/gitlab-ci') assert response.ok - assert response.json()['status'] == 'valid' + + schema = response.json() + jsonschema.validate(yaml.safe_load(pipeline), schema)