Files
app/scripts/test-ci-locally.sh
Albert bb650a3ed9 refactor: Simplify CI testing to use docker-compose directly
Instead of trying to use workflow runner tools (act/act_runner), the script
now directly runs the docker-compose command that CI uses. This is:

- More accurate (exact same command as CI)
- Simpler (no additional tools needed)
- Faster (no workflow interpretation overhead)
- Easier to debug (direct access to service logs)

The CI workflow literally runs `docker compose -f docker-compose.ci.yml`, so
running that locally is the most accurate way to test.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 14:12:35 +00:00

63 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# Script to test CI workflow locally by running the exact same docker-compose command as CI
# This runs docker-compose.ci.yml which is what the Gitea Actions workflow uses
set -e # Exit on error
echo "========================================="
echo "Testing CI Workflow Locally"
echo "========================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if .env exists
if [ ! -f .env ]; then
echo -e "${RED}Error: .env file not found!${NC}"
echo "Please create .env file with required variables"
exit 1
fi
echo -e "${YELLOW}Running the exact same docker-compose command as CI${NC}"
echo -e "${YELLOW}This executes: docker compose -f docker-compose.ci.yml --profile test up${NC}"
echo ""
# Cleanup function
cleanup() {
echo -e "${YELLOW}Cleaning up containers and volumes...${NC}"
docker compose -f docker-compose.ci.yml down -v
}
# Trap cleanup on exit
trap cleanup EXIT
# Run the exact same command that CI runs
docker compose -f docker-compose.ci.yml --profile test up \
--abort-on-container-exit \
--exit-code-from magnitude || {
echo ""
echo -e "${RED}=========================================${NC}"
echo -e "${RED}Tests failed!${NC}"
echo -e "${RED}=========================================${NC}"
echo ""
echo -e "${YELLOW}Showing service logs:${NC}"
echo ""
echo "=== SurrealDB Logs ==="
docker compose -f docker-compose.ci.yml logs --tail=50 surrealdb
echo ""
echo "=== Next.js Logs ==="
docker compose -f docker-compose.ci.yml logs --tail=50 nextjs
echo ""
echo "=== Magnitude Logs ==="
docker compose -f docker-compose.ci.yml logs --tail=50 magnitude
exit 1
}
echo ""
echo -e "${GREEN}=========================================${NC}"
echo -e "${GREEN}All tests passed!${NC}"
echo -e "${GREEN}=========================================${NC}"