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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6e2689d
Fix syntax, change tokei to static link, add user
phanlezz Apr 22, 2024
77c3f5b
Add exit code check to verify git execution
phanlezz Apr 23, 2024
c1102e5
Add Changelog entry for Docker fix
phanlezz Apr 23, 2024
8b59ba6
Add status badge to main readme
phanlezz Apr 23, 2024
7341808
Update copyright to 2024
phanlezz Apr 23, 2024
ca7bb6c
Add possibility to execute golden_test with a given path
phanlezz Apr 23, 2024
14c9ff8
Add golden_test run inside docker to pipeline WIP
phanlezz Apr 23, 2024
81923a1
Remove interactive and tty
phanlezz Apr 23, 2024
d6101e8
Change working dir to project dir
phanlezz Apr 24, 2024
b237e36
Add analysis to path to ensure absolut paths
phanlezz Apr 24, 2024
dae82fd
Fix typo in path argument
phanlezz Apr 24, 2024
0a04c0a
Change test execution to home
phanlezz Apr 24, 2024
5dd833f
WIP Debug ownership
phanlezz Apr 24, 2024
b9dc587
Add root as user for github test run
phanlezz Apr 25, 2024
7eeb2ea
Remove root as runner, add tmp location
phanlezz Apr 25, 2024
50a31bd
Fix logic error
phanlezz Apr 25, 2024
868ecdd
Add ktlint format
phanlezz Apr 26, 2024
69d6354
Add read rights to ccsh
phanlezz Apr 26, 2024
e573d5d
Add read rights change to Dockerfile
phanlezz Apr 26, 2024
4e5dc34
Fix syntax error
phanlezz Apr 26, 2024
311580f
Change user to runner
phanlezz Apr 26, 2024
9df3bda
Revert runner execution, add debug
phanlezz Apr 26, 2024
ed94112
Move execution back to home folder, add more debug
phanlezz Apr 26, 2024
7a80291
Fix path
phanlezz Apr 26, 2024
c316eab
Fix path again
phanlezz Apr 26, 2024
8c9524e
Change to github id
phanlezz Apr 26, 2024
f2bd134
Include build argument in test pipeline
phanlezz Apr 29, 2024
89b545e
Add new file extensions
phanlezz Apr 29, 2024
a73fa27
Add test for version check
phanlezz Apr 29, 2024
c2a20f9
Add example to docker docs
phanlezz Apr 29, 2024
171b40f
Remove debug info
phanlezz Apr 30, 2024
0c5bbfa
Removal of added read rights caused by #3570 fixed by #3607
phanlezz May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ jobs:
runs-on: ubuntu-latest
env:
working-directory: ./analysis
project-directory: .

steps:
- uses: actions/checkout@v3
Expand All @@ -147,6 +148,13 @@ jobs:
./gradlew jacocoTestReport
working-directory: ${{env.working-directory}}

- name: Docker Test Analysis
run: |
docker build ./analysis -t local-ccsh --build-arg USER_UID=1001
current_version=$(node -pe "require('./analysis/node-wrapper/package.json').version")
docker run -w /home/nonroot-docker-user/cc/analysis/test -v $(pwd):/home/nonroot-docker-user/cc local-ccsh bash ./golden_test.sh ${current_version} /home/nonroot-docker-user/tmp-files/ /usr/local/bin/ccsh
working-directory: ${{env.project-directory}}

