Skip to content

Commit 9384c04

Browse files
authored
Merge pull request #4 from ngocbd/main
Update integration-tests.yml
2 parents e9f5f74 + cc0f5d3 commit 9384c04

59 files changed

Lines changed: 5222 additions & 49 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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: Build Rust application
77+
run: cargo build --verbose
78+
79+
- name: Set up test environment
80+
run: |
81+
# Set environment variables for the application
82+
echo "DATABASE_URL=postgresql://postgres:password@localhost:5432/container_engine_test" >> $GITHUB_ENV
83+
echo "REDIS_URL=redis://localhost:6379" >> $GITHUB_ENV
84+
echo "PORT=3000" >> $GITHUB_ENV
85+
echo "JWT_SECRET=test-jwt-secret-key-for-github-actions" >> $GITHUB_ENV
86+
echo "JWT_EXPIRES_IN=3600" >> $GITHUB_ENV
87+
echo "API_KEY_PREFIX=ce_test_" >> $GITHUB_ENV
88+
echo "KUBERNETES_NAMESPACE=test" >> $GITHUB_ENV
89+
echo "DOMAIN_SUFFIX=test.local" >> $GITHUB_ENV
90+
echo "RUST_LOG=container_engine=info,tower_http=info" >> $GITHUB_ENV
91+
92+
- name: Run database migrations
93+
run: |
94+
sqlx migrate run --database-url postgresql://postgres:password@localhost:5432/container_engine_test
95+
96+
- name: Start Container Engine server in background
97+
run: |
98+
cargo run &
99+
echo $! > server.pid
100+
101+
# Wait for server to be ready
102+
timeout 60 bash -c 'until curl -f http://localhost:3000/health; do sleep 2; done'
103+
104+
- name: Run integration tests
105+
run: |
106+
python -m pytest tests/integrate/ -v --tb=short --durations=10
107+
timeout-minutes: 15
108+
109+
- name: Stop server
110+
if: always()
111+
run: |
112+
if [ -f server.pid ]; then
113+
kill $(cat server.pid) || true
114+
rm server.pid
115+
fi
116+
117+
- name: Upload test results
118+
if: always()
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: test-results
122+
path: |
123+
pytest-report.html
124+
.pytest_cache/
125+
retention-days: 7
126+
127+
- name: Test Summary
128+
if: always()
129+
run: |
130+
echo "## Integration Test Results" >> $GITHUB_STEP_SUMMARY
131+
echo "Integration tests completed for Container Engine API" >> $GITHUB_STEP_SUMMARY
132+
if [ ${{ job.status }} == 'success' ]; then
133+
echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY
134+
else
135+
echo "❌ Some tests failed. Check the logs above." >> $GITHUB_STEP_SUMMARY
136+
fi

.gitignore

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,55 @@ dump.rdb
3434
.dockerignore
3535

3636
# Kubernetes
37-
*.kubeconfig
37+
*.kubeconfig
38+
39+
# Python
40+
__pycache__/
41+
*.py[cod]
42+
*$py.class
43+
*.so
44+
.Python
45+
build/
46+
develop-eggs/
47+
dist/
48+
downloads/
49+
eggs/
50+
.eggs/
51+
lib/
52+
lib64/
53+
parts/
54+
sdist/
55+
var/
56+
wheels/
57+
*.egg-info/
58+
.installed.cfg
59+
*.egg
60+
MANIFEST
61+
62+
# Testing
63+
.pytest_cache/
64+
.coverage
65+
htmlcov/
66+
.tox/
67+
.nox/
68+
.coverage.*
69+
pytest-report.html
70+
.cache
71+
nosetests.xml
72+
coverage.xml
73+
*.cover
74+
.hypothesis/
75+
76+
# Virtual environments
77+
.env
78+
.venv
79+
env/
80+
venv/
81+
ENV/
82+
env.bak/
83+
venv.bak/
84+
85+
# Test artifacts
86+
tests/.env.test.local
87+
tests/test-results/
88+
tests/artifacts/

.sqlx/query-0ba88a1b78cd18a82c419957c84ce56db021bab1b8551229a0c1f38be1eded0b.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-11d6340896362a877d965789467e2d2464a069c5ba80196daadcd7cb9971f320.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-1eb66bd0aac43ccad4e95cd8ba9339ab8632f0b11abfe60ae6b1042b58c53398.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-324db57df1629aedb2fccccbea66cd883f5b5a6423619041266ea8ed2a9f5d03.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-418ecaef4e8144de092974ac916d4cd62cf1ad745507e4f266a4b63de3d52333.json

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)