Skip to content

Commit 8a5fefb

Browse files
committed
[PLUTO-1412] Test init
1 parent c584641 commit 8a5fefb

19 files changed

Lines changed: 463 additions & 63 deletions

File tree

.github/workflows/it-test.yml

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,28 @@ on:
77
push:
88

99
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0 # Needed for git history
17+
- name: Set up Go
18+
uses: actions/setup-go@v4
19+
- name: Build CLI for all platforms
20+
run: make build-all
21+
- name: Upload CLI binaries
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: cli-binaries
25+
path: |
26+
cli-v2-linux
27+
cli-v2.exe
28+
cli-v2-macos
29+
1030
test:
31+
needs: build
1132
runs-on: ${{ matrix.os }}
1233
strategy:
1334
matrix:
@@ -25,10 +46,9 @@ jobs:
2546
go-version: '1.21'
2647
cache: true
2748

28-
- name: Download CLI binaries from go workflow
29-
uses: dawidd6/action-download-artifact@v2
49+
- name: Download CLI binaries
50+
uses: actions/download-artifact@v4
3051
with:
31-
workflow: go.yml
3252
name: cli-binaries
3353
path: .
3454

@@ -48,6 +68,26 @@ jobs:
4868
if: matrix.os != 'windows-latest'
4969
run: chmod +x cli-v2
5070

71+
- name: Run init command tests
72+
if: matrix.os != 'windows-latest'
73+
id: run_init_tests
74+
continue-on-error: true
75+
shell: bash
76+
env:
77+
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }}
78+
run: |
79+
# Make the script executable
80+
chmod +x integration-tests/run.sh
81+
82+
# Run the init command tests
83+
echo "Running init command integration tests..."
84+
./integration-tests/run.sh || {
85+
echo "❌ Init command tests failed"
86+
echo "::error::Init command tests failed. Please check the logs above for details."
87+
exit 1
88+
}
89+
echo "✅ Init command tests passed successfully!"
90+
5191
- name: Run tool tests
5292
if: matrix.os != 'windows-latest'
5393
id: run_tests
@@ -84,7 +124,7 @@ jobs:
84124
fi
85125
86126
- name: Check test results
87-
if: steps.run_tests.outcome == 'failure'
127+
if: steps.run_tests.outcome == 'failure' || steps.run_init_tests.outcome == 'failure'
88128
run: |
89-
echo "Job failed because some tool tests failed. Please check the logs above for details."
129+
echo "Job failed because some tests failed. Please check the logs above for details."
90130
exit 1

cmd/init.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ func buildRepositoryConfigurationFiles(token string) error {
275275
PyLint: "pylint",
276276
PMD: "pmd",
277277
DartAnalyzer: "dartanalyzer",
278+
Lizard: "lizard",
279+
Semgrep: "semgrep",
278280
}
279281

