8000 Add GitLab code quality reporting. by cmlara · Pull Request #1878 · infection/infection · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add GitLab code quality reporting. #1878

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

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

cmlara
Copy link
Contributor
@cmlara cmlara commented Sep 27, 2023

This PR:

Fixes #1877

Adds a new logger format that outputs the GitLab(Code Climate) code quality format.

8000
Copy link
Member
@maks-rafalko maks-rafalko left a comment

Choose a reason for hiding this comment

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

Thank you for this great addition!

Left a couple of comments and we are good to go.

I will ask you also update the docs and add information about new option and config setting, see examples:

Repository to update: https://github.com/infection/site/blob/master/src/guide/command-line-options.md

Do you have any public examples of how this feature works on GitLab already?

@@ -327,6 +327,7 @@ private function retrieveLogs(Logs $logs, string $configDir, ?bool $useGitHubLog
self::pathToAbsolute($logs->getHtmlLogFilePath(), $configDir),
self::pathToAbsolute($logs->getSummaryLogFilePath(), $configDir),
self::pathToAbsolute($logs->getJsonLogFilePath(), $configDir),
self::pathToAbsolute($logs->getGitlabLogFilePath(), $configDir),
Copy link
Member
@maks-rafalko maks-rafalko Sep 27, 2023

Choose a reason for hiding this comment

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

I think we also need --logger-gitlab=<path> or something like this, to

  • make it consistent with --logger-github
  • to have option and config file parity, where this feature can be enabled either from option (--logger-gitlab) or from config file by setting "github": "/path/to/file.json"

Related to #141

@maks-rafalko maks-rafalko added DX Developer Experience Feature labels Sep 27, 2023
@cmlara
Copy link
Contributor Author
cmlara commented Sep 28, 2023

Created PR for documentation and added the CLI option as requested.

Copy link
Member
@maks-rafalko maks-rafalko left a comment

Choose a reason for hiding this comment

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

Thank you for your work, much appreciated.

@maks-rafalko maks-rafalko merged commit 42a666d into infection:master Sep 28, 2023
@maks-rafalko
Copy link
Member

Released, https://github.com/infection/infection/releases/tag/0.27.3

If you have some public repository where I can see this in action, please let me know.

Thanks.

@cmlara
Copy link
Contributor Author
cmlara commented Sep 28, 2023

Thank you!

This was the first step in working towards including infection in a project workflow, I will circle back with an example once I have it on a public repo.

@cmlara
Copy link
Contributor Author
cmlara commented Oct 10, 2023

Here are a couple reference links on a public GitLab server showing it in action configured to perform full scans on branch CI runs and to only scan modified files for MR's.

MR Overview showing the mutation reported as a Code Quality fault: https://git.drupalcode.org/project/s3fs/-/merge_requests/36
MR Changes page showing the escaped mutant as an expandable in-line: https://git.drupalcode.org/project/s3fs/-/merge_requests/36/diffs#0b97329dffce8550a1ce638084c975392cad49c9_49_50

@maks-rafalko
Copy link
Member
maks-rafalko commented Oct 14, 2023

@cmlara I'm new to GitLab, so probably not understand somthing completely, but do you know why it doesn't work on my very simple minimal example?

https://gitlab.com/maks-rafalko/infection-gitlab-integration-example/-/merge_requests/2

  1. I don't see any "annotations" as on yours PR. Is it because I use free account?
  2. I don't see any files (artifacts) uploaded to PR, only can found them on job details page. Is it expected?
  3. Even those uploaded artifacts are empty, while Infection generated 2 escaped mutations

Pipeline definition: https://gitlab.com/maks-rafalko/infection-gitlab-integration-example/-/blob/main/.gitlab-ci.yml#L25-30

@cmlara
Copy link
Contributor Author
cmlara commented Oct 14, 2023

I don't see any "annotations" as on yours PR. Is it because I use free account?

Unfortunately the "See findings in merge request diff view" does require an Ultimate account which is why it works

I don't see any files (artifacts) uploaded to PR, only can found them on job details page. Is it expected?

On https://gitlab.com/maks-rafalko/infection-gitlab-integration-example/-/merge_requests/2 from the download icon they are in the "infection:archive" and "code_quality:archive" download options (GitLab batches all the artifacts into a single download) the filename can be changed by adding an "expose_as" key https://docs.gitlab.com/ee/ci/yaml/#artifactsexpose_as

Even those uploaded artifacts are empty, why Infection generated 2 escaped mutations

On quick glance it does not look like it is a configuration fault in your gitlab-ci.yml. I'm going to have to load up a lab to debug to see if there is a fault in how I implemented the logger plugin.

@cmlara
Copy link
Contributor Author
cmlara commented Oct 14, 2023

Interesting:

When I add on the HTML logger it appears to works:

./vendor/bin/infection --logger-gitlab=infection-gitlab.json --logger-html=/dev/null
(I used https://github.com/firecow/gitlab-ci-local to run your repo locally)

I'm not very familiar with infection's internals, any thoughts on what might cause this? I don't see this on another project, maybe its a dependency related fault?

@maks-rafalko
Copy link
Member
maks-rafalko commented Oct 15, 2023

I'm not very familiar with infection's internals, any thoughts on what might cause this?

there is a bug, fix is here: #1882

I don't see this on another project, maybe its a dependency related fault?

I'm pretty sure that when Infection is used only with --logger-gitlab - it can't work correctly in 0.27.4. Can you share a project and/or executable command line?

@maks-rafalko
Copy link
Member

Now it works on my sample project!

https://gitlab.com/maks-rafalko/infection-gitlab-integration-example/-/merge_requests/2

image

@cmlara
Copy link
Contributor Author
cmlara commented Oct 16, 2023

Ah I missed a location when adding the feature, thank you for finding and creating the fix.

To followup on how I failed to reproduce earlier: Looking back at my command logs it appears I was testing with the -s flag that would also be a triggering option. This does appear to be in line with the fix you provided.

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

Successfully merging this pull request may close these issues.

Add new GitLab (Code Climate) code quality JSON logger.
2 participants
0