microcks / microcks/microcks-cli
CI/CD Pipeline False Positives: `import-dir` Exits with Code 0 on Failures
- Dominant language
- Go
- Stars
- 52
- Forks
- 68
- Avg merge
- 6h 54m
- Merged PRs (30d)
- 10
Description
### Describe the bug
### Description
The `import-dir` command scans a directory and attempts to import all matching files. If one or more files fail to import, it records the failure in `ImportResult.FailedCount` and prints an error message. However, the command runner does not check the failed count to return a non-zero exit code.
### Impact
In CI/CD environments (GitHub Actions, Tekton, GitLab CI), the CLI exits with status `0`, indicating success even if all API specifications failed to import. This hides deployment failures.
### Code Reference
* [cmd/importDir.go](file:///c:/Users/Hp/microcks-cli/cmd/importDir.go#L162-L200)
### Diagram
```mermaid
graph TD
A[Start import-dir] --> B[Scan Directory]
B --> C[Import File 1: Success]
B --> D[Import File 2: FAILED]
C & D --> E[Display Results Summary]
E --> F["Exit Status Code 0 (Success)"]
F --> G["CI/CD pipeline reports green/success despite failures"]
```
### Steps to Reproduce
1. Run `microcks import-dir ./specs` where at least one spec has invalid content.
2. The console displays `✗ Failed: ...`.
3. Check the exit code of the process (`echo $?` or `$LASTEXITCODE` in PowerShell). It returns `0`.
---
Contributor guide
Research direction
Start in cmd/importDir.go around lines 162-200 and trace how ImportResult.FailedCount is handled after the import summary is printed. Reproduce with an invalid API specification, then verify that import-dir returns a non-zero process status when failures are recorded while successful imports retain the expected status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- ci-cd, cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100