Skip to content
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

Adjust hassfest.manifest based on config.action #100577

Merged
merged 2 commits into from Sep 19, 2023

Conversation

raman325
Copy link
Contributor

@raman325 raman325 commented Sep 19, 2023

Proposed change

Currently, when calling hassfest.manifest.validate, once we retrieve all the integration manifests that were not sorted, hassfest will try to run prettier on the corresponding integrations, regardless of whether the mode config.action is generate or validate. Currently, when running hassfest as a GitHub action, which runs the tool in validate mode, improperly sorted manifests leads to the error below because the action's container doesn't have prettier installed.

In discussion with @ludeeus , we should instead have branching logic based on the config.action so that we only take the steps that are needed. In the case of validate, which is what the GitHub action uses, there is no reason to run prettier because we aren't actually generating new files. While this was done to fix the GH action, this is a general improvement to the tool anyway

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/script/hassfest/__main__.py", line 244, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/src/homeassistant/script/hassfest/__main__.py", line 166, in main
    plugin.validate(integrations, config)
  File "/usr/src/homeassistant/script/hassfest/manifest.py", line 393, in validate
    subprocess.run(
  File "/usr/local/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pre-commit', 'run', '--hook-stage', 'manual', 'prettier', '--files', PosixPath('/github/workspace/custom_components/my_integration/manifest.json')]' returned non-zero exit status 1.
Validating manifest...

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant home-assistant bot added bugfix cla-signed small-pr PRs with less than 30 lines. labels Sep 19, 2023
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks, @raman325 👍

../Frenck

@frenck frenck merged commit 2ad0fd1 into home-assistant:dev Sep 19, 2023
29 of 30 checks passed
@raman325 raman325 deleted the hassfest branch September 19, 2023 16:54
@raman325 raman325 added this to the 2023.9.3 milestone Sep 19, 2023
@raman325
Copy link
Contributor Author

added to milestone so this could be released as soon as possible so that the hassfest action starts working as expected

@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with manifest key sort validation?
3 participants