mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
ci: always set expire_in and when with artifacts
set it under `default` does not work due to gitlab bugs. will use `default` back once the bugs are resolved.
This commit is contained in:
@@ -104,6 +104,21 @@ class YmlLinter:
|
||||
f'Please set `dependencies:` (to null) explicitly to avoid missing artifacts issue'
|
||||
)
|
||||
|
||||
def _lint_artifacts_expire_in_and_when(self) -> None:
|
||||
"""
|
||||
Set `artifacts: expire_in` and `artifacts: when` together since gitlab has bugs:
|
||||
|
||||
- https://gitlab.com/gitlab-org/gitlab/-/issues/404563 (expire_in)
|
||||
- https://gitlab.com/gitlab-org/gitlab/-/issues/440672 (when)
|
||||
"""
|
||||
for job_name, d in self.yml_config.jobs.items():
|
||||
if 'artifacts' in d:
|
||||
if 'expire_in' not in d['artifacts']:
|
||||
self._errors.append(f'job {job_name} missing `artifacts: expire_in`. (suggest to set to `1 week`)')
|
||||
|
||||
if 'when' not in d['artifacts']:
|
||||
self._errors.append(f'job {job_name} missing `artifacts: when`. (suggest to set to `always`)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
@@ -202,22 +202,34 @@ class GitlabYmlConfig:
|
||||
for k in self._job_keys:
|
||||
self._expand_extends(k)
|
||||
|
||||
def _merge_dict(self, d1: t.Dict[str, t.Any], d2: t.Dict[str, t.Any]) -> t.Any:
|
||||
for k, v in d2.items():
|
||||
if k in d1:
|
||||
if isinstance(v, dict) and isinstance(d1[k], dict):
|
||||
d1[k] = self._merge_dict(d1[k], v)
|
||||
else:
|
||||
d1[k] = v
|
||||
else:
|
||||
d1[k] = v
|
||||
|
||||
return d1
|
||||
|
||||
def _expand_extends(self, name: str) -> t.Dict[str, t.Any]:
|
||||
extends = to_list(self.config[name].pop('extends', None))
|
||||
original_d = self.config[name].copy()
|
||||
if not extends:
|
||||
return self.config[name] # type: ignore
|
||||
|
||||
original_d = self.config[name].copy()
|
||||
d = {}
|
||||
while extends:
|
||||
self._used_template_keys.update(extends)
|
||||
self._used_template_keys.update(extends) # for tracking
|
||||
|
||||
for i in extends:
|
||||
d.update(self._expand_extends(i))
|
||||
|
||||
extends = to_list(self.config[name].pop('extends', None))
|
||||
|
||||
self.config[name] = {**d, **original_d}
|
||||
self.config[name] = self._merge_dict(d, original_d)
|
||||
return self.config[name] # type: ignore
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user