-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: integrations should check for previous comments (#305)
This change affects all integrations that deal with comments/notes on PRs/MRs. Previously, these integrations would not account for the possibility that Phylum-generated comments already exist on the PR/MR. That led to situations where a FAILED comment was the last one posted even though actions (commits) were taken to rectify the bad dependencies. This gap was enabled because the "changed" lockfile looks no different than the one it is being compared to (e.g., the default branch). The additional effect of this behavior was that the integration would bail early and an analysis would therefore not be submitted, leaving the project in an old/bad/incorrect state when viewed on that label. The change here is to ensure previous Phylum-generated comments *are* taken into account. If any are found, an analysis is submitted, even if the lockfile has not otherwise changed from the one which it is compared. Actions taken include: * Add `phylum_comment_exists` predicate as abstract property to `CIBase` * Update the main logic to NOT bail when there is an existing comment * Return false for the `CINone` and `CIPReCommit` implementations * They will never have historical comments * Update the GitLab integration to properly check for existing comments * Account for when in a merge request pipeline context * Update Bitbucket integration to properly check for existing comments * Account for when in a pull request pipeline context * Use query parameters to get the most recent Phylum-generated comment * Simplify the `phylum_comment_exists` logic with this consolidation * Update GitHub integration to properly check for existing comments * Create function to get the most recent Phylum-generated comment * Simplify the `phylum_comment_exists` logic with this consolidation * Update Azure integration to properly check for existing comments * Create function to get the most recent Phylum-generated comment * Simplify the `phylum_comment_exists` logic with this consolidation * Account for the triggering repo being either GitHub or Azure Repos * Format and refactor throughout * Change `phylum_label` to a cached property since it is now called more * Limit the number of subprocess calls * Refactor and format throughout * Add more type hints * Ensure existing type hints are backwards compatible to Python 3.8 * Format `pyproject.toml` Closes #303
- Loading branch information
Showing
11 changed files
with
397 additions
and
186 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.