mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
76d118577e
As an example, [7964999 example_test_002_](https://gitlab.espressif.cn:6688/espressif/esp-idf/-/jobs/7964999/artifacts/file/examples/test_configs/example_test_002_.yml)
66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
# Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http:#www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import os
|
|
|
|
import yaml
|
|
|
|
|
|
class Job(dict):
|
|
"""
|
|
Gitlab CI job
|
|
|
|
:param job: job data loaded from .gitlab-ci.yml
|
|
:param job_name: job name
|
|
"""
|
|
def __init__(self, job, job_name):
|
|
super(Job, self).__init__(job)
|
|
self["name"] = job_name
|
|
self.tags = set(self["tags"])
|
|
|
|
def match_group(self, group):
|
|
"""
|
|
Match group by tags of job.
|
|
All filters values of group should be included in tags.
|
|
|
|
:param group: case group to match
|
|
:return: True or False
|
|
"""
|
|
match_result = False
|
|
if "case group" not in self and group.ci_job_match_keys == self.tags:
|
|
# group not assigned and all tags match
|
|
match_result = True
|
|
return match_result
|
|
|
|
def assign_group(self, group):
|
|
"""
|
|
assign a case group to a test job.
|
|
|
|
:param group: the case group to assign
|
|
"""
|
|
self["case group"] = group
|
|
|
|
def output_config(self, file_path):
|
|
"""
|
|
output test config to the given path.
|
|
file name will be job_name.yml
|
|
|
|
:param file_path: output file path
|
|
:return: None
|
|
"""
|
|
file_name = os.path.join(file_path, self["name"] + ".yml")
|
|
if "case group" in self:
|
|
with open(file_name, "w") as f:
|
|
yaml.safe_dump(self["case group"].output(), f, encoding='utf-8', default_flow_style=False)
|