Skip to content

Commit c108090

Browse files
committed
Add tests for package version mismatch detection(FritzAndFriends#28)
Improved reporting of packages Added AoT building and delivery at release time Add tests for package version mismatch detection and improve reportin… (FritzAndFriends#29) Add config file support (FritzAndFriends#36)
1 parent eac8bc2 commit c108090

29 files changed

Lines changed: 1924 additions & 459 deletions

‎.github/workflows/docker-publish.yml‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
build-and-push:
1414
runs-on: ubuntu-latest
1515
permissions:
16-
contents: read
16+
contents: write
1717
packages: write
1818

1919
steps:
@@ -45,6 +45,7 @@ jobs:
4545
type=raw,value=latest,enable={{is_default_branch}}
4646
4747
- name: Build and push Docker image
48+
id: build
4849
uses: docker/build-push-action@v5
4950
with:
5051
context: .
@@ -59,3 +60,25 @@ jobs:
5960
cache-from: type=gha
6061
cache-to: type=gha,mode=max
6162
platforms: linux/amd64,linux/arm64
63+
64+
- name: Create release image reference
65+
if: github.event_name == 'release'
66+
shell: bash
67+
run: |
68+
set -euo pipefail
69+
{
70+
echo "CodeMedic container image"
71+
echo "Release: ${{ github.event.release.tag_name }}"
72+
echo "Repository: ${{ github.repository }}"
73+
echo "Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
74+
echo "Digest: ${{ steps.build.outputs.digest }}"
75+
echo ""
76+
echo "Tags:"
77+
echo "${{ steps.meta.outputs.tags }}" | sed 's/^/ - /'
78+
} > codemedic-container-image.txt
79+
80+
- name: Attach image reference to release
81+
if: github.event_name == 'release'
82+
uses: softprops/action-gh-release@v2
83+
with:
84+
files: codemedic-container-image.txt
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Release Binaries (NativeAOT)
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
env:
9+
DOTNET_NOLOGO: true
10+
11+
jobs:
12+
publish-aot:
13+
name: Publish NativeAOT (${{ matrix.rid }})
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- os: windows-latest
20+
rid: win-x64
21+
ext: .exe
22+
- os: windows-latest
23+
rid: win-arm64
24+
ext: .exe
25+
- os: ubuntu-latest
26+
rid: linux-x64
27+
ext: ""
28+
- os: ubuntu-latest
29+
rid: linux-arm64
30+
ext: ""
31+
needsCross: true
32+
- os: macos-13
33+
rid: osx-x64
34+
ext: ""
35+
- os: macos-latest
36+
rid: osx-arm64
37+
ext: ""
38+
39+
permissions:
40+
contents: write
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Setup .NET
49+
uses: actions/setup-dotnet@v4
50+
with:
51+
dotnet-version: 10.0.x
52+
53+
- name: Install NativeAOT prerequisites (Linux)
54+
if: runner.os == 'Linux'
55+
shell: bash
56+
run: |
57+
set -euo pipefail
58+
sudo apt-get update
59+
sudo apt-get install -y clang zlib1g-dev
60+
61+
- name: Install cross toolchain (linux-arm64)
62+
if: runner.os == 'Linux' && matrix.needsCross
63+
shell: bash
64+
run: |
65+
set -euo pipefail
66+
sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
67+
68+
- name: Restore
69+
run: dotnet restore src/CodeMedic.sln
70+
71+
- name: Publish (NativeAOT)
72+
run: >-
73+
dotnet publish src/CodeMedic/CodeMedic.csproj
74+
-c Release
75+
-r ${{ matrix.rid }}
76+
/p:PublishAot=true
77+
78+
- name: Prepare artifact
79+
shell: bash
80+
run: |
81+
set -euo pipefail
82+
VERSION="${{ github.event.release.tag_name }}"
83+
if [ -z "$VERSION" ]; then VERSION="manual"; fi
84+
85+
OUTDIR="src/CodeMedic/bin/Release/net10.0/${{ matrix.rid }}/publish"
86+
BIN="$OUTDIR/CodeMedic${{ matrix.ext }}"
87+
88+
if [ ! -f "$BIN" ]; then
89+
echo "Expected binary not found at $BIN"
90+
echo "Publish directory contents:"
91+
ls -la "$OUTDIR" || true
92+
exit 1
93+
fi
94+
95+
mkdir -p artifacts
96+
DEST="artifacts/CodeMedic-${VERSION}-${{ matrix.rid }}${{ matrix.ext }}"
97+
cp "$BIN" "$DEST"
98+
99+
- name: Generate checksums (SHA-256)
100+
shell: pwsh
101+
run: |
102+
$ErrorActionPreference = 'Stop'
103+
104+
$files = Get-ChildItem -LiteralPath 'artifacts' -File | Where-Object { $_.Name -notmatch '\.sha256$' }
105+
if (-not $files -or $files.Count -eq 0) {
106+
throw 'No artifacts found to checksum.'
107+
}
108+
109+
foreach ($file in $files) {
110+
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $file.FullName).Hash.ToLowerInvariant()
111+
$line = "$hash $($file.Name)"
112+
$checksumPath = "$($file.FullName).sha256"
113+
$line | Out-File -FilePath $checksumPath -Encoding ascii
114+
}
115+
116+
- name: Upload workflow artifact
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: CodeMedic-${{ matrix.rid }}
120+
path: artifacts/*
121+
122+
- name: Attach binaries to GitHub Release
123+
if: github.event_name == 'release'
124+
uses: softprops/action-gh-release@v2
125+
with:
126+
files: artifacts/*

‎.vscode/settings.json‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"editor.insertSpaces": false,
3+
"editor.tabSize": 4,
4+
"editor.detectIndentation": false,
5+
"[csharp]": {
6+
"editor.insertSpaces": false,
7+
"editor.tabSize": 4
8+
},
9+
"[json]": {
10+
"editor.insertSpaces": false,
11+
"editor.tabSize": 2
12+
},
13+
"[xml]": {
14+
"editor.insertSpaces": false,
15+
"editor.tabSize": 2
16+
},
17+
"[yaml]": {
18+
"editor.insertSpaces": true,
19+
"editor.tabSize": 2
20+
},
21+
"[markdown]": {
22+
"editor.insertSpaces": true,
23+
"editor.tabSize": 2
24+
}
25+
}

‎README.md‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ dotnet run -- --help
3030

3131
## 📖 Documentation
3232

33-
- **User Guide:** `user-docs/cli_quick_reference.md`
34-
- **Docker Guide:** `user-docs/docker_usage.md`
35-
- **Technical Guide:** `doc/cli_skeleton_implementation.md`
36-
- **Architecture & Extension:** `doc/cli_architecture.md`
33+
### User Documentation
34+
- **CLI Quick Reference:** `user-docs/cli_quick_reference.md`
35+
- **Configuration Files:** `user-docs/configuration-files.md` - Batch analysis with JSON/YAML
36+
- **Docker Usage:** `user-docs/docker_usage.md`
37+
- **Vulnerability Scanning:** `user-docs/vulnerability-scanning.md`
38+
39+
### Technical Documentation
40+
- **CLI Architecture:** `doc/cli_architecture.md`
41+
- **Implementation Guide:** `doc/cli_skeleton_implementation.md`
3742
- **Docker Implementation:** `doc/docker_implementation.md`
3843
- **Test Results:** `doc/cli_skeleton_test_results.md`
3944

@@ -52,6 +57,7 @@ dotnet run -- --help
5257
- ✅ Multiple output formats (console, markdown)
5358
- ✅ Path argument support (`-p` / `--path`) for all analysis commands
5459
- ✅ Command-specific help with argument documentation
60+
- ✅ **Configuration file support (JSON & YAML) for batch analysis**
5561

5662
## 🎯 Current Commands
5763

@@ -61,6 +67,11 @@ codemedic # Show help (default)
6167
codemedic --help # Explicit help
6268
codemedic --version # Show version
6369

70+
# Configuration-based batch analysis
71+
codemedic config <config-file> # Run multiple analyses from config file
72+
codemedic config config.json
73+
codemedic config config.yaml
74+
6475
# Analysis commands
6576
codemedic health # Repository health dashboard
6677
codemedic health -p /path/to/repo --format markdown

‎run-config.cmd‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@echo off
2+
REM Run CodeMedic with a configuration file
3+
4+
if "%1"=="" (
5+
set CONFIG_FILE=sample-config.yaml
6+
) else (
7+
set CONFIG_FILE=%1
8+
)
9+
10+
if not exist "%CONFIG_FILE%" (
11+
echo Configuration file not found: %CONFIG_FILE%
12+
exit /b 1
13+
)
14+
15+
echo Running CodeMedic with configuration: %CONFIG_FILE%
16+
17+
dotnet run --project src\CodeMedic config %CONFIG_FILE%

‎run-config.ps1‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env pwsh
2+
# Run CodeMedic with a configuration file
3+
4+
param(
5+
[Parameter(Mandatory=$false)]
6+
[string]$ConfigFile = "sample-config.yaml"
7+
)
8+
9+
if (-not (Test-Path $ConfigFile)) {
10+
Write-Host "Configuration file not found: $ConfigFile" -ForegroundColor Red
11+
exit 1
12+
}
13+
14+
Write-Host "Running CodeMedic with configuration: $ConfigFile" -ForegroundColor Cyan
15+
16+
dotnet run --project src\CodeMedic config $ConfigFile

‎run-config.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
# Run CodeMedic with a configuration file
3+
4+
CONFIG_FILE="${1:-sample-config.yaml}"
5+
6+
if [ ! -f "$CONFIG_FILE" ]; then
7+
echo "Configuration file not found: $CONFIG_FILE"
8+
exit 1
9+
fi
10+
11+
echo "Running CodeMedic with configuration: $CONFIG_FILE"
12+
13+
dotnet run --project src/CodeMedic config "$CONFIG_FILE"

‎sample-config-multi-repo.json‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"global": {
3+
"format": "markdown",
4+
"output-dir": "./reports/multi"
5+
},
6+
"repositories": [
7+
{
8+
"name": "MainProject",
9+
"path": "./src",
10+
"commands": ["health", "bom"]
11+
},
12+
{
13+
"name": "TestSuite",
14+
"path": "./test",
15+
"commands": ["health"]
16+
},
17+
{
18+
"name": "Documentation",
19+
"path": "./docs",
20+
"commands": ["bom"]
21+
}
22+
]
23+
}

‎sample-config-multi-repo.yaml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
global:
2+
format: markdown
3+
output-dir: ./reports/multi
4+
5+
repositories:
6+
- name: MainProject
7+
path: ./src
8+
commands:
9+
- health
10+
- bom
11+
12+
- name: TestSuite
13+
path: ./test
14+
commands:
15+
- health
16+
17+
- name: Documentation
18+
path: ./docs
19+
commands:
20+
- bom

‎sample-config.json‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"global": {
3+
"format": "markdown",
4+
"output-dir": "./reports"
5+
},
6+
"repositories": [
7+
{
8+
"name": "CodeMedic",
9+
"path": ".",
10+
"commands": ["health", "bom", "vulnerabilities"]
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)