1+ name : Integration Tests
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ env :
10+ CARGO_TERM_COLOR : always
11+ RUST_BACKTRACE : 1
12+
13+ jobs :
14+ integration-tests :
15+ runs-on : ubuntu-latest
16+
17+ services :
18+ postgres :
19+ image : postgres:16
20+ env :
21+ POSTGRES_DB : container_engine_test
22+ POSTGRES_USER : postgres
23+ POSTGRES_PASSWORD : password
24+ options : >-
25+ --health-cmd pg_isready
26+ --health-interval 10s
27+ --health-timeout 5s
28+ --health-retries 5
29+ ports :
30+ - 5432:5432
31+
32+ redis :
33+ image : redis:7-alpine
34+ options : >-
35+ --health-cmd "redis-cli ping"
36+ --health-interval 10s
37+ --health-timeout 5s
38+ --health-retries 5
39+ ports :
40+ - 6379:6379
41+
42+ steps :
43+ - name : Checkout code
44+ uses : actions/checkout@v4
45+
46+ - name : Install Rust
47+ uses : dtolnay/rust-toolchain@stable
48+ with :
49+ components : rustfmt, clippy
50+
51+ - name : Cache Rust dependencies
52+ uses : actions/cache@v4
53+ with :
54+ path : |
55+ ~/.cargo/registry
56+ ~/.cargo/git
57+ target/
58+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
59+ restore-keys : |
60+ ${{ runner.os }}-cargo-
61+
62+ - name : Install SQLx CLI
63+ run : cargo install sqlx-cli --no-default-features --features postgres
64+
65+ - name : Set up Python
66+ uses : actions/setup-python@v4
67+ with :
68+ python-version : ' 3.11'
69+ cache : ' pip'
70+
71+ - name : Install Python dependencies
72+ run : |
73+ pip install --upgrade pip
74+ pip install -r tests/requirements.txt
75+
76+ - name : Check Rust formatting
77+ run : cargo fmt --all -- --check
78+
79+ - name : Run Rust linter
80+ run : cargo clippy --all-targets --all-features -- -D warnings
81+
82+ - name : Build Rust application
83+ run : cargo build --verbose
84+
85+ - name : Set up test environment
86+ run : |
87+ # Set environment variables for the application
88+ echo "DATABASE_URL=postgresql://postgres:password@localhost:5432/container_engine_test" >> $GITHUB_ENV
89+ echo "REDIS_URL=redis://localhost:6379" >> $GITHUB_ENV
90+ echo "PORT=3000" >> $GITHUB_ENV
91+ echo "JWT_SECRET=test-jwt-secret-key-for-github-actions" >> $GITHUB_ENV
92+ echo "JWT_EXPIRES_IN=3600" >> $GITHUB_ENV
93+ echo "API_KEY_PREFIX=ce_test_" >> $GITHUB_ENV
94+ echo "KUBERNETES_NAMESPACE=test" >> $GITHUB_ENV
95+ echo "DOMAIN_SUFFIX=test.local" >> $GITHUB_ENV
96+ echo "RUST_LOG=container_engine=info,tower_http=info" >> $GITHUB_ENV
97+
98+ - name : Run database migrations
99+ run : |
100+ sqlx migrate run --database-url postgresql://postgres:password@localhost:5432/container_engine_test
101+
102+ - name : Start Container Engine server in background
103+ run : |
104+ cargo run &
105+ echo $! > server.pid
106+
107+ # Wait for server to be ready
108+ timeout 60 bash -c 'until curl -f http://localhost:3000/health; do sleep 2; done'
109+
110+ - name : Run integration tests
111+ run : |
112+ python -m pytest tests/integrate/ -v --tb=short --durations=10
113+ timeout-minutes : 15
114+
115+ - name : Stop server
116+ if : always()
117+ run : |
118+ if [ -f server.pid ]; then
119+ kill $(cat server.pid) || true
120+ rm server.pid
121+ fi
122+
123+ - name : Upload test results
124+ if : always()
125+ uses : actions/upload-artifact@v4
126+ with :
127+ name : test-results
128+ path : |
129+ pytest-report.html
130+ .pytest_cache/
131+ retention-days : 7
132+
133+ - name : Test Summary
134+ if : always()
135+ run : |
136+ echo "## Integration Test Results" >> $GITHUB_STEP_SUMMARY
137+ echo "Integration tests completed for Container Engine API" >> $GITHUB_STEP_SUMMARY
138+ if [ ${{ job.status }} == 'success' ]; then
139+ echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY
140+ else
141+ echo "❌ Some tests failed. Check the logs above." >> $GITHUB_STEP_SUMMARY
142+ fi
0 commit comments