Skip to content

feat: updating github action test to launch elk #242

feat: updating github action test to launch elk

feat: updating github action test to launch elk #242

Workflow file for this run

name: Run Cypress Tests
on:
pull_request:
branches:
- feat/clevercloud
- main
jobs:
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:16-alpine
env:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: jdma
ports:
- 5432:5432
mailhog:
image: mailhog/mailhog
ports:
- 8025:8025
- 1025:1025
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.1
env:
- discovery.type: single-node

Check failure on line 30 in .github/workflows/tests.yml

View workflow run for this annotation

GitHub Actions / Run Cypress Tests

Invalid workflow file

The workflow is not valid. .github/workflows/tests.yml (Line: 30, Col: 11): A sequence was not expected
- xpack.security.enabled: true
- ES_JAVA_OPTS: -Xms512m -Xmx512m
- ELASTIC_PASSWORD: ${{ secrets.ES_ADDON_PASSWORD }}
ports:
- 9200:9200
options: >-
--health-cmd="curl -s --insecure https://localhost:9200/_cluster/health || exit 1"
--health-interval=30s
--health-timeout=10s
--health-retries=5
steps:
# 1. Checkout du code
- name: Checkout code
uses: actions/checkout@v3
# 2. Copier le fichier .env.example vers .env
- name: Copy .env.example to .env
run: |
cp webapp-backoffice/.env.example webapp-backoffice/.env
cp webapp-form/.env.example webapp-form/.env
# 3. Configuration de Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: "yarn"
cache-dependency-path: |
webapp-backoffice/yarn.lock
webapp-form/yarn.lock
#4 Configurer l'environnement ElasticSearch
- name: Configure Elasticsearch environment
run: |
echo "ES_ADDON_URI=${{ secrets.ES_ADDON_URI }}" >> webapp-backoffice/.env
echo "ES_ADDON_USER=${{ secrets.ES_ADDON_USER }}" >> webapp-backoffice/.env
echo "ES_ADDON_PASSWORD=${{ secrets.ES_ADDON_PASSWORD }}" >> webapp-backoffice/.env
# 5. Installer les dépendances et générer le client Prisma pour `webapp-backoffice`
- name: Install dependencies and generate Prisma client for webapp-backoffice
run: |
cd webapp-backoffice
yarn install
npx prisma generate
npx prisma migrate reset --force
# 6. Installer les dépendances et générer le client Prisma pour `webapp-form`
- name: Install dependencies and generate Prisma client for webapp-form
run: |
cd webapp-form
yarn install
npx prisma generate
# 7. Construire `webapp-backoffice`
- name: Build webapp-backoffice
run: |
cd webapp-backoffice
yarn build
nohup yarn start &
# 8. Construire `webapp-form`
- name: Build webapp-form
run: |
cd webapp-form
yarn build
nohup yarn startB &
# 9. Attendre que les services soient prêts
- name: Wait for services to be ready
run: |
echo "Waiting for webapp-backoffice to be ready..."
until curl -s http://localhost:3000 > /dev/null; do echo "Waiting for webapp-backoffice..."; sleep 5; done
echo "Waiting for webapp-form to be ready..."
until curl -s http://localhost:3001 > /dev/null; do echo "Waiting for webapp-form..."; sleep 5; done
echo "Waiting for MailHog to be ready..."
until curl -s http://localhost:8025 > /dev/null; do echo "Waiting for MailHog..."; sleep 5; done
echo "Waiting for Elasticsearch to be ready..."
until curl -s --insecure https://localhost:9200/_cluster/health > /dev/null; do echo "Waiting for Elasticsearch..."; sleep 5; done
# 10. Exécuter les tests Cypress pour `webapp-backoffice`
- name: Run Cypress tests for webapp-backoffice
working-directory: ./webapp-backoffice
run: npx cypress run --spec "cypress/e2e/jdma/launcher.cy.js" --headed --browser chrome
# 11. Vérifier si MailHog reçoit les emails
- name: Check MailHog for received emails
run: curl http://localhost:8025/api/v2/messages
# 12. Arrêter les applications démarrées
- name: Stop applications
run: |
pkill -f "yarn start" || true
pkill -f "yarn startB" || true