Skip to content

New RN summary #7133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 58 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8acff2c
in progress
dantavori May 19, 2020
e91faf5
Merge branch 'master' into rn_summary
dantavori May 20, 2020
971b4d8
in progress
dantavori May 20, 2020
374b48c
in progress
dantavori May 20, 2020
2812214
in progress
dantavori May 20, 2020
a5db938
in progress
dantavori May 20, 2020
ce254e1
in progress
dantavori May 20, 2020
c3c8d8f
in progress
dantavori May 20, 2020
f5855ce
in progress
dantavori May 21, 2020
bac2515
changed RN file name
dantavori May 21, 2020
b3cb570
Merge branch 'master' into rn_summary
dantavori May 21, 2020
8aa9a83
added comments
dantavori May 21, 2020
f6bbb88
test in progress
dantavori May 24, 2020
0dfdd4f
updated script
dantavori May 24, 2020
e6f8ee9
Merge branch 'master' into rn_summary
dantavori May 24, 2020
c3ffcd3
updated script
dantavori May 24, 2020
27bcfa8
updated script
dantavori May 24, 2020
184d56e
test fix helloworld
dantavori May 25, 2020
88daff8
in progress
dantavori May 25, 2020
260c2ce
in progress
dantavori May 26, 2020
ccf739b
in progress
dantavori May 27, 2020
039808b
in progress
dantavori May 27, 2020
8bb9364
in progress
dantavori May 27, 2020
cf06496
in progress
dantavori Jun 1, 2020
1dffa82
in progress
dantavori Jun 1, 2020
349ff61
added test
dantavori Jun 3, 2020
7f78396
fix
dantavori Jun 3, 2020
a9f7a5e
fixed doc
dantavori Jun 3, 2020
f1d4d23
Merge remote-tracking branch 'origin/master' into rn_summary
yaakovi Jun 3, 2020
401a7b8
in progress
dantavori Jun 3, 2020
bbb5b39
updated new release notes generator
yaakovi Jun 3, 2020
02988db
Merge remote-tracking branch 'origin/rn_summary' into rn_summary
dantavori Jun 3, 2020
07ff092
in progress
dantavori Jun 3, 2020
51b7372
in progress
dantavori Jun 3, 2020
0c3f6ef
in progress
dantavori Jun 3, 2020
e12295a
in progress
dantavori Jun 3, 2020
b2111e0
fixed ignored release notes validations and added tests
dantavori Jun 3, 2020
a4dd9f4
small fixes
dantavori Jun 3, 2020
2fe8162
restored .gitignore
yaakovi Jun 5, 2020
cc71264
added new packs to release notes generator
yaakovi Jun 7, 2020
0059abb
Merge remote-tracking branch 'origin/master' into rn_summary
yaakovi Jun 7, 2020
677aac1
fixed unit tests
yaakovi Jun 15, 2020
9fcaf6e
Merge remote-tracking branch 'origin/master' into rn_summary
yaakovi Jun 15, 2020
59dd32a
fixed lint error
yaakovi Jun 15, 2020
5990ad9
fixed lint error
yaakovi Jun 16, 2020
9a85264
fixed modified packs collection
yaakovi Jun 16, 2020
43d791a
Fixed handling of ignored section in RN files
yaakovi Jun 16, 2020
593f0c7
fixed modified release notes filter
yaakovi Jun 16, 2020
e369089
Merge remote-tracking branch 'origin/master' into rn_summary
yaakovi Jun 18, 2020
d56d217
start merging pack versions block to single block
yaakovi Jun 18, 2020
c4f6335
added support for merging pack versions block to single block
yaakovi Jun 21, 2020
9e8dcf3
added unit test for merge release notes block function
yaakovi Jun 21, 2020
81a09e7
Merge remote-tracking branch 'origin/master' into rn_summary
yaakovi Jun 21, 2020
11c7b23
fixed small formatting issue
yaakovi Jun 22, 2020
73e8bca
fixed CR notes
yaakovi Jun 22, 2020
30d20e3
fixed content-descriptor.json path
yaakovi Jun 22, 2020
0e8933c
Merge remote-tracking branch 'origin/master' into rn_summary
yaakovi Jun 22, 2020
d9e3b97
fixed time formats in content-descriptor.json
yaakovi Jun 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,14 @@ jobs:
fi
if [ -n "${GITHUB_TOKEN}" ] ;
then
python3 release_notes.py $CONTENT_VERSION $GIT_SHA1 $CIRCLE_BUILD_NUM $SERVER_VERSION --github-token $GITHUB_TOKEN || echo "ignore errors"
# python3 release_notes.py $CONTENT_VERSION $GIT_SHA1 $CIRCLE_BUILD_NUM $SERVER_VERSION --github-token $GITHUB_TOKEN || echo "ignore errors"
# new release notes summary generator in packs format
python3 Utils/release_notes_generator.py $CONTENT_VERSION $GIT_SHA1 $CIRCLE_BUILD_NUM --output $CIRCLE_ARTIFACTS/packs-release-notes.md --github-token $GITHUB_TOKEN

