Skip to content

Commit 9548753

Browse files
authored
feat: switch from Makefile to Mise (#29)
1 parent ee22a70 commit 9548753

10 files changed

Lines changed: 84 additions & 106 deletions

File tree

.github/workflows/generate.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,14 @@ on: [push]
55
jobs:
66
test:
77
runs-on: macos-14
8-
env:
9-
MINT_PATH: "~/mint_cache"
108

119
steps:
1210
- uses: actions/checkout@v5
13-
14-
- name: Cache Mint
15-
id: cache-mint
16-
uses: actions/cache@v4
17-
with:
18-
path: ~/mint_cache
19-
key: cache
11+
- uses: jdx/mise-action@v3
2012

2113
- name: Generate project and run tests
2214
run: |
23-
brew install cookiecutter mint
15+
brew install cookiecutter
2416
cookiecutter --no-input -f .
25-
mint bootstrap
17+
mise install
2618
swift test

{{ cookiecutter.name | lower }}/.github/dependabot.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

{{ cookiecutter.name | lower }}/.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- dev
87
pull_request:
98
paths:
109
- '.swiftlint.yml'

{{ cookiecutter.name | lower }}/.swiftformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Stream rules
22

3-
--swiftversion 5.3
3+
--swiftversion 5.10
44

55
# Use 'swiftformat --options' to list all of the possible options
66

{{ cookiecutter.name | lower }}/Makefile

Lines changed: 0 additions & 19 deletions
This file was deleted.

{{ cookiecutter.name | lower }}/Mintfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

{{ cookiecutter.name | lower }}/hooks/pre-commit

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[tools]
2+
git-cliff = "2.9.1"
3+
swiftlint = "0.62.2"
4+
swiftformat = "0.58.7"
5+
6+
[settings]
7+
experimental = true
8+
9+
[hooks]
10+
postinstall = "mise run install"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "🔧 Installing git hooks..."
6+
7+
# Find git repository root
8+
GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
9+
10+
if [ -z "$GIT_ROOT" ]; then
11+
echo "❌ Error: Not a git repository"
12+
exit 1
13+
fi
14+
15+
echo "📁 Git root: $GIT_ROOT"
16+
17+
# Create hooks directory if it doesn't exist
18+
mkdir -p "$GIT_ROOT/.git/hooks"
19+
20+
# Create pre-commit hook
21+
cat > "$GIT_ROOT/.git/hooks/pre-commit" <<'HOOK_EOF'
22+
#!/bin/bash
23+
24+
echo "🔍 Running linters..."
25+
26+
echo "📝 Formatting staged Swift files..."
27+
git diff --diff-filter=d --staged --name-only | grep -e '\.swift$' | while read line; do
28+
if [[ $line == *"/Generated"* ]]; then
29+
echo "⏭️ Skipping generated file: $line"
30+
else
31+
echo "✨ Formatting: $line"
32+
mise exec swiftformat -- swiftformat "${line}"
33+
git add "$line"
34+
fi
35+
done
36+
37+
if ! mise run lint; then
38+
echo "❌ Lint failed. Please fix the issues before committing."
39+
echo "💡 Tip: Run 'mise run format' to auto-fix some issues"
40+
echo "⚠️ To skip this hook, use: git commit --no-verify"
41+
exit 1
42+
fi
43+
44+
echo "✅ All checks passed!"
45+
exit 0
46+
HOOK_EOF
47+
48+
chmod +x "$GIT_ROOT/.git/hooks/pre-commit"
49+
50+
echo "✅ Git hooks installed successfully!"
51+
echo "📍 Hook location: $GIT_ROOT/.git/hooks/pre-commit"
52+
echo ""
53+
echo "Pre-commit hook will:"
54+
echo " 1. Format staged Swift files (except /Generated)"
55+
echo " 2. Run mise lint"
56+
echo ""
57+
echo "To skip the hook, use: git commit --no-verify"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
#MISE description="Lint the {{ cookiecutter.name | lower }} package using SwiftLint and SwiftFormat"
3+
#MISE usage flag "-f --fix" help="Fix the fixable issues"
4+
5+
set -eo pipefail
6+
7+
if [ "$usage_fix" = "true" ]; then
8+
swiftformat Sources Tests
9+
swiftlint lint --fix --strict --config .swiftlint.yml Sources Tests
10+
else
11+
swiftformat Sources Tests --lint
12+
swiftlint lint --strict --config .swiftlint.yml Sources Tests
13+
fi

0 commit comments

Comments
 (0)