-
Notifications
You must be signed in to change notification settings - Fork 1
Introduce ubuntu-lint #1
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
Open
enr0n
wants to merge
26
commits into
ubuntu:main
Choose a base branch
from
enr0n:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The purpose of this class is to encapsulate context for package source changes, the source package, etc. required for a linter to operate. A linter is intended to be a function that accepts a Context, and using the available information, determines if the check has passed or not. If it fails, it calls Context.lint_fail with the reason, which raises LintFailure. Callers of the linters should handle LintFailure to determine why the check failed. For now, the class contains a changes attribute (type debian.deb822.Changes) to inspect a source changes file, and a debian_changelog attribute (type debian.changelog.Changelog) to inspect the changelog of a source package. More information will be added to this class as needed.
There are no linters defined yet, but this tool adds the scaffolding required. The basic structure is around a Runner class, which holds a set of linters to run, by name. For each linter named foo, there is a command line argument --foo= which accepts "auto", "warn", "fail", "off", and defaults to "auto". This enables control over linters. Additionally, there are flags for context, e.g. --debian-changelog, --source-dir, and --changes-file. Output formatting is minimal at this stage.
Inspect a source changes file, and if it's an Ubuntu revision, complain if the Maintainer field is not set correctly. This lint should be expanded to check debian/control also.
Inspect a source changes file, and complain if Launchpad-Bugs-Fixed is not set. In the CLI, this defaults to a warning for devel, and failure for stable.
Inspect the changelog entry for bug references, and complain if there are none. This is a warning on devel, and a failure on stable.
Ensure that the changelog references a valid distribution.
This is useful to ensure that the changes file has valid references for git-ubuntu, which are how the importer preserves rich history. For now this is only a warning in the CLI, but if the context gains git-ubuntu support, it could be a fail in those contexts.
This will be used for other linters in subsequent commits.
This checks if there is already a version in -proposed, and whether the changes file included reference to it. On the CLI, this is a warning for devel, but fail for stable.
This is a simple warning if it does not appear the referenced bugs have SRU templates.
Warn about release tasks not being set on SRU bugs. Off by default, and a warning for stable.
Logging in to launchpad for the handle is slow. Do not do it until the first time context.lp is used.
f08ef4c to
1437898
Compare
Collaborator
Author
|
I am not exactly sure why the CI does not run here, but here it is running on my fork: https://github.com/enr0n/ubuntu-lint/actions/runs/21490580966. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the initial structure of the Python module and CLI, and implements some basic lints.
The
ubuntu_lintmodule provides the objects required to implement lints:Context: a class that contains the necessary context of a source package, upload, etc. to implement a lint check.LintFailure: a trivial exception that is raised by lint checks on failure.and, several lint basic lints:
check_missing_ubuntu_maintainercheck_missing_launchpad_bugs_fixedcheck_missing_bug_referencescheck_distribution_invalidcheck_missing_git_ubuntu_referencescheck_missing_pending_changelog_entrycheck_sru_bug_missing_templatecheck_sru_bug_missing_release_tasksMore will be added soon.
The
ubuntu-lintCLI tool is a basic wrapper around these checks, with flags to control each lint. For now, the output and operation of the CLI is very basic, and will be addressed soon.