Skip to content

Commit 25e9781

Browse files
authored
Atlas (#2333)
* package atlas in dockerfile, fallback, set CGO in dockerfile, fix memory system id
1 parent 2ef0ab1 commit 25e9781

File tree

25 files changed

+1781
-113
lines changed

25 files changed

+1781
-113
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Check Migrations Generated
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'taco/internal/query/types/**'
7+
- 'taco/atlas.hcl'
8+
- 'taco/internal/atlas_loader.go'
9+
workflow_dispatch: # Allows manual trigger from GitHub UI
10+
11+
jobs:
12+
check-migrations:
13+
name: Verify Migrations Were Generated
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Need full history to check file changes
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: '1.22'
26+
cache-dependency-path: |
27+
taco/go.sum
28+
go.work.sum
29+
30+
- name: Install Atlas CLI
31+
run: |
32+
curl -sSf https://atlasgo.sh | sh
33+
atlas version
34+
35+
- name: Install Atlas GORM Provider
36+
run: go install ariga.io/atlas-provider-gorm@latest
37+
38+
- name: Check if model files changed
39+
id: check_models
40+
run: |
41+
# Check if any GORM model files changed in this PR
42+
git fetch origin ${{ github.base_ref }}
43+
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "taco/internal/query/types/"; then
44+
echo "models_changed=true" >> $GITHUB_OUTPUT
45+
echo "✋ GORM models were modified"
46+
else
47+
echo "models_changed=false" >> $GITHUB_OUTPUT
48+
echo "✅ No GORM model changes detected"
49+
fi
50+
51+
- name: Check if migrations changed
52+
id: check_migrations
53+
if: steps.check_models.outputs.models_changed == 'true'
54+
run: |
55+
# Check if migration files changed in this PR
56+
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "taco/migrations/"; then
57+
echo "migrations_changed=true" >> $GITHUB_OUTPUT
58+
echo "✅ Migration files were updated"
59+
else
60+
echo "migrations_changed=false" >> $GITHUB_OUTPUT
61+
echo "❌ No migration files were updated"
62+
fi
63+
64+
- name: Verify migrations were committed with model changes
65+
if: steps.check_models.outputs.models_changed == 'true'
66+
run: |
67+
if [ "${{ steps.check_migrations.outputs.migrations_changed }}" != "true" ]; then
68+
echo ""
69+
echo "❌ ERROR: Model changes detected but no migrations were committed!"
70+
echo ""
71+
echo "📝 You modified GORM models in taco/internal/query/types/"
72+
echo " but didn't generate and commit corresponding migrations."
73+
echo ""
74+
echo "To fix this:"
75+
echo " 1. cd taco"
76+
echo " 2. make atlas-diff-all name=descriptive_name"
77+
echo " 3. git add migrations/"
78+
echo " 4. git commit"
79+
echo ""
80+
echo "Example:"
81+
echo " make atlas-diff-all name=add_user_email_field"
82+
echo ""
83+
exit 1
84+
else
85+
echo "✅ Model changes have corresponding migration files committed"
86+
fi
87+
88+
- name: Validate migration files
89+
if: steps.check_migrations.outputs.migrations_changed == 'true'
90+
working-directory: taco
91+
run: |
92+
echo "Ensuring migration checksums are up to date..."
93+
make atlas-hash-all
94+
95+
echo "Validating migration file format..."
96+
# Just check that .sql files exist and are non-empty
97+
for db in postgres mysql sqlite; do
98+
if [ -d "migrations/$db" ]; then
99+
sql_files=$(find migrations/$db -name "*.sql" -type f)
100+
if [ -z "$sql_files" ]; then
101+
echo "❌ No .sql files found in migrations/$db"
102+
exit 1
103+
fi
104+
echo "✅ Found migration files in migrations/$db"
105+
fi
106+
done
107+
108+
echo "✅ All migration files validated"
109+
110+
- name: Summary
111+
if: always()
112+
run: |
113+
echo "## Migration Check Summary" >> $GITHUB_STEP_SUMMARY
114+
echo "" >> $GITHUB_STEP_SUMMARY
115+
116+
if [ "${{ steps.check_models.outputs.models_changed }}" = "true" ]; then
117+
echo "- 🔄 GORM models were modified" >> $GITHUB_STEP_SUMMARY
118+
119+
if [ "${{ steps.check_migrations.outputs.migrations_changed }}" = "true" ]; then
120+
echo "- ✅ Migration files were updated" >> $GITHUB_STEP_SUMMARY
121+
else
122+
echo "- ℹ️ No migration files changed (no schema impact)" >> $GITHUB_STEP_SUMMARY
123+
fi
124+
else
125+
echo "- ℹ️ No GORM model changes detected" >> $GITHUB_STEP_SUMMARY
126+
fi
127+
128+
echo "" >> $GITHUB_STEP_SUMMARY
129+
echo "### How to generate migrations" >> $GITHUB_STEP_SUMMARY
130+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
131+
echo "cd taco" >> $GITHUB_STEP_SUMMARY
132+
echo "make atlas-diff-all name=descriptive_name" >> $GITHUB_STEP_SUMMARY
133+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
134+

0 commit comments

Comments
 (0)