else
python3 release_notes.py $CONTENT_VERSION $GIT_SHA1 $CIRCLE_BUILD_NUM $SERVER_VERSION || echo "ignore errors"
# python3 release_notes.py $CONTENT_VERSION $GIT_SHA1 $CIRCLE_BUILD_NUM $SERVER_VERSION || echo "ignore errors"
# new release notes summary generator in packs format
python3 Utils/release_notes_generator.py $CONTENT_VERSION $GIT_SHA1 $CIRCLE_BUILD_NUM --output $CIRCLE_ARTIFACTS/packs-release-notes.md
fi
- run:
name: Common Server Documentation
Expand Down
267 changes: 267 additions & 0 deletions Tests/scripts/infrastructure_tests/release_notes_generator_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
import os
import re
from Utils.release_notes_generator import (get_release_notes_dict,
generate_release_notes_summary,
get_pack_entities,
read_and_format_release_note,
merge_version_blocks,
EMPTY_LINES_REGEX)

TEST_DATA_PATH = 'Tests/scripts/infrastructure_tests/tests_data/RN_tests_data'

VERSION = 'VERSION'
ASSET_ID = 'ASSET_ID'


class TestReadAndFormatReleaseNote:
def test_sanity(self):
"""
Given
- A release note file with 2 Integrations:
- FakePack1_Integration1
- FakePack1_Integration2

When
- Formatting a release notes file.

Then
- Ensure both integration appear in the formatted string
"""
rn_file = os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes', '1_1_0.md')
formatted_text = read_and_format_release_note(rn_file)
assert 'FakePack1_Integration1' in formatted_text
assert 'FakePack1_Integration2' in formatted_text

def test_ignored_release_notes_block(self):
"""
Given
- A release note file with an Integration and a Script:
- FakePack4_Script1
- FakePack4_Integration1 - should be ignored

When
- Formatting a release notes file.

Then
- Ensure only the script appears in the formatted string
"""
rn_file = os.path.join(TEST_DATA_PATH, 'FakePack4', 'ReleaseNotes', '1_1_0.md')
formatted_text = read_and_format_release_note(rn_file)
assert 'FakePack4_Script1' in formatted_text
assert 'FakePack4_Integration1' not in formatted_text

def test_ignored_entire_release_note(self):
"""
Given
- A release note file with an Integration and a Script:
- FakePack4_Script1
- FakePack4_Integration1

When
- Formatting a release notes file.

Then
- Ensure formatted string is empty.
"""
rn_file = os.path.join(TEST_DATA_PATH, 'FakePack4', 'ReleaseNotes', '1_0_1.md')
formatted_text = read_and_format_release_note(rn_file)
assert formatted_text == ''


