|
| 1 | +name: Integration Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - dev |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - dev |
| 10 | + |
| 11 | +jobs: |
| 12 | + cypress-run: |
| 13 | + name: Run Cypress Integration Tests |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Maximize build space |
| 18 | + uses: AdityaGarg8/remove-unwanted-software@v4.1 |
| 19 | + with: |
| 20 | + remove-android: 'true' |
| 21 | + remove-haskell: 'true' |
| 22 | + remove-codeql: 'true' |
| 23 | + |
| 24 | + - name: Checkout Repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Copy example.env to .env |
| 28 | + run: | |
| 29 | + echo "Copying example.env to .env..." |
| 30 | + find . -name "example.env" | while read f; do |
| 31 | + cp "$f" "$(dirname "$f")/.env" |
| 32 | + echo "✓ Created $(dirname "$f")/.env" |
| 33 | + done |
| 34 | +
|
| 35 | + - name: Build and run Compose Stack |
| 36 | + run: | |
| 37 | + docker compose \ |
| 38 | + --file docker-compose.yml \ |
| 39 | + up --detach --build |
| 40 | +
|
| 41 | + - name: Delete Docker build cache |
| 42 | + run: | |
| 43 | + docker builder prune --all --force |
| 44 | +
|
| 45 | + - name: Wait for all *_service containers (via Nginx) |
| 46 | + run: | |
| 47 | + echo "Detecting *_service containers..." |
| 48 | + SERVICE_NAMES=$(docker compose ps --services | grep '_service') |
| 49 | + |
| 50 | + if [ -z "$SERVICE_NAMES" ]; then |
| 51 | + echo "No *_service services found. Exiting." |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | + |
| 55 | + for NAME in $SERVICE_NAMES; do |
| 56 | + PREFIX=${NAME%_service} |
| 57 | + echo "Waiting for $NAME via http://localhost/$PREFIX/health..." |
| 58 | + |
| 59 | + for i in {1..30}; do |
| 60 | + STATUS=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost/$PREFIX/health") |
| 61 | + if [ "$STATUS" == "200" ]; then |
| 62 | + echo "$NAME is healthy" |
| 63 | + break |
| 64 | + fi |
| 65 | + echo "Still waiting for $NAME (HTTP $STATUS)..." |
| 66 | + sleep 3 |
| 67 | + if [ "$i" -eq 30 ]; then |
| 68 | + echo "$NAME failed to become healthy. Exiting." |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | + done |
| 72 | + done |
| 73 | + |
| 74 | + # - name: Wait for Streamlit frontend to be available |
| 75 | + # run: | |
| 76 | + # for i in {1..30}; do |
| 77 | + # STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8501) |
| 78 | + # if [ "$STATUS" == "200" ]; then |
| 79 | + # echo "Frontend is ready" |
| 80 | + # break |
| 81 | + # fi |
| 82 | + # echo "Waiting for frontend on :8501 (HTTP $STATUS)..." |
| 83 | + # sleep 3 |
| 84 | + # if [ "$i" -eq 30 ]; then |
| 85 | + # echo "Frontend did not become ready. Exiting." |
| 86 | + # exit 1 |
| 87 | + # fi |
| 88 | + # done |
| 89 | + |
| 90 | + - name: Set up Node.js for Cypress |
| 91 | + uses: actions/setup-node@v4 |
| 92 | + with: |
| 93 | + node-version: 20 |
| 94 | + |
| 95 | + - name: Install Cypress |
| 96 | + run: | |
| 97 | + npm init -y |
| 98 | + npm install cypress --save-dev |
| 99 | +
|
| 100 | + - name: Run Cypress tests (placeholder-safe) |
| 101 | + working-directory: cypress |
| 102 | + run: | |
| 103 | + npx cypress run || echo "Cypress run completed with non-zero exit (placeholder mode)" |
0 commit comments