fix docker sha #95
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Import | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| import-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Start Metabase | |
| run: | | |
| docker pull metabase/metabase-enterprise-head:latest | |
| docker run -d --name metabase \ | |
| -e MB_PREMIUM_EMBEDDING_TOKEN=${{ secrets.MB_PREMIUM_EMBEDDING_TOKEN }} \ | |
| -p 3000:3000 \ | |
| metabase/metabase-enterprise-head:latest | |
| echo "Waiting for Metabase to start..." | |
| timeout 180 bash -c ' | |
| until curl -sf http://localhost:3000/api/health | grep -q ok; do | |
| sleep 2 | |
| done | |
| ' | |
| - name: Setup, create API key, and import | |
| run: | | |
| # Complete first-time setup | |
| SETUP_TOKEN=$(curl -sf http://localhost:3000/api/session/properties | jq -r '.["setup-token"]') | |
| SESSION=$(curl -sf http://localhost:3000/api/setup -X POST \ | |
| -H 'Content-Type: application/json' \ | |
| -d "$(jq -n --arg token "$SETUP_TOKEN" '{ | |
| token: $token, | |
| user: {email:"admin@test.com", password:"Metabase123!", first_name:"Admin", last_name:"User", site_name:"Test"}, | |
| prefs: {site_name:"Test", site_locale:"en", allow_tracking:false} | |
| }')" | jq -r '.id') | |
| echo "Setup complete (session: $SESSION)" | |
| # Create API key | |
| API_KEY=$(curl -sf http://localhost:3000/api/api-key \ | |
| -H "X-Metabase-Session: $SESSION" \ | |
| -H 'Content-Type: application/json' \ | |
| -d '{"name":"ci","group_id":2}' | jq -r '.unmasked_key') | |
| echo "API key created" | |
| echo "API_KEY=$API_KEY" >> "$GITHUB_ENV" | |
| # Create import archive and POST it | |
| tar czf /tmp/import.tgz -C examples/v1 . | |
| IMPORT_START=$(date -u +%Y-%m-%dT%H:%M:%SZ) | |
| HTTP_CODE=$(curl -s -o /tmp/import-response.txt -w '%{http_code}' \ | |
| -X POST \ | |
| -H "X-API-Key: $API_KEY" \ | |
| -F 'file=@/tmp/import.tgz' \ | |
| 'http://localhost:3000/api/ee/serialization/import') | |
| cat /tmp/import-response.txt | |
| if [ "$HTTP_CODE" != "200" ]; then | |
| echo "Import failed with HTTP $HTTP_CODE" | |
| exit 1 | |
| fi | |
| echo "Import succeeded" | |
| # Check for metabase.lib warnings from the import | |
| WARNINGS=$(docker logs --since "$IMPORT_START" metabase 2>&1 | grep "WARN.*metabase\.lib" || true) | |
| if [ -n "$WARNINGS" ]; then | |
| echo "Import produced metabase.lib warnings:" | |
| echo "$WARNINGS" | |
| exit 1 | |
| fi | |
| - name: Query every card | |
| run: | | |
| QUERY_START=$(date -u +%Y-%m-%dT%H:%M:%SZ) | |
| # Find the Sample Database ID and only query cards on it | |
| SAMPLE_DB_ID=$(curl -sf http://localhost:3000/api/database \ | |
| -H "X-API-Key: $API_KEY" \ | |
| | jq -r '.data[] | select(.is_sample == true) | .id') | |
| curl -sf http://localhost:3000/api/card \ | |
| -H "X-API-Key: $API_KEY" \ | |
| | jq -r --argjson db "$SAMPLE_DB_ID" '[.[] | select(.database_id == $db)] | .[].id' > /tmp/card-ids.txt | |
| echo "Querying $(wc -l < /tmp/card-ids.txt) cards..." | |
| FAILED=0 | |
| while read -r ID; do | |
| HTTP_CODE=$(curl -s -o /tmp/card-query-$ID.txt -w '%{http_code}' \ | |
| -X POST \ | |
| -H "X-API-Key: $API_KEY" \ | |
| "http://localhost:3000/api/card/$ID/query") | |
| if [ "$HTTP_CODE" != "202" ]; then | |
| echo "Card $ID query failed with HTTP $HTTP_CODE" | |
| cat /tmp/card-query-$ID.txt | |
| FAILED=1 | |
| else | |
| echo "Card $ID query OK" | |
| fi | |
| done < /tmp/card-ids.txt | |
| if [ "$FAILED" = "1" ]; then | |
| echo "One or more card queries failed" | |
| exit 1 | |
| fi | |
| # Check for metabase.lib warnings during query execution | |
| WARNINGS=$(docker logs --since "$QUERY_START" metabase 2>&1 | grep "WARN.*metabase\.lib" || true) | |
| if [ -n "$WARNINGS" ]; then | |
| echo "Card queries produced metabase.lib warnings:" | |
| echo "$WARNINGS" | |
| exit 1 | |
| fi |