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

Fix GitLogParser in docker container #3571

Merged
merged 32 commits into from
May 7, 2024
Merged

Conversation

phanlezz
Copy link
Collaborator

@phanlezz phanlezz commented Apr 22, 2024

Fix GitLogParser in docker container

  • Fix syntax in Dockerfile so that sonar-scanner can be downloaded correctly

  • change tokei download to static link (not latest anymore)

  • Add a non-root user as default to docker image

  • Is it necessary to declare the user in the compose file?

  • Add an exit code validation, to verify if git exited correctly.

Closes: #3308
Closes: #3385

Definition of Done

A PR is only ready for merge once all the following acceptance criteria are fulfilled:

  • Changes have been manually tested
    • Check code-maat
    • Check tokei
    • Check sonar-scanner (callable, but requires running sonar qube instance at localhost:9000)
    • Check gitlogparser
  • All TODOs related to this PR have been closed
  • There are automated tests for newly written code and bug fixes
  • All bugs discovered while working on this PR have been submitted as issues (if not already an open issue)
  • Documentation (GH-pages, analysis/visualization READMEs, parser READMEs, --help, etc.) has been updated (almost always necessary except for bug fixes)
  • CHANGELOG.md has been updated

Screenshots or gifs

@phanlezz
Copy link
Collaborator Author

It might not be possible to test our Dockerfile with a custom user:
https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user

@phanlezz phanlezz force-pushed the fix/3308/docker-gitlogparser-empty branch from b73022e to 04ee62e Compare April 26, 2024 07:13
@phanlezz
Copy link
Collaborator Author

I'm not sure why the e2e tests failed, now that the Docker Tests ran through 😆.
Problem is that the current setup is not really applicable:

  • I changed the user id (uid) inside the docker container to 1001, which is the uid of the GitHub runner via the Dockerfile
  • Now the owner uid of the repository files matches the uid inside the container and git can run (without dubious ownership issues)
  • BUT: If now executed locally on e.g. Ubuntu with a native user 1000, git doesn't work anymore (because now the repository file owner is different to the docker user uid:1000 != uid:1001)

For me, this means, that we can't really just use uid:1000 as proposed in the original issue, because a regular user of the docker might have a different uid.

Some ideas:

ARG

We could use an ARG in the analysis/Dockerfile where we default a value of 1000 and inject a value of 1001 for GitHub.
This does not fix the issue with regular users, which have uids different to 1000.

We could accept this, and the user would have to adept in this special case. There might also be a possibility of a dynamic uid on container creation which copyies the host uid.

Entrypoint

With an entrypoint script, we might have different options to deal with this problem. Changing the uid, using git config to declare the folders as safe, or changing ownership of the files.

I suggest we try to use the ARG approach, as it keeps the test run and the regular usage close together.

@phanlezz
Copy link
Collaborator Author

Sonar down? 👀

@phanlezz phanlezz force-pushed the fix/3308/docker-gitlogparser-empty branch from 625c849 to 171b40f Compare May 2, 2024 12:16
Copy link

sonarcloud bot commented May 2, 2024

Quality Gate Passed Quality Gate passed for 'CodeCharta Visualization'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented May 2, 2024

@ViktoriaGordeevaVG ViktoriaGordeevaVG self-requested a review May 7, 2024 08:59
@ViktoriaGordeevaVG ViktoriaGordeevaVG self-requested a review May 7, 2024 09:01
@ViktoriaGordeevaVG ViktoriaGordeevaVG marked this pull request as draft May 7, 2024 09:02
@phanlezz phanlezz marked this pull request as ready for review May 7, 2024 09:07
@phanlezz phanlezz merged commit e34e0a6 into main May 7, 2024
7 checks passed
@phanlezz phanlezz deleted the fix/3308/docker-gitlogparser-empty branch May 7, 2024 09:07
@Nereboss Nereboss restored the fix/3308/docker-gitlogparser-empty branch May 16, 2024 07:37
@phanlezz phanlezz deleted the fix/3308/docker-gitlogparser-empty branch May 16, 2024 12:25
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.

Failed to load SLF4J during testing gitlogparser doesn't work with docker file
2 participants