class TestGenerateReleaseNotesSummary:
def setup(self):
self._version = VERSION
self._asset_id = ASSET_ID
self._outfile = 'temp.md'

def test_added_pack(self):
"""
Given
- A repository of two new packs:
- FakePack3 version 1.0.0
- FakePack4 version 1.0.0

When
- Generating a release notes summary file.

Then
- Ensure release notes generator creates a valid summary, by checking:
- the release notes summary contains two packs:
- FakePack3 with version 1.0.0
- FakePack4 with version 1.0.0
"""
new_packs_rn = {
'FakePack3': get_pack_entities(os.path.join(TEST_DATA_PATH, 'FakePack3')),
'FakePack4': get_pack_entities(os.path.join(TEST_DATA_PATH, 'FakePack4')),
}

rn_summary = generate_release_notes_summary(new_packs_rn, {}, self._version, self._asset_id, 'temp.md')

assert '## New: FakePack3 Pack v1.0.0' in rn_summary
assert '## New: FakePack4 Pack v1.0.0' in rn_summary

def test_two_packs(self):
"""
Given
- A repository of two packs updates and release notes:
- FakePack1 with versions 1.1.0 and 2.0.0
- FakePack2 version 1.1.0

When
- Generating a release notes summary file.

Then
- Ensure release notes generator creates a valid summary, by checking:
- the output of get_release_notes_dict() is a valid dict of (pack_name, dict(pack_version, release_note)).
- the release notes summary contains two packs with 3 updates:
- FakePack1 with versions 1.1.0 and 2.0.0
- FakePack2 with versions 1.1.0
"""
release_notes_files = [
os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes', '1_1_0.md'),
os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes', '2_0_0.md'),
os.path.join(TEST_DATA_PATH, 'FakePack2', 'ReleaseNotes', '1_1_0.md'),
]

rn_dict = get_release_notes_dict(release_notes_files)

assert '1.1.0' in rn_dict['FakePack1'].keys()
assert '2.0.0' in rn_dict['FakePack1'].keys()
assert '1.1.0' in rn_dict['FakePack2'].keys()

rn_summary = generate_release_notes_summary({}, rn_dict, self._version, self._asset_id, self._outfile)

assert VERSION in rn_summary and ASSET_ID in rn_summary # summary title
assert '### FakePack1 Pack v2.0.0' in rn_summary
assert '##### FakePack1_Integration1' in rn_summary
assert 'This is a fake1 minor release note.' in rn_summary
assert 'This is a fake1 major release note.' in rn_summary
assert '### FakePack2 Pack v1.1.0' in rn_summary
assert '##### FakePack2_Script1' in rn_summary
assert 'This is a fake2 major release note.' in rn_summary

def test_release_notes_summary_with_empty_lines_in_rn(self):
"""
Given
- A repository contains a FakePack3 update with ignored release notes.

When
- Generating a release notes summary file.

Then
- Ensure release notes generator creates a valid summary, by checking:
- the output of get_release_notes_dict() is a dict of (pack_name, dict(pack_version, release_note)).
- empty lines (with dashes) are removed from the release notes summary.
"""
release_notes_files = [
os.path.join(TEST_DATA_PATH, 'FakePack3', 'ReleaseNotes', '1_0_1.md')
]

rn_dict = get_release_notes_dict(release_notes_files)

assert '1.0.1' in rn_dict['FakePack3'].keys()
assert len(rn_dict) == 1

rn_summary = generate_release_notes_summary({}, rn_dict, self._version, self._asset_id, self._outfile)

print(rn_summary)

match = re.search(EMPTY_LINES_REGEX, rn_summary)
assert match is None

