Test/add test e2e #184
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: Main CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-backend: | |
name: Build Backend | |
uses: ./.github/workflows/build.yml | |
with: | |
image: ghcr.io/dnum-mi/referentiel-applications/backend | |
context: ./server | |
build-frontend: | |
name: Build Frontend | |
uses: ./.github/workflows/build.yml | |
with: | |
image: ghcr.io/dnum-mi/referentiel-applications/frontend | |
context: ./client | |
test-format: | |
name: Test Formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run Prettier check | |
run: | | |
npm ci | |
npm run format-check | |
test-e2e: | |
name: End-to-End Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checks-out repository | |
uses: actions/checkout@v4 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
check-latest: true | |
cache: "npm" | |
cache-dependency-path: "**/package-lock.json" | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Set timezone to 'Europe/Paris' for tests | |
run: sudo timedatectl set-timezone Europe/Paris | |
- name: Clean previous Cypress artifacts | |
run: | | |
rm -rf cypress/screenshots/ cypress/videos/ | |
- name: Install dependencies | |
run: | | |
pnpm install | |
npx cypress install | |
- name: Start application server | |
run: | | |
pnpm run start & | |
sleep 10 # Attendre que le serveur démarre correctement | |
- name: Wait for application server | |
run: | | |
while ! nc -z localhost 3000; do | |
echo "Waiting for server..." | |
sleep 2 | |
done | |
- name: Run Cypress tests | |
run: | | |
npx cypress run --headless --browser chrome | |
- name: Send artifacts | |
uses: actions/upload-artifact@v3 | |
if: ${{ failure() }} | |
with: | |
name: cypress-screenshots | |
path: | | |
cypress/screenshots/ | |
cypress/videos/ |