Skip to content

Commit 9fe40a5

Browse files
committed
new feat
1 parent b23d0a6 commit 9fe40a5

21 files changed

Lines changed: 3584 additions & 192 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: 🧭 Homebrew Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to release (e.g., v1.0.0)'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
update-homebrew-formula:
15+
name: Update Homebrew Formula
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up variables
25+
id: vars
26+
run: |
27+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
28+
VERSION="${{ inputs.version }}"
29+
else
30+
VERSION="${{ github.event.release.tag_name }}"
31+
fi
32+
33+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
34+
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
35+
echo "tarball_url=https://github.com/${{ github.repository }}/archive/refs/tags/${VERSION}.tar.gz" >> $GITHUB_OUTPUT
36+
37+
- name: Calculate SHA256
38+
id: sha256
39+
run: |
40+
curl -sL "${{ steps.vars.outputs.tarball_url }}" | sha256sum | cut -d' ' -f1 > sha256.txt
41+
SHA256=$(cat sha256.txt)
42+
echo "sha256=${SHA256}" >> $GITHUB_OUTPUT
43+
echo "📋 SHA256: ${SHA256}"
44+
45+
- name: Update Homebrew formula
46+
run: |
47+
# Update Formula/codecompass.rb with new version and SHA256
48+
sed -i 's|url ".*"|url "${{ steps.vars.outputs.tarball_url }}"|' Formula/codecompass.rb
49+
sed -i 's|sha256 ".*"|sha256 "${{ steps.sha256.outputs.sha256 }}"|' Formula/codecompass.rb
50+
51+
echo "🧭 Updated Formula/codecompass.rb:"
52+
cat Formula/codecompass.rb
53+
54+
- name: Validate formula syntax
55+
run: |
56+
# Check Ruby syntax
57+
ruby -c Formula/codecompass.rb
58+
echo "✅ Formula syntax is valid"
59+
60+
- name: Test formula (dry-run)
61+
run: |
62+
echo "🧪 Formula validation completed"
63+
echo "Version: ${{ steps.vars.outputs.version }}"
64+
echo "SHA256: ${{ steps.sha256.outputs.sha256 }}"
65+
echo "URL: ${{ steps.vars.outputs.tarball_url }}"
66+
67+
- name: Commit formula updates
68+
if: github.event_name == 'release'
69+
run: |
70+
git config --global user.name 'github-actions[bot]'
71+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
72+
73+
git add Formula/codecompass.rb
74+
git commit -m "🧭 Update Homebrew formula for ${{ steps.vars.outputs.version }}"
75+
git push
76+
77+
- name: Create Homebrew tap PR (if tap exists)
78+
if: github.event_name == 'release'
79+
env:
80+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
run: |
82+
echo "🚀 Formula ready for Homebrew tap update"
83+
echo "Manual step: Update tap repository with new formula"
84+
85+
# Note: This would require a separate tap repository
86+
# For now, we'll just prepare the formula file
87+
88+
echo "Formula updated and ready for release:"
89+
echo "- Version: ${{ steps.vars.outputs.version }}"
90+
echo "- SHA256: ${{ steps.sha256.outputs.sha256 }}"
91+
echo "- Tarball: ${{ steps.vars.outputs.tarball_url }}"
92+
93+
- name: Create artifact
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: homebrew-formula-${{ steps.vars.outputs.version }}
97+
path: |
98+
Formula/codecompass.rb
99+
sha256.txt
100+
retention-days: 30
101+
102+
- name: Summary
103+
run: |
104+
echo "## 🧭 Homebrew Release Summary" >> $GITHUB_STEP_SUMMARY
105+
echo "| Item | Value |" >> $GITHUB_STEP_SUMMARY
106+
echo "|------|-------|" >> $GITHUB_STEP_SUMMARY
107+
echo "| Version | ${{ steps.vars.outputs.version }} |" >> $GITHUB_STEP_SUMMARY
108+
echo "| SHA256 | ${{ steps.sha256.outputs.sha256 }} |" >> $GITHUB_STEP_SUMMARY
109+
echo "| Tarball URL | ${{ steps.vars.outputs.tarball_url }} |" >> $GITHUB_STEP_SUMMARY
110+
echo "| Formula Status | ✅ Updated and validated |" >> $GITHUB_STEP_SUMMARY
111+
echo "" >> $GITHUB_STEP_SUMMARY
112+
echo "### 📋 Next Steps" >> $GITHUB_STEP_SUMMARY
113+
echo "1. Formula has been automatically updated" >> $GITHUB_STEP_SUMMARY
114+
echo "2. Users can install with: \`brew install codecompass\`" >> $GITHUB_STEP_SUMMARY
115+
echo "3. Consider submitting to official Homebrew core if popular enough" >> $GITHUB_STEP_SUMMARY

