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

Add Argument to Specify YAML File Path #813

Merged
merged 6 commits into from
Dec 2, 2024

Conversation

rudra-iitm
Copy link
Contributor

This update introduces a new argument to allow users to specify the file path to the YAML file (snapcraft.yaml or rockcraft.yaml). It ensures the workflow operates seamlessly even when the YAML file is located in a non-conventional directory.

Key Change

  • Added a --yaml-path argument to accept the path to the YAML file.

Usage
Users can now pass the file path using the --yaml-path flag: --yaml-path: 'path/to/yaml/file'

Benefits

  • Enables workflows to handle diverse project structures.
  • Improves usability for projects with custom file layouts.

@rudra-iitm
Copy link
Contributor Author

@sergio-costas , please review this PR. The unittests are passing successfully; however, the style check is failing for a file that I did not modify. The error states "too-many-positional-arguments", even though Pylint is explicitly disabled for that line. I’m unable to determine the cause of this failure.

@sergio-costas
Copy link
Collaborator

@rudra-iitm I'll check it.

@sergio-costas
Copy link
Collaborator

Mmm... odd... in local it does work...

Maybe updating the ubuntu version to ubuntu-noble (ubuntu-latest isn't "the latest one", but... 18.04 I think) and python version to 3.12 in the .github/workflows/updatesnaptests.yml file...

@sergio-costas
Copy link
Collaborator

(I don't want to send a patch for that because every time that I tried to send a commit to a PR that wasn't mine, I broke the git history. So I prefer to stay in the safe side 😅 )

@rudra-iitm
Copy link
Contributor Author

Mmm... odd... in local it does work...

Maybe updating the ubuntu version to ubuntu-noble (ubuntu-latest isn't "the latest one", but... 18.04 I think) and python version to 3.12 in the .github/workflows/updatesnaptests.yml file...

I am working on a Mac and using Python 3.12. The style check is still failing locally for me.

@rudra-iitm
Copy link
Contributor Author

(I don't want to send a patch for that because every time that I tried to send a commit to a PR that wasn't mine, I broke the git history. So I prefer to stay in the safe side 😅 )

😅 Better safe than sorry

@sergio-costas
Copy link
Collaborator

Mmm... which version of pylint and flake8 do you have? Mine are:

raster ~/workspace/desktop-snaps/updatesnap (stable)$ pylint --version
pylint 3.2.7
astroid 3.2.2
Python 3.12.7 (main, Nov  6 2024, 18:29:01) [GCC 14.2.0]
raster ~/workspace/desktop-snaps/updatesnap (stable)$ flake8 --version
7.1.1 (mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0) CPython 3.12.7 on Linux

@sergio-costas
Copy link
Collaborator

I found how to fix it. Please, remove your changes in the workflows and rebase against stable. It was a problem with the pylint version.

@sergio-costas
Copy link
Collaborator

@rudra-iitm I cancelled the test because I was wrong: it's not "ubuntu-noble" but "ubuntu-24.04". Anyway, in the main branch is everything fixed, so just removing that last commit and rebasing should be enough.

@rudra-iitm
Copy link
Contributor Author

@rudra-iitm I cancelled the test because I was wrong: it's not "ubuntu-noble" but "ubuntu-24.04". Anyway, in the main branch is everything fixed, so just removing that last commit and rebasing should be enough.

Done rebasing

@sergio-costas
Copy link
Collaborator

And checks have passed :-)

@rudra-iitm
Copy link
Contributor Author

And checks have passed :-)

Could you please review the changes and merge the PR?

Copy link
Collaborator

@sergio-costas sergio-costas left a comment

Choose a reason for hiding this comment

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

Some details.

updatesnap/updatesnapyaml.py Outdated Show resolved Hide resolved
updatesnap/updatesnapyaml.py Show resolved Hide resolved
@sergio-costas
Copy link
Collaborator

Yes, sorry... I reviewed it yesterday, but forgot to press the button to commit it.

Copy link
Collaborator

@sergio-costas sergio-costas left a comment

Choose a reason for hiding this comment

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

Some nitpicks.

@@ -76,6 +83,8 @@ def main():
help='Version schema of snapping repository')
parser.add_argument('--rock-version-schema', action='store', default='None',
help='Version schema of rock repository')
parser.add_argument('--yaml-path', action='store', default='None',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that it would be better to use None instead of the string "None". Like in github-user and github-token.

Also, I see that version-schema and rock-version-schema also use a string instead of the None native type... I think that it should be fixed in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will do it in new PR for version-schema and rock-version-schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there is an issue when using None instead of 'None', as action.yml sends 'None' when an argument is not passed. We can't pass None as the default value in action.yml because it breaks.

Copy link
Collaborator

@sergio-costas sergio-costas Dec 2, 2024

Choose a reason for hiding this comment

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

Maybe you should try a different way in the action.yml file. You can test if an environment variable is defined or not directly in the line, and add a piece of text if it is defined. For example:

${VERSION_SCHEMA:+--version-schema $VERSION_SCHEMA}

the :+ part means "if the previous variable is defined, add what is after me". Thus, if VERSION_SCHEMA isn't defined, that will translate to no text, while if it is defined, it will translate to --version-schema $VERSION_SCHEMA

updatesnap/updatesnapyaml.py Outdated Show resolved Hide resolved
- Add logic to move the YAML file to the specified path in `action.yml`
@rudra-iitm
Copy link
Contributor Author

@sergio-costas I often forget to update action.yml because everything works fine during local testing without it. Is there a way to test the workflow directly (instead of locally) to ensure I don’t miss updating action.yml?

@sergio-costas
Copy link
Collaborator

About testing the action.yml... there seems to be "gh", the github-cli program. I think that it allows to do that.

@rudra-iitm
Copy link
Contributor Author

Refactored action.yml to handle undefined yaml-path arg as well. Please review the changes once again.

Copy link
Collaborator

@sergio-costas sergio-costas left a comment

Choose a reason for hiding this comment

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

After the changes, it looks good.

@sergio-costas
Copy link
Collaborator

@rudra-iitm Do you have merge permissions...?

@rudra-iitm
Copy link
Contributor Author

rudra-iitm commented Dec 2, 2024

@rudra-iitm Do you have merge permissions...?

No, I don't have such permissions.

@sergio-costas
Copy link
Collaborator

I'll merge it, then. And thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants