✅ add end to end test in CI #1
This file contains 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: End-to-End Test | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
e2e-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Copy .env.docker to .env | |
run: cp .env.docker .env | |
- name: Install Docker Compose | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
- name: Build and start services | |
run: docker-compose up -d --build | |
- name: Wait for services to be ready | |
run: | | |
timeout 60s bash -c 'until curl -s http://localhost:8080 > /dev/null; do sleep 1; done' | |
sleep 10 # Additional wait time for other services to initialize | |
- name: Run end-to-end test | |
run: | | |
docker-compose exec -T user-cli /bin/sh -c "cargo test --test e2e_test -- --nocapture" | |
- name: Collect logs | |
if: always() | |
run: docker-compose logs > docker-compose-logs.txt | |
- name: Upload logs | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: docker-compose-logs | |
path: docker-compose-logs.txt | |
- name: Stop services | |
if: always() | |
run: docker-compose down |