Formula/codecompass.rb

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,83 @@
11
class Codecompass < Formula
2-
desc "A CLI tool that helps you navigate and understand large codebases."
3-
homepage "https://github.com/xeoncross/codecompass"
4-
url "https://github.com/xeon-zolt/codecompass/archive/refs/tags/v0.0.1-beta.3.tar.gz" # Placeholder: Update with each release
5-
sha256 "99e7d4be71d3383faa6d00ead8f94c311b4c57b7f549e51ab2191ca58296e72f" # Placeholder: Update with each release
2+
desc "Navigate Your Code Quality - A comprehensive code quality analysis tool with advanced analytics"
3+
homepage "https://github.com/xeon-zolt/codecompass"
4+
url "https://github.com/xeon-zolt/codecompass/archive/refs/tags/v1.0.0.tar.gz" # Update with each release
5+
sha256 "PLACEHOLDER_SHA256_HASH" # Calculate with: shasum -a 256 codecompass-v1.0.0.tar.gz
6+
license "MIT"
67

78
depends_on "go" => :build
9+
depends_on "git"
10+
11+
# Optional dependencies for enhanced functionality
12+
uses_from_macos "node" => :optional # For ESLint support
13+
uses_from_macos "python3" => :optional # For Ruff support
814

915
def install
10-
system "go", "build", *std_go_args(ldflags: "-s -w")
16+
# Build with version information
17+
version_ldflags = "-X main.version=#{version} -X main.buildDate=#{Time.now.strftime('%Y-%m-%d')}"
18+
system "go", "build", *std_go_args(ldflags: "-s -w #{version_ldflags}")
19+
20+
# Create default config directory
21+
(etc/"codecompass").mkpath
22+
23+
# Install sample configuration
24+
system bin/"codecompass", "--generate-config"
25+
(etc/"codecompass").install ".codecompass.rc" => "codecompass.rc.example"
26+
end
27+
28+
def caveats
29+
<<~EOS
30+
🧭 CodeCompass is now installed!
31+
32+
Basic Usage:
33+
codecompass --help # Show all available options
34+
codecompass --summary # Quick repository overview
35+
codecompass --authors # Author leaderboard
36+
37+
Advanced Features:
38+
codecompass --quality # Comprehensive quality analysis
39+
codecompass --trends # Trend analysis with charts
40+
codecompass --hotspots # Detect high-risk code areas
41+
codecompass --team # Team performance metrics
42+
43+
Configuration:
44+
Sample config: #{etc}/codecompass/codecompass.rc.example
45+
Copy to your repo: cp #{etc}/codecompass/codecompass.rc.example .codecompass.rc
46+
47+
Optional Dependencies:
48+
• Install ESLint for JavaScript analysis: npm install -g eslint
49+
• Install Ruff for Python analysis: pip install ruff
50+
EOS
1151
end
1252

1353
test do
14-
# Basic test to ensure the binary runs and outputs something
15-
assert_match "CodeCompass", shell_output("#{bin}/codecompass --version")
54+
# Test version output
55+
version_output = shell_output("#{bin}/codecompass --version")
56+
assert_match "CodeCompass", version_output
57+
assert_match version.to_s, version_output
58+
59+
# Test help output
60+
help_output = shell_output("#{bin}/codecompass --help")
61+
assert_match "Navigate Your Code Quality", help_output
62+
assert_match "--quality", help_output
63+
assert_match "--trends", help_output
64+
assert_match "--hotspots", help_output
65+
assert_match "--team", help_output
66+
67+
# Test config generation
68+
system bin/"codecompass", "--generate-config"
69+
assert_predicate testpath/".codecompass.rc", :exist?
70+
71+
# Test that it can run basic analysis (in a git repo)
72+
system "git", "init"
73+
system "git", "config", "user.name", "Test User"
74+
system "git", "config", "user.email", "test@example.com"
75+
(testpath/"test.go").write "package main\nfunc main() {}\n"
76+
system "git", "add", "."
77+
system "git", "commit", "-m", "Initial commit"
78+
79+
# Test summary command
80+
summary_output = shell_output("#{bin}/codecompass --summary")
81+
assert_match "Repository Summary", summary_output
1682
end
1783
end

0 commit comments

Comments
 (0)