|
1 | | -name: 'Lancer les Tests Backend et Frontend' |
| 1 | +name: 'Tests Backend et Frontend' |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request: |
|
9 | 9 | - dev |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - test-backend-frontend: |
| 12 | + test-backend: |
| 13 | + name: 'Tests Backend' |
13 | 14 | runs-on: ubuntu-latest |
14 | | - strategy: |
15 | | - matrix: |
16 | | - node-version: [18] # adapte selon la version Node de ton projet |
| 15 | + |
| 16 | + services: |
| 17 | + mongodb: |
| 18 | + image: mongo:7 |
| 19 | + ports: |
| 20 | + - 27017:27017 |
17 | 21 |
|
18 | 22 | steps: |
19 | 23 | - name: 'Checkout code' |
20 | | - uses: actions/checkout@v3 |
| 24 | + uses: actions/checkout@v4 |
21 | 25 |
|
22 | 26 | - name: 'Setup Node.js' |
23 | | - uses: actions/setup-node@v3 |
| 27 | + uses: actions/setup-node@v4 |
24 | 28 | with: |
25 | | - node-version: 20.9.0 |
| 29 | + node-version: '20' |
| 30 | + cache: 'npm' |
| 31 | + cache-dependency-path: saintBarthVolleyApp/backend/package-lock.json |
26 | 32 |
|
27 | | - # ---------------------- |
28 | | - # Backend |
29 | | - # ---------------------- |
30 | | - - name: 'Installer les dépendances backend' |
31 | | - run: | |
32 | | - echo "Installation des dépendances backend" |
33 | | - cd saintBarthVolleyApp/backend |
34 | | - npm install |
| 33 | + - name: 'Installer les dépendances' |
| 34 | + run: npm ci |
| 35 | + working-directory: saintBarthVolleyApp/backend |
35 | 36 |
|
36 | 37 | - name: 'Lancer les tests backend' |
37 | | - run: | |
38 | | - echo "Lancement des tests backend" |
39 | | - cd saintBarthVolleyApp/backend |
40 | | - npm test |
| 38 | + run: npm test |
| 39 | + working-directory: saintBarthVolleyApp/backend |
| 40 | + env: |
| 41 | + NODE_ENV: test |
| 42 | + MONGO_URI: mongodb://localhost:27017/sbv_test |
| 43 | + JWT_SECRET: test_secret_ci |
| 44 | + PORT: 5000 |
| 45 | + |
| 46 | + test-frontend: |
| 47 | + name: 'Build Frontend (vérification)' |
| 48 | + runs-on: ubuntu-latest |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: 'Checkout code' |
| 52 | + uses: actions/checkout@v4 |
41 | 53 |
|
42 | | - # ---------------------- |
43 | | - # Frontend |
44 | | - # ---------------------- |
45 | | - - name: 'Installer les dépendances frontend' |
46 | | - run: | |
47 | | - echo "Installation des dépendances frontend" |
48 | | - cd saintBarthVolleyApp/frontend |
49 | | - npm install |
| 54 | + - name: 'Setup Node.js' |
| 55 | + uses: actions/setup-node@v4 |
| 56 | + with: |
| 57 | + node-version: '20' |
| 58 | + cache: 'npm' |
| 59 | + cache-dependency-path: saintBarthVolleyApp/frontend/package-lock.json |
50 | 60 |
|
51 | | - - name: 'Lancer les tests frontend' |
52 | | - run: | |
53 | | - echo "Lancement des tests frontend" |
54 | | - cd saintBarthVolleyApp/frontend |
55 | | - npm test |
| 61 | + - name: 'Installer les dépendances' |
| 62 | + run: npm ci |
| 63 | + working-directory: saintBarthVolleyApp/frontend |
56 | 64 |
|
57 | | - # ---------------------- |
58 | | - # Optional: build frontend |
59 | | - # ---------------------- |
60 | | - - name: 'Build frontend pour vérification' |
61 | | - run: | |
62 | | - echo "Building du frontend" |
63 | | - cd saintBarthVolleyApp/frontend |
64 | | - npm run build || { echo "❌ Build frontend échoué"; exit 1; } |
| 65 | + - name: 'Build Next.js' |
| 66 | + run: npm run build |
| 67 | + working-directory: saintBarthVolleyApp/frontend |
| 68 | + env: |
| 69 | + # Pas de basePath en CI, pas besoin de l'URL de prod |
| 70 | + NEXT_BASE_PATH: '' |
| 71 | + NEXT_PUBLIC_API_URL: '' |
0 commit comments