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

feat: use CI variables to detect project path #1949

Conversation

darthf1
Copy link
Contributor

@darthf1 darthf1 commented Mar 24, 2024

Fixes #1948.

This fixes the following issue on Gitlab CI:

Generated Reports:
         - /builds/xxx/xxx/var/cache/infection/infection-gitlab.json
Please note that some mutants will inevitably be harmless (i.e. false positives).
fatal: detected dubious ownership in repository at '/builds/xxx/xxx'
To add an exception for this directory, call:
	git config --global --add safe.directory /builds/xxx/xxx
In ExecException.php line 9:
                    
  An error occured  
                    
run [--test-framework TEST-FRAMEWORK] [--test-framework-options TEST-FRAMEWORK-OPTIONS] [-j|--threads THREADS] [--only-covered] [-s|--show-mutations] [--no-progress] [--force-progress] [-c|--configuration CONFIGURATION] [--coverage COVERAGE] [--mutators MUTATORS] [--filter FILTER] [--formatter FORMATTER] [--git-diff-filter GIT-DIFF-FILTER] [--git-diff-lines] [--git-diff-base GIT-DIFF-BASE] [--logger-github [LOGGER-GITHUB]] [--map-source-class-to-test [MAP-SOURCE-CLASS-TO-TEST]] [--logger-gitlab [LOGGER-GITLAB]] [--logger-html LOGGER-HTML] [--noop] [--only-covering-test-cases] [--min-msi MIN-MSI] [--min-covered-msi MIN-COVERED-MSI] [--log-verbosity LOG-VERBOSITY] [--initial-tests-php-options INITIAL-TESTS-PHP-OPTIONS] [--skip-initial-tests] [--ignore-msi-with-no-mutations] [--debug] [--dry-run]

By utilizing the CI_PROJECT_DIR (Gitlab) and the GITHUB_WORKSPACE (Github) ENV variables to get the project root dir, the git command does not have to be invoked.

This does not resolve the issue with running Infection with one of these loggers both outside the CI and outside a GIT repository, but since my project is in a mono-repo and the pathmapping is different inside my Docker container, and the value of these loggers is inside a CI environment; I'm happy with this change.

I tested this change in a CI runner in my private Gitlab project. I have not tested this in CI runner in a Github project, as I don't have any. But the change seems pretty straight forward.

@darthf1 darthf1 force-pushed the feat/use-ci-variables-detect-project-path branch from ea209db to 69178f9 Compare March 24, 2024 13:06
@darthf1
Copy link
Contributor Author

darthf1 commented Mar 24, 2024

All green @maks-rafalko :D

@darthf1 darthf1 force-pushed the feat/use-ci-variables-detect-project-path branch from 69178f9 to b0a8e3c Compare March 24, 2024 14:30
@darthf1
Copy link
Contributor Author

darthf1 commented Mar 24, 2024

Thanks for the review. All ready @sanmai :)

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.

I wonder if we can break the fix introduced here: #1576

I think no, as GITHUB_WORKSPACE should return the root folder (exactly what we need), but just in case..


Let's wait for @sanmai's review yet

@darthf1
Copy link
Contributor Author

darthf1 commented Mar 24, 2024

I wonder if we can break the fix introduced here: #1576

I think no, as GITHUB_WORKSPACE should return the root folder (exactly what we need), but just in case..


Let's wait for @sanmai's review yet

Yeah, when I read the Github docs, they should both resolve to the same directory. But I have no practical experience.

…m:darthf1/infection into feat/use-ci-variables-detect-project-path
@maks-rafalko
Copy link
Member

Could you please also merge master into this branch? Should fix MT build check

@darthf1
Copy link
Contributor Author

darthf1 commented Mar 25, 2024

Comments addressed; all green.

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.

Sill 👍

Copy link
Member

@sanmai sanmai left a comment

Choose a reason for hiding this comment

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

Nice! 💯

@maks-rafalko maks-rafalko merged commit 1ee4ffa into infection:master Mar 25, 2024
55 checks passed
@maks-rafalko
Copy link
Member

Thank you @darthf1

@darthf1 darthf1 deleted the feat/use-ci-variables-detect-project-path branch March 25, 2024 09:51
@maks-rafalko
Copy link
Member

Released https://github.com/infection/infection/releases/tag/0.28.1

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.

Gitlab logger errors when run outside git repository
3 participants