280282
// Generate languages configuration based on API tools response
@@ -384,52 +386,56 @@ func createToolFileConfigurations(tool tools.Tool, patternConfiguration []domain
384386
if err != nil {
385387
return fmt.Errorf("failed to create Trivy config: %v", err)
386388
}
389+
fmt.Println("Trivy configuration created based on Codacy settings")
387390
} else {
388391
err := createDefaultTrivyConfigFile(toolsConfigDir)
389392
if err != nil {
390393
return fmt.Errorf("failed to create default Trivy config: %v", err)
391394
}
392395
}
393-
fmt.Println("Trivy configuration created based on Codacy settings")
394396
case PMD:
395397
if len(patternConfiguration) > 0 {
396398
err := createPMDConfigFile(patternConfiguration, toolsConfigDir)
397399
if err != nil {
398400
return fmt.Errorf("failed to create PMD config: %v", err)
399401
}
402+
403+
fmt.Println("PMD configuration created based on Codacy settings")
400404
} else {
401405
err := createDefaultPMDConfigFile(toolsConfigDir)
402406
if err != nil {
403407
return fmt.Errorf("failed to create default PMD config: %v", err)
404408
}
405409
}
406-
fmt.Println("PMD configuration created based on Codacy settings")
410+
407411
case PyLint:
408412
if len(patternConfiguration) > 0 {
409413
err := createPylintConfigFile(patternConfiguration, toolsConfigDir)
410414
if err != nil {
411415
return fmt.Errorf("failed to create Pylint config: %v", err)
412416
}
417+
fmt.Println("Pylint configuration created based on Codacy settings")
413418
} else {
414419
err := createDefaultPylintConfigFile(toolsConfigDir)
415420
if err != nil {
416421
return fmt.Errorf("failed to create default Pylint config: %v", err)
417422
}
418423
}
419-
fmt.Println("Pylint configuration created based on Codacy settings")
420424
case DartAnalyzer:
421425
if len(patternConfiguration) > 0 {
422426
err := createDartAnalyzerConfigFile(patternConfiguration, toolsConfigDir)
423427
if err != nil {
424428
return fmt.Errorf("failed to create Dart Analyzer config: %v", err)
425429
}
430+
fmt.Println("Dart configuration created based on Codacy settings")
426431
}
427432
case Semgrep:
428433
if len(patternConfiguration) > 0 {
429434
err := createSemgrepConfigFile(patternConfiguration, toolsConfigDir)
430435
if err != nil {
431436
return fmt.Errorf("failed to create Semgrep config: %v", err)
432437
}
438+
fmt.Println("Semgrep configuration created based on Codacy settings")
433439
}
434440
case Lizard:
435441
createLizardConfigFile(toolsConfigDir, patternConfiguration)
@@ -541,7 +547,6 @@ func createLizardConfigFile(toolsConfigDir string, patternConfiguration []domain
541547
var patterns []domain.PatternDefinition
542548

543549
if len(patternConfiguration) == 0 {
544-
fmt.Println("Using default Lizard configuration")
545550
var err error
546551
patterns, err = tools.FetchDefaultEnabledPatterns(Lizard)
547552
if err != nil {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
runtimes:
2+
- node@22.2.0
3+
- python@3.11.11
4+
tools:
5+
- semgrep@1.78.0
6+
- lizard@1.17.19
7+
- eslint@8.57.0
8+
- trivy@0.59.1
9+
- pylint@3.3.6
10+
- pmd@6.55.0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Codacy CLI
2+
tools-configs/
3+
.gitignore
4+
cli-config.yaml
5+
logs/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mode: remote
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
runtimes:
2+
- node@22.2.0
3+
- python@3.11.11
4+
tools:
5+
- eslint@8.57.0
6+
- trivy@0.59.1
7+
- pylint@3.3.6
8+
- pmd@6.55.0
9+
- semgrep@1.78.0
10+
- lizard@1.17.19
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tools:
2+
- name: pylint
3+
languages: [Python]
4+
extensions: [.py]
5+
- name: lizard
6+
languages: [Java, JavaScript, Python]
7+
extensions: [.java, .js, .jsm, .jsx, .mjs, .py, .vue]
8+
- name: pmd
9+
languages: [Java, JavaScript]
10+
extensions: [.java, .js, .jsm, .jsx, .mjs, .vue]
11+
- name: eslint
12+
languages: [JavaScript]
13+
extensions: [.js, .jsm, .jsx, .mjs, .vue]
14+
- name: trivy
15+
languages: [Multiple]
16+
extensions: []
17+
- name: semgrep
18+
languages: [Java, JavaScript, JSON, Python]
19+
extensions: [.java, .js, .jsm, .json, .jsx, .mjs, .py, .vue]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
patterns:
2+
Lizard_ccn-minor:
3+
category: Complexity
4+
description: Check the Cyclomatic Complexity value of a function or logic block. If the threshold is not met, raise a Minor issue. The default threshold is 5.
5+
explanation: |-
6+
# Minor Cyclomatic Complexity control
7+
8+
Check the Cyclomatic Complexity value of a function or logic block. If the threshold is not met, raise a Minor issue. The default threshold is 4.
9+
id: Lizard_ccn-minor
10+
level: Info
11+
severityLevel: Info
12+
threshold: 5
13+
timeToFix: 5
14+
title: Minor Cyclomatic Complexity control
15+
Lizard_nloc-critical:
16+
category: Complexity
17+
description: Check the number of lines of code (without comments) in a function or logic block. If the threshold is not met, raise a Critical issue. The default threshold is 100.
18+
explanation: |-
19+
# Critical NLOC control - Number of Lines of Code (without comments)
20+
21+
Check the number of lines of code (without comments) in a function or logic block. If the threshold is not met, raise a Critical issue. The default threshold is 100.
22+
id: Lizard_nloc-critical
23+
level: Error
24+
severityLevel: Error
25+
threshold: 100
26+
timeToFix: 5
27+
title: Critical NLOC control - Number of Lines of Code (without comments)
28+
Lizard_nloc-medium:
29+
category: Complexity
30+
description: Check the number of lines of code (without comments) in a function. If the threshold is not met, raise a Medium issue. The default threshold is 50.
31+
explanation: |-
32+
# Medium NLOC control - Number of Lines of Code (without comments)
33+
34+
Check the number of lines of code (without comments) in a function. If the threshold is not met, raise a Medium issue. The default threshold is 50.
35+
id: Lizard_nloc-medium
36+
level: Warning
37+
severityLevel: Warning
38+
threshold: 50
39+
timeToFix: 5
40+
title: Medium NLOC control - Number of Lines of Code (without comments)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[MASTER]
2+
ignore=CVS
3+
persistent=yes
4+
load-plugins=
5+
6+
[MESSAGES CONTROL]
7+
disable=all
8+
enable=E1124,E1130,E1133
9+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Codacy PMD Ruleset"
3+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
6+
<description>Codacy PMD Ruleset</description>
7+
8+
<rule ref="category/apex/design.xml/ExcessivePublicCount"/>
9+
<rule ref="category/java/bestpractices.xml/JUnitTestsShouldIncludeAssert"/>
10+
<rule ref="category/java/codestyle.xml/ShortMethodName"/>
11+
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/>
12+
</ruleset>

0 commit comments

Comments
 (0)