Nowadays our test automation, testing tools, and various frameworks actually rely on many well-known open source frameworks. For example, Pytest, Junit, Selenium, Appium, JMeter and so on are all open source frameworks that are very widely used. And precisely because of their broad user base and thriving communities, these open source projects themselves are updated and iterated extremely frequently, introducing some new features from time to time, while also adjusting or deprecating original features in historical versions.
While these frequent updates drive the continuous development of open source projects, they also bring some troubles to our use of these projects: we never know when a feature we originally used may have changed in a new version, which brings quite a few challenges for us to apply new versions in a timely manner.
To address this problem, the usual approach is in fact to check the project’s release notes, to understand the main changes of each version release, and also to understand the development trend of the related project itself.
Since test work involves quite a number of mainstream open source projects, the idea here arose of automatically collecting the release notes of various mainstream versions and aggregating them in one place.
Below is the rendering effect I put on my personal blog after using the GitHub API to automatically collect the version update records of some mainstream testing-related open source projects and turning them into web pages, which brings some convenience for us to grasp the change trends of various mainstream open source frameworks in one stop.
The core method is actually the following piece of code, which uses a predefined project list to obtain the historical release notes of the corresponding projects. Shared below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
| def update_release_list(self):
"""
Get the project release list and update it to keep the list file up to date
:return:
""" for project in self.projects:
name = project["name"]
url = self.baseUrl + f'/repos/{project["repo"]}/releases'
res = requests.get(url, headers=self.headers)
# Get the total number of pages for the project
pages = APIs.github_page_count(res)
total = pages['last'] if 'last' in pages else 1
# Saved release list, used as the baseline for the current list
if not os.path.exists(os.path.join(self.release_dir, f'{name}.json')):
old_list = []
else:
with open(os.path.join(self.release_dir, f'{name}.json'), "r", encoding='utf-8') as file:
old_list = json.load(file)
release_list = old_list
# Remove the status field from the original list for comparison
old_list = [{k: v for k, v in d.items() if k != 'status'} for d in old_list]
# The first page has been fetched; generate the list, default status False (detail not fetched yet)
if res.headers['content-type'].find('json') > 0 and isinstance(res.json(), list):
for release in res.json():
record = {'id': release['id'],
'name': release['name'],
'date': release['created_at']}
if record not in old_list:
record['status'] = False
release_list.append(record)
print(f'got release {release['id']}-{release['name']}, 1-{total}')
else:
print(f'release {release['id']}-{release['name']} exist!')
# Get the lists from subsequent pages
if 'last' in pages and 'next' in pages:
for i in range(pages['next'], total + 1):
page_url = url + f'?page={i}'
res = requests.get(page_url, headers=self.headers)
if res.headers['content-type'].find('json') > 0 and isinstance(res.json(), list):
for release in res.json():
record = {'id': release['id'],
'name': release['name'],
'date': release['created_at']}
if record not in old_list:
record['status'] = False
release_list.append(record)
print(f'got release {release['id']}-{release['name']}, {i}-{total}')
else:
print(f'release {release['id']}-{release['name']} exist!')
# Sort by id
release_list.sort(key=lambda x: x['id'], reverse=True)
# Update the list file
with open(os.path.join(self.release_dir, f'{name}.json'), "w", encoding='utf-8') as file:
file.write(json.dumps(release_list))
|
Then, combined with the id of a specific release to obtain the detail information, assembling md documents and directly using hugo to generate page files is all that is needed.