Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
118 changes: 1 addition & 117 deletions .github/workflows/main-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,120 +103,10 @@ jobs:
path: coverage/
retention-days: 3

- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: |
.build/debug/index/store
retention-days: 3

# Static Analysis
static-analysis:
runs-on: macos-26
needs: test-and-coverage
timeout-minutes: 15

steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1

- name: Verify Swift version
run: swift --version

- name: Cache Homebrew
uses: actions/cache@v5
with:
path: ~/Library/Caches/Homebrew
key: ${{ runner.os }}-${{ runner.arch }}-brew-swiftlint-gitleaks-periphery
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-brew-

- name: Install analysis tools
run: |
brew install swiftlint gitleaks periphery

- name: Prepare directories
run: |
mkdir -p reports

- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: build-artifacts
path: .build/debug

- name: Run SwiftLint
run: |
swiftlint lint \
--reporter sonarqube \
> reports/linter-report.json || true

- name: Run Periphery
run: |
periphery scan \
--skip-build \
--index-store-path "$PWD/.build/debug/index/store" \
--format json \
> reports/periphery.json || true

# Convert to SonarCloud Clean Code format
# Periphery location is a string "path:line:column" that must be parsed
if [ -f reports/periphery.json ]; then
jq --arg pwd "$PWD" '{
rules: [{
id: "unused-code",
name: "Unused Code",
description: "Code that is never used and can be removed",
engineId: "periphery",
cleanCodeAttribute: "FOCUSED",
impacts: [{
softwareQuality: "MAINTAINABILITY",
severity: "HIGH"
}]
}],
issues: [.[] |
(.location | split(":")) as $loc |
($loc[0] | ltrimstr($pwd + "/")) as $path |
($loc[1] | tonumber) as $line |
($loc[2] | tonumber) as $col |
{
ruleId: "unused-code",
effortMinutes: 10,
primaryLocation: {
message: "\(.kind) \(.name) is \(.hints | join(", "))",
filePath: $path,
textRange: {
startLine: $line,
startColumn: $col,
endLine: $line,
endColumn: ($col + 1)
}
}
}
]
}' reports/periphery.json > reports/dead-code-report.json
fi

- name: Run Gitleaks
run: |
gitleaks detect \
--report-path reports/leaks-report.sarif \
--report-format sarif || true

- name: Upload analysis reports
uses: actions/upload-artifact@v7
with:
name: reports
path: reports/
retention-days: 3

# Publish Code Analysis
publish-code-analysis:
runs-on: ubuntu-latest
needs: [test-and-coverage, static-analysis]
needs: test-and-coverage
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Expand All @@ -232,12 +122,6 @@ jobs:
name: coverage
path: coverage

- name: Download reports artifacts
uses: actions/download-artifact@v8
with:
name: reports
path: reports

- name: Compute project version
run: |
TAG=$(git describe --tags --abbrev=0 2>/dev/null || true)
Expand Down
Loading