def test_release_notes_summary_with_ignored_rns(self):
"""
Given
- A repository of a packs update and release notes:
- FakePack4 with versions 1.0.1 and 1.1.0

When
- Generating a release notes summary file.

Then
- Ensure release notes generator creates a valid summary, by checking:
- the output of get_release_notes_dict() is a valid dict of (pack_name, dict(pack_version, release_note))
- the release notes summary contains one packs with 1 updates:
- FakePack4 version 1.1.0
- the summary does not contain release notes 1.0.1, because it is ignored.
"""
release_notes_files = [
os.path.join(TEST_DATA_PATH, 'FakePack4', 'ReleaseNotes', '1_0_1.md'),
os.path.join(TEST_DATA_PATH, 'FakePack4', 'ReleaseNotes', '1_1_0.md'),
]

rn_dict = get_release_notes_dict(release_notes_files)

assert '1.1.0' in rn_dict['FakePack4'].keys()
assert len(rn_dict) == 1

rn_summary = generate_release_notes_summary({}, rn_dict, self._version, self._asset_id, self._outfile)

assert '### FakePack4 Pack v1.1.0' in rn_summary
assert '##### FakePack4_Script1' in rn_summary


class TestMergeVersionBlocks:
def test_sanity(self):
"""
Given
two changes in foreign content types

When
two pack versions that modified different items.

Then
type sections appears one after the other
"""
release_notes_paths = [
os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes', '1_1_0.md'),
os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes', '2_1_0.md'),
]

pack_versions_dict = {}
for path in release_notes_paths:
with open(path) as file_:
pack_versions_dict[os.path.basename(os.path.splitext(path)[0])] = file_.read()

rn_block = merge_version_blocks('FakePack', pack_versions_dict)

assert 'FakePack1_Playbook1' in rn_block
assert 'FakePack1_Playbook2' in rn_block
assert 'FakePack1_Integration1' in rn_block
assert 'FakePack1_Integration2' in rn_block
assert 'v2_1_0' in rn_block
assert 'v1_1_0' not in rn_block

def test_similiar_entities(self):
"""
Given
two changes in similar content entities

When
two pack versions that modified the same items.

Then
one integration section appears
one entity title for each one with two comments
"""
release_notes_paths = [
os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes', '1_1_0.md'),
os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes', '2_0_0.md'),
]

pack_versions_dict = {}
for path in release_notes_paths:
with open(path) as file_:
pack_versions_dict[os.path.basename(os.path.splitext(path)[0])] = file_.read()

rn_block = merge_version_blocks('FakePack', pack_versions_dict)

assert rn_block.count('Integrations') == 1
assert rn_block.count('FakePack1_Integration1') == 1
assert rn_block.count('FakePack1_Integration2') == 1
assert 'v2_0_0' in rn_block
assert 'v1_1_0' not in rn_block
assert 'fake1 minor' in rn_block
assert 'fake2 minor' in rn_block
assert 'fake1 major' in rn_block
assert 'fake2 major' in rn_block
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations
##### __FakePack1_Integration1__
- This is a fake1 minor release note.
##### __FakePack1_Integration2__
- This is a fake2 minor release note.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations
##### __FakePack1_Integration1__
- This is a fake1 major release note.
##### __FakePack1_Integration2__
- This is a fake2 major release note.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Playbooks
##### __FakePack1_Playbook1__
- This is a fake major release note.
##### __FakePack1_Playbook2__
- This is a fake major release note.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "FakePack1",
"currentVersion": "2.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

#### Scripts
##### __FakePack2_Script1__
- This is a fake minor release note.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "FakePack2",
"currentVersion": "1.1.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#### Scripts
##### __FakePack3_Script1__
- This is a fake minor release note.
-

##### __FakePack3_Script2__
- Another release note.
-

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "FakePack3",
"currentVersion": "1.0.1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--
#### Scripts
- __FakePack4_Script1__
This is a fake minor release note.


#### Integrations
- __FakePack4_Integration1__
-
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#### Scripts
##### __FakePack4_Script1__
- This is a fake minor release note.

<!--
#### Integrations
- __FakePack4_Integration1__
- ignored
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "FakePack4",
"currentVersion": "1.0.1"
}
Loading