Skip to content

Commit 3346ebe

Browse files
committed
🚀 releasing version 2.2.0 @ 2021-08-10 10:39
[skip ci]
1 parent c406016 commit 3346ebe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+740
-392
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ This project was forked from version 1.7.4 of [mbed-tools-ci-scripts](https://gi
1313

1414
[//]: # (begin_release_notes)
1515

16+
"2.2.0" (2021-08-10)
17+
====================
18+
19+
Features
20+
--------
21+
22+
- create news file on dependency update (#202108092028)
23+
- Refactored APIs for creating news files (#202108100018)
24+
25+
26+
Bugfixes
27+
--------
28+
29+
- Modified copyright template (#202108061642)
30+
- check news files on branches off beta branch (#202108092254)
31+
- Fix pdoc version as there is a bug in >= 0.9.2 (#202108101002)
32+
- Test on Python 3.9 (#202108101003)
33+
34+
1635
"2.1.3" (2021-07-19)
1736
====================
1837

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2020-2021 Arm. All rights reserved.
2+
# Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved.
33
# SPDX-License-Identifier: Apache-2.0
44
#
55
"""The version number is based on semantic versioning.
@@ -10,8 +10,8 @@
1010
1111
This file is autogenerated, do not modify by hand.
1212
"""
13-
__version__ = "2.1.3"
14-
COMMIT = "afaa6355034202a9919d5b3dae8372e7faa34137"
13+
__version__ = "2.2.0"
14+
COMMIT = "c40601694f6867d2215d8d5d10bd482117938aa9"
1515
MAJOR = 2
16-
MINOR = 1
17-
PATCH = 3
16+
MINOR = 2
17+
PATCH = 0

docs/assert_news.html

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!--
2-
-- Copyright (C) 2020-2021 Arm. All rights reserved.
2+
-- Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved.
33
-- SPDX-License-Identifier: Apache-2.0
44
-->
55
<!doctype html>
66
<html lang="en">
77
<head>
88
<meta charset="utf-8">
99
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
10-
<meta name="generator" content="pdoc 0.9.2" />
10+
<meta name="generator" content="pdoc 0.9.1" />
1111
<title>continuous_delivery_scripts.assert_news API documentation</title>
1212
<meta name="description" content="Checks if valid news files are created for changes in the project." />
1313
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
@@ -46,6 +46,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
4646
from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
4747
from continuous_delivery_scripts.utils.git_helpers import ProjectTempClone, LocalProjectRepository, GitWrapper
4848
from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
49+
from continuous_delivery_scripts.utils.news_file import create_news_file
4950

5051
logger = logging.getLogger(__name__)
5152

@@ -125,6 +126,39 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
125126
validate_news_file(absolute_file_path)
126127

127128

129+
def add_news_files(git: GitWrapper, news_dir: str) -&gt; None:
130+
&#34;&#34;&#34;Adds a news file if the branch corresponds to an dependency update.
131+
132+
Args:
133+
git: Instance of GitWrapper.
134+
news_dir: Relative path to news directory.
135+
&#34;&#34;&#34;
136+
current_branch = str(git.get_current_branch())
137+
is_dependency_update, groups = git.is_current_branch_of_type(
138+
str(configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_BRANCH_PATTERN))
139+
)
140+
if not is_dependency_update:
141+
raise EnvironmentError(f&#34;Branch {current_branch} must contain a news file.&#34;)
142+
if not configuration.get_value(ConfigurationVariable.AUTOGENERATE_NEWS_FILE_ON_DEPENDENCY_UPDATE):
143+
raise EnvironmentError(f&#34;Branch {current_branch} must contain a news file.&#34;)
144+
145+
create_news_file(
146+
news_dir,
147+
str(configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_MESSAGE)).format(
148+
message=&#34;, &#34;.join(groups)
149+
),
150+
configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_TYPE),
151+
)
152+
153+
154+
def _commit_news_file(git: GitWrapper, news_dir: str) -&gt; None:
155+
logger.info(&#34;Committing news file...&#34;)
156+
git.add(news_dir)
157+
git.commit(&#34;Adding news file&#34;)
158+
git.push()
159+
git.pull()
160+
161+
128162
def main() -&gt; None:
129163
&#34;&#34;&#34;Asserts the new PR comprises at least one news file and it adheres to the required standard.&#34;&#34;&#34;
130164
parser = argparse.ArgumentParser(description=&#34;Check correctly formatted news files exist on feature branch.&#34;)
@@ -147,7 +181,12 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
147181
validate_news_files(git=git, news_dir=news_dir, root_dir=root_dir)
148182
except Exception as e:
149183
log_exception(logger, e)
150-
sys.exit(1)
184+
try:
185+
add_news_files(git, absolute_news_dir)
186+
_commit_news_file(git, absolute_news_dir)
187+
except Exception as e2:
188+
log_exception(logger, e2)
189+
sys.exit(1)
151190

152191

153192
if __name__ == &#34;__main__&#34;:
@@ -161,6 +200,47 @@ <h1 class="title">Module <code>continuous_delivery_scripts.assert_news</code></h
161200
<section>
162201
<h2 class="section-title" id="header-functions">Functions</h2>
163202
<dl>
203+
<dt id="continuous_delivery_scripts.assert_news.add_news_files"><code class="name flex">
204+
<span>def <span class="ident">add_news_files</span></span>(<span>git: <a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper" href="utils/git_helpers.html#continuous_delivery_scripts.utils.git_helpers.GitWrapper">GitWrapper</a>, news_dir: str) ‑> NoneType</span>
205+
</code></dt>
206+
<dd>
207+
<div class="desc"><p>Adds a news file if the branch corresponds to an dependency update.</p>
208+
<h2 id="args">Args</h2>
209+
<dl>
210+
<dt><strong><code>git</code></strong></dt>
211+
<dd>Instance of GitWrapper.</dd>
212+
<dt><strong><code>news_dir</code></strong></dt>
213+
<dd>Relative path to news directory.</dd>
214+
</dl></div>
215+
<details class="source">
216+
<summary>
217+
<span>Expand source code</span>
218+
</summary>
219+
<pre><code class="python">def add_news_files(git: GitWrapper, news_dir: str) -&gt; None:
220+
&#34;&#34;&#34;Adds a news file if the branch corresponds to an dependency update.
221+
222+
Args:
223+
git: Instance of GitWrapper.
224+
news_dir: Relative path to news directory.
225+
&#34;&#34;&#34;
226+
current_branch = str(git.get_current_branch())
227+
is_dependency_update, groups = git.is_current_branch_of_type(
228+
str(configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_BRANCH_PATTERN))
229+
)
230+
if not is_dependency_update:
231+
raise EnvironmentError(f&#34;Branch {current_branch} must contain a news file.&#34;)
232+
if not configuration.get_value(ConfigurationVariable.AUTOGENERATE_NEWS_FILE_ON_DEPENDENCY_UPDATE):
233+
raise EnvironmentError(f&#34;Branch {current_branch} must contain a news file.&#34;)
234+
235+
create_news_file(
236+
news_dir,
237+
str(configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_MESSAGE)).format(
238+
message=&#34;, &#34;.join(groups)
239+
),
240+
configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_TYPE),
241+
)</code></pre>
242+
</details>
243+
</dd>
164244
<dt id="continuous_delivery_scripts.assert_news.find_news_files"><code class="name flex">
165245
<span>def <span class="ident">find_news_files</span></span>(<span>git: <a title="continuous_delivery_scripts.utils.git_helpers.GitWrapper" href="utils/git_helpers.html#continuous_delivery_scripts.utils.git_helpers.GitWrapper">GitWrapper</a>, root_dir: str, news_dir: str) ‑> List[str]</span>
166246
</code></dt>
@@ -233,7 +313,12 @@ <h2 id="returns">Returns</h2>
233313
validate_news_files(git=git, news_dir=news_dir, root_dir=root_dir)
234314
except Exception as e:
235315
log_exception(logger, e)
236-
sys.exit(1)</code></pre>
316+
try:
317+
add_news_files(git, absolute_news_dir)
318+
_commit_news_file(git, absolute_news_dir)
319+
except Exception as e2:
320+
log_exception(logger, e2)
321+
sys.exit(1)</code></pre>
237322
</details>
238323
</dd>
239324
<dt id="continuous_delivery_scripts.assert_news.validate_news_file"><code class="name flex">
@@ -410,6 +495,7 @@ <h1>Index</h1>
410495
</li>
411496
<li><h3><a href="#header-functions">Functions</a></h3>
412497
<ul class="">
498+
<li><code><a title="continuous_delivery_scripts.assert_news.add_news_files" href="#continuous_delivery_scripts.assert_news.add_news_files">add_news_files</a></code></li>
413499
<li><code><a title="continuous_delivery_scripts.assert_news.find_news_files" href="#continuous_delivery_scripts.assert_news.find_news_files">find_news_files</a></code></li>
414500
<li><code><a title="continuous_delivery_scripts.assert_news.main" href="#continuous_delivery_scripts.assert_news.main">main</a></code></li>
415501
<li><code><a title="continuous_delivery_scripts.assert_news.validate_news_file" href="#continuous_delivery_scripts.assert_news.validate_news_file">validate_news_file</a></code></li>
@@ -432,7 +518,7 @@ <h4><code><a title="continuous_delivery_scripts.assert_news.NewsFileValidator" h
432518
</nav>
433519
</main>
434520
<footer id="footer">
435-
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
521+
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.1</a>.</p>
436522
</footer>
437523
</body>
438524
</html>

0 commit comments

Comments
 (0)