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

lint: lint snap files inside an instance #4115

Merged
merged 3 commits into from
Apr 27, 2023
Merged

Conversation

mr-cal
Copy link
Collaborator

@mr-cal mr-cal commented Apr 25, 2023

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run make lint?
  • Have you successfully run pytest tests/unit?

So far, snapcraft lint parses the command line, prepares an instance, and re-executes snapcraft inside the instance.

This PR adds the code that is executed inside the instance:

  1. Unsquash the snap
  2. Collect the metadata from snap.yaml and lint filters from snapcraft.yaml
  3. Install the snap
  4. Run the linter on /snap/<snap-name>/current
  5. Report the linter warnings

(CRAFT-1689)

@mr-cal mr-cal marked this pull request as draft April 25, 2023 23:36
@codecov-commenter
Copy link

codecov-commenter commented Apr 26, 2023

Codecov Report

Merging #4115 (2a4729d) into main (70f9e9d) will increase coverage by 0.02%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #4115      +/-   ##
==========================================
+ Coverage   94.78%   94.80%   +0.02%     
==========================================
  Files         648      648              
  Lines       54034    54252     +218     
==========================================
+ Hits        51214    51436     +222     
+ Misses       2820     2816       -4     
Impacted Files Coverage Δ
snapcraft/commands/lint.py 100.00% <100.00%> (+2.94%) ⬆️
snapcraft/linters/__init__.py 100.00% <100.00%> (ø)
snapcraft/linters/linters.py 100.00% <100.00%> (+2.32%) ⬆️
tests/unit/commands/test_lint.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal mr-cal marked this pull request as ready for review April 26, 2023 21:52
@mr-cal mr-cal changed the title (draft) lint: lint snap files inside an instance lint: lint snap files inside an instance Apr 26, 2023
Copy link
Contributor

@tigarmo tigarmo left a comment

Choose a reason for hiding this comment

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

Callahan I'm afraid I tried my best to find issues with your code but I failed :/
this is very clear and well-organized, very nice! The unit tests are verbose with the mocking but it's consistent with the other tests, so no issues there.
thanks!

tests/unit/commands/test_lint.py Outdated Show resolved Hide resolved
snapcraft/commands/lint.py Show resolved Hide resolved
mr-cal added 2 commits April 27, 2023 14:20
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal mr-cal merged commit ddd328f into canonical:main Apr 27, 2023
@mr-cal mr-cal deleted the lint-file branch April 27, 2023 21:37
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.

3 participants