Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gen_release_notes.py 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. #!/usr/bin/env python3
  2. # Copyright © 2019 Intel Corporation
  3. # Permission is hereby granted, free of charge, to any person obtaining a copy
  4. # of this software and associated documentation files (the "Software"), to deal
  5. # in the Software without restriction, including without limitation the rights
  6. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. # copies of the Software, and to permit persons to whom the Software is
  8. # furnished to do so, subject to the following conditions:
  9. # The above copyright notice and this permission notice shall be included in
  10. # all copies or substantial portions of the Software.
  11. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. # SOFTWARE.
  18. """Generates release notes for a given version of mesa."""
  19. import asyncio
  20. import datetime
  21. import os
  22. import pathlib
  23. import textwrap
  24. import typing
  25. import urllib.parse
  26. import aiohttp
  27. from mako.template import Template
  28. from mako import exceptions
  29. CURRENT_GL_VERSION = '4.6'
  30. CURRENT_VK_VERSION = '1.1'
  31. TEMPLATE = Template(textwrap.dedent("""\
  32. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  33. <html lang="en">
  34. <head>
  35. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  36. <title>Mesa Release Notes</title>
  37. <link rel="stylesheet" type="text/css" href="../mesa.css">
  38. </head>
  39. <body>
  40. <div class="header">
  41. <h1>The Mesa 3D Graphics Library</h1>
  42. </div>
  43. <iframe src="../contents.html"></iframe>
  44. <div class="content">
  45. <h1>Mesa ${next_version} Release Notes / ${today}</h1>
  46. <p>
  47. %if not bugfix:
  48. Mesa ${next_version} is a new development release. People who are concerned
  49. with stability and reliability should stick with a previous release or
  50. wait for Mesa ${version[:-1]}1.
  51. %else:
  52. Mesa ${next_version} is a bug fix release which fixes bugs found since the ${version} release.
  53. %endif
  54. </p>
  55. <p>
  56. Mesa ${next_version} implements the OpenGL ${gl_version} API, but the version reported by
  57. glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
  58. glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
  59. Some drivers don't support all the features required in OpenGL ${gl_version}. OpenGL
  60. ${gl_version} is <strong>only</strong> available if requested at context creation.
  61. Compatibility contexts may report a lower version depending on each driver.
  62. </p>
  63. <p>
  64. Mesa ${next_version} implements the Vulkan ${vk_version} API, but the version reported by
  65. the apiVersion property of the VkPhysicalDeviceProperties struct
  66. depends on the particular driver being used.
  67. </p>
  68. <h2>SHA256 checksum</h2>
  69. <pre>
  70. TBD.
  71. </pre>
  72. <h2>New features</h2>
  73. <ul>
  74. %for f in features:
  75. <li>${f}</li>
  76. %endfor
  77. </ul>
  78. <h2>Bug fixes</h2>
  79. <ul>
  80. %for b in bugs:
  81. <li>${b}</li>
  82. %endfor
  83. </ul>
  84. <h2>Changes</h2>
  85. <ul>
  86. %for c, author in changes:
  87. %if author:
  88. <p>${c}</p>
  89. %else:
  90. <li>${c}</li>
  91. %endif
  92. %endfor
  93. </ul>
  94. </div>
  95. </body>
  96. </html>
  97. """))
  98. async def gather_commits(version: str) -> str:
  99. p = await asyncio.create_subprocess_exec(
  100. 'git', 'log', f'mesa-{version}..', '--grep', r'Closes: \(https\|#\).*',
  101. stdout=asyncio.subprocess.PIPE)
  102. out, _ = await p.communicate()
  103. assert p.returncode == 0, f"git log didn't work: {version}"
  104. return out.decode().strip()
  105. async def gather_bugs(version: str) -> typing.List[str]:
  106. commits = await gather_commits(version)
  107. issues: typing.List[str] = []
  108. for commit in commits.split('\n'):
  109. sha, message = commit.split(maxsplit=1)
  110. p = await asyncio.create_subprocess_exec(
  111. 'git', 'log', '--max-count', '1', r'--format=%b', sha,
  112. stdout=asyncio.subprocess.PIPE)
  113. _out, _ = await p.communicate()
  114. out = _out.decode().split('\n')
  115. for line in reversed(out):
  116. if line.startswith('Closes:'):
  117. bug = line.lstrip('Closes:').strip()
  118. break
  119. else:
  120. raise Exception('No closes found?')
  121. if bug.startswith('h'):
  122. # This means we have a bug in the form "Closes: https://..."
  123. issues.append(os.path.basename(urllib.parse.urlparse(bug).path))
  124. else:
  125. issues.append(bug.lstrip('#'))
  126. loop = asyncio.get_event_loop()
  127. async with aiohttp.ClientSession(loop=loop) as session:
  128. results = await asyncio.gather(*[get_bug(session, i) for i in issues])
  129. typing.cast(typing.Tuple[str, ...], results)
  130. return list(results)
  131. async def get_bug(session: aiohttp.ClientSession, bug_id: str) -> str:
  132. """Query gitlab to get the name of the issue that was closed."""
  133. # Mesa's gitlab id is 176,
  134. url = 'https://gitlab.freedesktop.org/api/v4/projects/176/issues'
  135. params = {'iids[]': bug_id}
  136. async with session.get(url, params=params) as response:
  137. content = await response.json()
  138. return content[0]['title']
  139. async def get_shortlog(version: str) -> str:
  140. """Call git shortlog."""
  141. p = await asyncio.create_subprocess_exec('git', 'shortlog', f'mesa-{version}..',
  142. stdout=asyncio.subprocess.PIPE)
  143. out, _ = await p.communicate()
  144. assert p.returncode == 0, 'error getting shortlog'
  145. assert out is not None, 'just for mypy'
  146. return out.decode()
  147. def walk_shortlog(log: str) -> typing.Generator[typing.Tuple[str, bool], None, None]:
  148. for l in log.split('\n'):
  149. if l.startswith(' '): # this means we have a patch description
  150. yield l, False
  151. else:
  152. yield l, True
  153. def calculate_next_version(version: str, is_point: bool) -> str:
  154. """Calculate the version about to be released."""
  155. if '-' in version:
  156. version = version.split('-')[0]
  157. if is_point:
  158. base = version.split('.')
  159. base[2] = str(int(base[2]) + 1)
  160. return '.'.join(base)
  161. return version
  162. def calculate_previous_version(version: str, is_point: bool) -> str:
  163. """Calculate the previous version to compare to.
  164. In the case of -rc to final that verison is the previous .0 release,
  165. (19.3.0 in the case of 20.0.0, for example). for point releases that is
  166. the last point release. This value will be the same as the input value
  167. for a point release, but different for a major release.
  168. """
  169. if '-' in version:
  170. version = version.split('-')[0]
  171. if is_point:
  172. return version
  173. base = version.split('.')
  174. if base[1] == '0':
  175. base[0] = str(int(base[0]) - 1)
  176. base[1] = '3'
  177. else:
  178. base[1] = str(int(base[1]) - 1)
  179. return '.'.join(base)
  180. def get_features() -> typing.Generator[str, None, None]:
  181. p = pathlib.Path(__file__).parent.parent / 'docs' / 'relnotes' / 'new_features.txt'
  182. if p.exists():
  183. with p.open('rt') as f:
  184. for line in f:
  185. yield line
  186. else:
  187. yield "None"
  188. async def main() -> None:
  189. v = pathlib.Path(__file__).parent.parent / 'VERSION'
  190. with v.open('rt') as f:
  191. raw_version = f.read().strip()
  192. is_point_release = '-rc' not in raw_version
  193. assert '-devel' not in raw_version, 'Do not run this script on -devel'
  194. version = raw_version.split('-')[0]
  195. previous_version = calculate_previous_version(version, is_point_release)
  196. next_version = calculate_next_version(version, is_point_release)
  197. shortlog, bugs = await asyncio.gather(
  198. get_shortlog(previous_version),
  199. gather_bugs(previous_version),
  200. )
  201. final = pathlib.Path(__file__).parent.parent / 'docs' / 'relnotes' / f'{next_version}.html'
  202. with final.open('wt') as f:
  203. try:
  204. f.write(TEMPLATE.render(
  205. bugfix=is_point_release,
  206. bugs=bugs,
  207. changes=walk_shortlog(shortlog),
  208. features=get_features(),
  209. gl_version=CURRENT_GL_VERSION,
  210. next_version=next_version,
  211. today=datetime.date.today(),
  212. version=previous_version,
  213. vk_version=CURRENT_VK_VERSION,
  214. ))
  215. except:
  216. print(exceptions.text_error_template().render())
  217. if __name__ == "__main__":
  218. loop = asyncio.get_event_loop()
  219. loop.run_until_complete(main())