@@ -46,42 +46,86 @@ commands:
46
46
47
47
echo "✅ Development environment setup complete!"
48
48
echo ""
49
- echo "Run 'atmos dev check' to run pre-commit hooks on staged files"
50
- echo "Run 'atmos dev check-pr' to run pre-commit hooks on PR changes"
51
- echo "Run 'atmos dev check-all' to run pre-commit hooks on all files"
49
+ echo "Run 'atmos dev check' to check staged files (read-only)"
50
+ echo "Run 'atmos dev check-pr' to check PR changes (read-only)"
51
+ echo "Run 'atmos dev format' to auto-format staged files"
52
+ echo "Run 'atmos dev format-pr' to auto-format PR changes"
52
53
53
54
- name : check
54
- description : Run pre-commit hooks on staged files ( for local development )
55
+ description : Check staged files for issues (read-only, no modifications )
55
56
steps :
56
- - pre-commit run
57
+ - |
58
+ echo "🔍 Checking staged files (read-only)..."
59
+ # Run checks without modifying files
60
+ STAGED_GO_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.go' | grep -v -E '^(vendor/|tests/test-cases/|tests/testdata/|tests/snapshots/)' || true)
61
+ if [ -n "$STAGED_GO_FILES" ]; then
62
+ echo "Checking Go formatting..."
63
+ echo "$STAGED_GO_FILES" | xargs -I {} gofumpt -d {} 2>/dev/null | head -20 || true
64
+ echo "Running golangci-lint..."
65
+ golangci-lint run --new-from-rev=origin/main --config=.golangci.yml $STAGED_GO_FILES || true
66
+ fi
67
+ echo "💡 To auto-fix issues, run: atmos dev format"
57
68
58
69
- name : check-pr
59
- description : Run pre-commit hooks on PR changes (compares with main branch )
70
+ description : Check PR changes for issues (read-only, no modifications )
60
71
steps :
61
72
- |
62
- if [ -z "${GITHUB_BASE_REF:-}" ]; then
63
- # Local development - compare with main branch
64
- echo "🔍 Checking files changed from main branch..."
65
- pre-commit run --from-ref origin/main --to-ref HEAD
66
- else
67
- # CI environment - use GitHub PR refs
68
- echo "🔍 Checking files changed in PR..."
69
- pre-commit run --from-ref "origin/${GITHUB_BASE_REF}" --to-ref HEAD
73
+ echo "🔍 Checking PR changes (read-only)..."
74
+ BASE_REF="${GITHUB_BASE_REF:-main}"
75
+ # Get changed Go files
76
+ CHANGED_GO_FILES=$(git diff origin/$BASE_REF...HEAD --name-only -- '*.go' | grep -v -E '^(vendor/|tests/test-cases/|tests/testdata/|tests/snapshots/)' || true)
77
+ if [ -n "$CHANGED_GO_FILES" ]; then
78
+ echo "Checking Go formatting..."
79
+ echo "$CHANGED_GO_FILES" | xargs -I {} gofumpt -d {} 2>/dev/null | head -20 || true
80
+ echo "Running golangci-lint..."
81
+ golangci-lint run --new-from-rev=origin/$BASE_REF --config=.golangci.yml || true
70
82
fi
83
+ echo "💡 To auto-fix issues, run: atmos dev format-pr"
71
84
72
85
- name : check-all
73
- description : Run pre-commit hooks on all files (use sparingly )
86
+ description : Check all files for issues (read-only, no modifications )
74
87
steps :
75
- - pre-commit run --all-files
88
+ - |
89
+ echo "🔍 Checking all files (read-only)..."
90
+ echo "⚠️ This may take a while..."
91
+ # Check formatting without modifying
92
+ echo "Checking Go formatting..."
93
+ find . -name '*.go' -not -path './vendor/*' -not -path './tests/test-cases/*' -not -path './tests/testdata/*' -not -path './tests/snapshots/*' | xargs gofumpt -d 2>/dev/null | head -50 || true
94
+ echo "Running comprehensive linting..."
95
+ golangci-lint run --config=.golangci.yml || true
96
+ echo "💡 To auto-fix issues, run: atmos dev format-all (⚠️ DANGEROUS)"
97
+
98
+ - name : format
99
+ description : Auto-format staged files
100
+ steps :
101
+ - |
102
+ echo "🔧 Auto-formatting staged files..."
103
+ pre-commit run || true
104
+ echo "✅ Formatting applied to staged files"
76
105
77
- - name : fix
78
- description : Auto-fix Go formatting issues
106
+ - name : format-pr
107
+ description : Auto-format PR changes
79
108
steps :
80
109
- |
81
- echo "🔧 Auto-fixing Go formatting issues..."
82
- gofumpt -w .
83
- go mod tidy
84
- echo "✅ Formatting fixes applied"
110
+ echo "🔧 Auto-formatting PR changes..."
111
+ BASE_REF="${GITHUB_BASE_REF:-main}"
112
+ pre-commit run --from-ref origin/$BASE_REF --to-ref HEAD || true
113
+ echo "✅ Formatting applied to PR changes"
114
+
115
+ - name : format-all
116
+ description : ⚠️ DANGEROUS - Auto-format ALL files (excludes golden snapshots)
117
+ steps :
118
+ - |
119
+ echo "⚠️ WARNING: This will modify many files!"
120
+ echo " Excludes: vendor/, tests/test-cases/, tests/testdata/, tests/snapshots/"
121
+ echo " Golden snapshots and fixtures are protected."
122
+ echo ""
123
+ echo " Press Ctrl+C to cancel, or wait 5 seconds to continue..."
124
+ sleep 5
125
+ echo "🔧 Auto-formatting all files..."
126
+ # Run pre-commit on all files with our exclude patterns
127
+ pre-commit run --all-files || true
128
+ echo "✅ Formatting complete. Review changes with: git diff"
85
129
86
130
- name : lint
87
131
description : Run golangci-lint
@@ -119,10 +163,17 @@ commands:
119
163
echo "Available Atmos dev commands:"
120
164
echo ""
121
165
echo " atmos dev setup - Set up local development environment"
122
- echo " atmos dev check - Run pre-commit hooks on staged files (local dev)"
123
- echo " atmos dev check-pr - Run pre-commit hooks on PR changes"
124
- echo " atmos dev check-all - Run pre-commit hooks on all files"
125
- echo " atmos dev fix - Auto-fix Go formatting issues"
166
+ echo ""
167
+ echo " Checking (read-only, no modifications):"
168
+ echo " atmos dev check - Check staged files for issues"
169
+ echo " atmos dev check-pr - Check PR changes for issues"
170
+ echo " atmos dev check-all - Check all files for issues"
171
+ echo ""
172
+ echo " Formatting (modifies files):"
173
+ echo " atmos dev format - Auto-format staged files"
174
+ echo " atmos dev format-pr - Auto-format PR changes"
175
+ echo " atmos dev format-all - ⚠️ DANGEROUS: Auto-format ALL files"
176
+ echo ""
126
177
echo " atmos dev lint - Run golangci-lint"
127
178
echo " atmos dev test - Run tests"
128
179
echo " atmos dev build - Build the Atmos binary"
0 commit comments