browniebroke / pypackage-template

A project template for Python package with heavy use of Github actions
MIT License
53 stars 13 forks source link

"Release" step not evaluated #631

Closed chemelli74 closed 5 months ago

chemelli74 commented 6 months ago

Describe the bug

Step "release" is not evaluated. I would expect not to be run if evaluated as false, but I miss the full step in the below log.

Debug log is not helpful either.

To Reproduce

Additional context Log: https://github.com/chemelli74/fitbit-web-api/actions/runs/7193699069/job/19592762516

browniebroke commented 6 months ago

Yes, I have this in a few of my projects and it drives me crazy. The step is evaluated, but the logs aren't showing. As far as I can tell, it seems to be a bug in how the workflow logs are rendered in GitHub. It might happen because I have the "Test release" step above and GitHub gets mixed up, but swapping the steps doesn't seem to help...

Anyway, to solve your issue, you can see the full logs by clicking on the cog icon > "View raw logs" in the context menu that opens:

image

It goes to this page, where you can se the actual error:

...
2023-12-13T10:15:24.2072317Z Creating virtualenv fitbit-web-api in /github/workspace/.venv
2023-12-13T10:15:24.4805977Z Building fitbit-web-api (0.1.0)
2023-12-13T10:15:24.6451683Z [10:15:24] INFO     [semantic_release.version.algorithm] INFO    algorithm.py:60
2023-12-13T10:15:24.6452515Z                     algorithm.tags_and_versions: found 1                        
2023-12-13T10:15:24.6453147Z                     previous tags                                               
2023-12-13T10:15:24.6571595Z            INFO     [semantic_release.changelog.template] INFO    template.py:98
2023-12-13T10:15:24.6572802Z                     template.recursive_render: Rendering                        
2023-12-13T10:15:24.6573575Z                     templates from /github/workspace/templates to               
2023-12-13T10:15:24.6574391Z                     /github/workspace                                           
2023-12-13T10:15:24.6636392Z Traceback (most recent call last):
2023-12-13T10:15:24.6638061Z   File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
2023-12-13T10:15:24.6639861Z     return _run_code(code, main_globals, None,
2023-12-13T10:15:24.6641907Z   File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
2023-12-13T10:15:24.6643013Z     exec(code, run_globals)
2023-12-13T10:15:24.6644642Z   File "/semantic-release/semantic_release/__main__.py", line 6, in <module>
2023-12-13T10:15:24.6645767Z     main(args=sys.argv[1:])
2023-12-13T10:15:24.6646970Z   File "/semantic-release/.venv/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
2023-12-13T10:15:24.6648292Z     return self.main(*args, **kwargs)
2023-12-13T10:15:24.6649554Z   File "/semantic-release/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main
2023-12-13T10:15:24.6650759Z     rv = self.invoke(ctx)
2023-12-13T10:15:24.6652143Z   File "/semantic-release/.venv/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
2023-12-13T10:15:24.6653471Z     return _process_result(sub_ctx.command.invoke(sub_ctx))
2023-12-13T10:15:24.6654773Z   File "/semantic-release/.venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
2023-12-13T10:15:24.6656152Z     return ctx.invoke(self.callback, **ctx.params)
2023-12-13T10:15:24.6657521Z   File "/semantic-release/.venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke
2023-12-13T10:15:24.6658852Z     return __callback(*args, **kwargs)
2023-12-13T10:15:24.6660202Z   File "/semantic-release/.venv/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
2023-12-13T10:15:24.6661623Z     return f(get_current_context(), *args, **kwargs)
2023-12-13T10:15:24.6663126Z   File "/semantic-release/semantic_release/cli/commands/version.py", line 417, in version
2023-12-13T10:15:24.6664217Z     updated_paths = recursive_render(
2023-12-13T10:15:24.6665563Z   File "/semantic-release/semantic_release/changelog/template.py", line 112, in recursive_render
2023-12-13T10:15:24.6667193Z     stream.dump(output_file, encoding="utf-8")
2023-12-13T10:15:24.6668693Z   File "/semantic-release/.venv/lib/python3.10/site-packages/jinja2/environment.py", line 1618, in dump
2023-12-13T10:15:24.6669997Z     fp.writelines(iterable)
2023-12-13T10:15:24.6671594Z   File "/semantic-release/.venv/lib/python3.10/site-packages/jinja2/environment.py", line 1613, in <genexpr>
2023-12-13T10:15:24.6673120Z     iterable = (x.encode(encoding, errors) for x in self)  # type: ignore
2023-12-13T10:15:24.6674720Z   File "/semantic-release/.venv/lib/python3.10/site-packages/jinja2/environment.py", line 1662, in __next__
2023-12-13T10:15:24.6676120Z     return self._next()  # type: ignore
2023-12-13T10:15:24.6677525Z   File "/semantic-release/.venv/lib/python3.10/site-packages/jinja2/environment.py", line 1354, in generate
2023-12-13T10:15:24.6678750Z     yield self.environment.handle_exception()
2023-12-13T10:15:24.6680167Z   File "/semantic-release/.venv/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
2023-12-13T10:15:24.6681026Z     raise rewrite_traceback_stack(source=source)
2023-12-13T10:15:24.6681697Z   File "templates/CHANGELOG.md.j2", line 12, in top-level template code
2023-12-13T10:15:24.6682690Z     - {{ commit.descriptions[0] | capitalize }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
2023-12-13T10:15:24.6683746Z   File "/semantic-release/.venv/lib/python3.10/site-packages/jinja2/sandbox.py", line 303, in getitem
2023-12-13T10:15:24.6684429Z     return obj[argument]
2023-12-13T10:15:24.6685498Z jinja2.exceptions.UndefinedError: 'semantic_release.commit_parser.token.ParseError object' has no attribute 'descriptions'
2023-12-13T10:15:25.0736865Z Post job cleanup.
...

Your error in this case, is coming from the changelog template. Looks like it expects a ParsedCommit, but instead we got a ParseError, which doesn't have a descriptions attribute.

chemelli74 commented 6 months ago

Thx for quick feedback. Any idea on how to fix the issue ? I'm a bit lot honestly.

chemelli74 commented 6 months ago

I added more verbosity to the job and found out:

2023-12-18T21:28:15.8561900Z            DEBUG    [semantic_release.commit_parser.angular] DEBUG angular.py:25
2023-12-18T21:28:15.8563089Z                     angular._logged_parse_error: Unable to parse                
2023-12-18T21:28:15.8564200Z                     commit message: Merge pull request #11 from                 
2023-12-18T21:28:15.8565514Z                     chemelli74/dependabot/github_actions/python-se              
2023-12-18T21:28:15.8566464Z                     mantic-release/python-semantic-release-8.5.0

and others similar

browniebroke commented 6 months ago

Ok. You could tweak the changelog template to ignore these perhaps?

chemelli74 commented 6 months ago

Ok. You could tweak the changelog template to ignore these perhaps?

unfortunately, I don't know the syntax of the template. Do you mind suggesting the code change ?

But I think it's a bug, the full log shows:

2023-12-18T21:28:07.5002045Z            DEBUG    [semantic_release.commit_parser.angular] DEBUG angular.py:25
2023-12-18T21:28:07.5003155Z                     angular._logged_parse_error: Unable to parse                
2023-12-18T21:28:07.5004008Z                     commit message: Merge pull request #13 from                 
2023-12-18T21:28:07.5004754Z                     chemelli74/chemelli74-ci-verbose                            
2023-12-18T21:28:07.5005273Z                                                                                 
2023-12-18T21:28:07.5005930Z                     build: make release verbose 

and it should be fine as there is the expected syntax in the last part of the commit squashed message.

Side note, https://github.com/chemelli74/aiovodafone is based on a older version of your source repo and works fine.

browniebroke commented 6 months ago

It uses python semantic release v7 https://github.com/chemelli74/aiovodafone/blob/main/.github%2Fworkflows%2Fci.yml#L83 while the latest version is v8. The template syntax is jinja2, I think.

chemelli74 commented 6 months ago

Hi @browniebroke, here the reply in the bug report I openend for semantic-release: https://github.com/python-semantic-release/python-semantic-release/issues/776#issuecomment-1861958976

Should be enough to exclude "unknown" commit type

chemelli74 commented 6 months ago

Any chance you can review the changelog template ? ;-)

browniebroke commented 6 months ago

Unfortunately, I don't have time in the coming days, but would be nice to do, yes.

Good news is that it's all open source, so you can fix it yourself! Here are the Jinja2 docs: https://jinja.palletsprojects.com/en/3.1.x/templates/

I would first try to tweak the template on your generated project, rather than trying to fix it directly in this repo. My guess is that you need to wrap the problematic line in an if condition of some sorts.

chemelli74 commented 6 months ago

Release now working 🥳

Two changes are needed:

Thx for pointing me to the right direction. Hopefully this was helpful also for you in order to update your repo and make copier work out of the box.

Side note: there are other small changes I implemented, not related to this issue. Maybe you are interested in those as well

browniebroke commented 6 months ago

Cool! The first one makes sense. The second one shouldn't be needed as we're publishing with a trusted publisher

chemelli74 commented 6 months ago

The second one shouldn't be needed as we're publishing with a trusted publisher

Seems it's a beta feature opt-in. So I preferred to change the ci and use for now the good old way.