- name: Setup Java JDK
uses: actions/setup-java@v3.13.0
with:
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ out
**/binScripts/**
gh-pages/vendor
gh-pages/visualization
*.gradle.kts
*.toml

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018, MaibornWolff GmbH
Copyright (c) 2024, MaibornWolff GmbH
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
<h4 align="center">a beautiful tool to help you visualize and understand code in 3D.</h4>

<p align="center">
<a href="">
<img src="https://github.com/MaibornWolff/codecharta/actions/workflows/release.yml/badge.svg"
alt="Build Status">
</a>
<a href="https://github.com/MaibornWolff/codecharta/actions/workflows/release-analysis.yml">
<img src="https://github.com/MaibornWolff/codecharta/actions/workflows/release-analysis.yml/badge.svg" alt="Release Analysis">
</a>
<a href="https://github.com/MaibornWolff/codecharta/actions/workflows/release-visualization.yml">
<img src="https://github.com/MaibornWolff/codecharta/actions/workflows/release-visualization.yml/badge.svg" alt="Release Visualization">
</a>
<a href="https://sonarcloud.io/dashboard?id=maibornwolff-gmbh_codecharta_analysis">
<img src="https://sonarcloud.io/api/project_badges/measure?project=maibornwolff-gmbh_codecharta_analysis&metric=alert_status" alt="Quality Gate Analysis"></a>
<a href="https://sonarcloud.io/dashboard?id=maibornwolff-gmbh_codecharta_visualization">
Expand Down
1 change: 1 addition & 0 deletions analysis/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

### Fixed 🐞

- Add default Docker user to mitigate `GitLogParser` issues during repo-scan [#3571](https://github.com/MaibornWolff/codecharta/pull/3571)
- Escaping and un-escaping windows paths, auto-detecting path separator for Unix and Windows
paths [#3569](https://github.com/MaibornWolff/codecharta/pull/3569)

Expand Down
13 changes: 11 additions & 2 deletions analysis/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update && apt-get dist-upgrade -y
RUN apt-get install git -y

RUN apt-get install wget curl -y; \
wget -qO tokei.tar.gz https://github.com/XAMPPRocky/tokei/releases/latest/download/tokei-x86_64-unknown-linux-gnu.tar.gz; \
wget -qO tokei.tar.gz https://github.com/XAMPPRocky/tokei/releases/download/v12.1.2/tokei-x86_64-unknown-linux-gnu.tar.gz; \
tar -xf tokei.tar.gz -C /usr/local/bin; \
rm tokei.tar.gz;

Expand All @@ -24,7 +24,7 @@ RUN wget -qO codemaat.jar https://github.com/adamtornhill/code-maat/releases/dow

RUN curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh; \
bash /tmp/nodesource_setup.sh; \
apt-get install nodejs make gcc build-essential -y; \
apt-get install nodejs make gcc build-essential -y;

RUN wget -qO /tmp/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip; \
apt-get install unzip -y; \
Expand All @@ -34,4 +34,13 @@ RUN wget -qO /tmp/sonar-scanner.zip https://binaries.sonarsource.com/Distributio
mkdir --parents /usr/local/conf ; cp ./conf/sonar-scanner.properties /usr/local/conf/; \
cp -r ./jre/ /usr/local/jre; cd /; rm /tmp/sonar-scanner.zip; rm -rf /tmp/sonar-scanner-*-linux;

ARG USERNAME=nonroot-docker-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME;

USER $USERNAME

CMD ["ccsh"]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.util.concurrent.Callable
@CommandLine.Command(
name = RepoScanCommand.NAME,
description = [RepoScanCommand.DESCRIPTION],
footer = ["Copyright(c) 2022, MaibornWolff GmbH"],
footer = ["Copyright(c) 2024, MaibornWolff GmbH"],
)
class RepoScanCommand : Callable<Unit>, InteractiveParser {
@CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["displays this help and exits"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ fun getGitLog() {
process.directory(gitDirectory)
process.redirectOutput(fileHandle)
val runningProcess = process.start()
runningProcess.waitFor(3, TimeUnit.MINUTES)
if (runningProcess.waitFor(3, TimeUnit.MINUTES)) {
val exitCode = runningProcess.exitValue()
if (exitCode != 0) {
throw RuntimeException("Error while executing Git! Command was: ${process.command()}. Process returned with exit status $exitCode.")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.maibornwolff.codecharta.importer.gitlogparser.util

import org.assertj.core.api.Assertions
import org.junit.jupiter.api.Assertions.assertThrowsExactly
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import java.io.File
Expand All @@ -17,6 +19,20 @@ class GitAdapterTest {
assertTrue(gitFile.inputStream().bufferedReader().readLine().matches(commitRegex))
}

@Test
fun `should throw error with exit code if non-zero`() {
val gitFile = File.createTempFile("git", ".log")
gitFile.deleteOnExit()

val assertion = assertThrowsExactly(RuntimeException::class.java) { GitAdapter(File(gitFile.parent), gitFile).getGitLog() }
Assertions.assertThat(assertion).hasMessageContainingAll(
"Error while executing Git! Command was",
"[git, log, --numstat, --raw, --topo-order, --reverse, -m]",
"Process returned with exit status",
"128",
)
}

@Test
fun `should produce a not empty git file list for the current directory`() {
val gitLs = File.createTempFile("git", ".log")
Expand Down
2 changes: 1 addition & 1 deletion analysis/node-wrapper/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020, MaibornWolff GmbH
Copyright (c) 2024, MaibornWolff GmbH
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
Loading
Loading