mise en place des tests et test de workflows
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
node_modules/
|
||||
*.env
|
||||
Dockerfile
|
||||
.angular
|
||||
.idea
|
||||
.vscode
|
||||
coverage
|
||||
Docker*
|
||||
start.sh
|
||||
package-lock.json
|
||||
|
||||
32
.github/workflows/ci.yaml
vendored
Normal file
32
.github/workflows/ci.yaml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Docker Build Check
|
||||
|
||||
# Déclencheur pour chaque pull request
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# 1. Checkout du code source du dépôt
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# 2. Installation Node.js
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22.18' # Spécifie la version de Node.js
|
||||
|
||||
# 3. Installation des dépendances
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
# 4. Exécution des tests unitaires
|
||||
- name: Run tests
|
||||
run: npm run test:ci
|
||||
|
||||
# 5. CI terminée
|
||||
- name: CI completed
|
||||
run: echo "✅CI process completed successfully.✅"
|
||||
16
.github/workflows/main.yaml
vendored
16
.github/workflows/main.yaml
vendored
@@ -1,16 +0,0 @@
|
||||
name: Main Workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
- feat/*
|
||||
- fix/*
|
||||
|
||||
jobs:
|
||||
run-tests:
|
||||
uses: ./.github/workflows/tests/docker-build.yaml
|
||||
62
.github/workflows/tests/docker-build.yaml
vendored
62
.github/workflows/tests/docker-build.yaml
vendored
@@ -1,62 +0,0 @@
|
||||
name: Docker Build Check
|
||||
|
||||
# Déclencheur pour chaque pull request
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# 1. Checkout du code source du dépôt
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# 2. Configuration de QEMU pour le support multi-plateformes
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
# 3. Configuration de Docker Buildx pour la construction multi-arch
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
# 4. Test de la construction du Dockerfile pour les architectures amd64 et arm64
|
||||
- name: Build local container
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
tags: lastrea/trouvetonprofile:latest
|
||||
push: false
|
||||
platforms: linux/arm64
|
||||
load: true
|
||||
|
||||
# 5. Vérification de la taille de l'image construite
|
||||
- name: Check image size
|
||||
run: docker images lastrea/trouvetonprofile:latest --format "{{.Size}}"
|
||||
|
||||
# 6. Scan de l'image Docker pour détecter les vulnérabilités
|
||||
- name: Scan Image
|
||||
uses: anchore/scan-action@v3
|
||||
id: scan
|
||||
with:
|
||||
image: "lastrea/trouvetonprofile:latest"
|
||||
fail-build: true
|
||||
severity-cutoff: critical
|
||||
output-format: sarif
|
||||
|
||||
- name: Upload Anchore Scan SARIF Report
|
||||
uses: github/codeql-action/upload-sarif@v2
|
||||
with:
|
||||
sarif_file: ${{ steps.scan.outputs.sarif }}
|
||||
|
||||
# 7. Vérification si la construction et le scan ont réussi
|
||||
- name: Build and Scan verification
|
||||
if: ${{ success() }}
|
||||
run: echo "Dockerfile built and scanned successfully!"
|
||||
|
||||
# 8. Envoi d'un message d'échec en cas d'erreur lors de la construction ou du scan
|
||||
- name: Notify on failure
|
||||
if: ${{ failure() }}
|
||||
run: echo "The Dockerfile build or scan failed! Please review the changes."
|
||||
22
compose.yaml
22
compose.yaml
@@ -1,22 +0,0 @@
|
||||
volumes:
|
||||
pb_data:
|
||||
|
||||
networks:
|
||||
ttp-net:
|
||||
|
||||
services:
|
||||
pocketbase:
|
||||
image: ghcr.io/muchobien/pocketbase:latest
|
||||
container_name: pocketbase
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8090:8090
|
||||
networks:
|
||||
- ttp-net
|
||||
volumes:
|
||||
- pb_data:/pb_data
|
||||
healthcheck:
|
||||
test: wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
25
package-lock.json
generated
25
package-lock.json
generated
@@ -44,11 +44,13 @@
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^18.18.0",
|
||||
"@types/node-fetch": "^2.6.13",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"jasmine-core": "~5.1.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"jest-preset-angular": "^14.6.1",
|
||||
"node-fetch": "^2.7.0",
|
||||
"postcss": "^8.4.47",
|
||||
"tailwindcss": "^3.4.12",
|
||||
"typescript": "~5.2.2"
|
||||
@@ -5562,6 +5564,17 @@
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node-fetch": {
|
||||
"version": "2.6.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz",
|
||||
"integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^4.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node-forge": {
|
||||
"version": "1.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-forge/-/node-forge-1.3.13.tgz",
|
||||
@@ -13026,8 +13039,6 @@
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
@@ -13048,18 +13059,14 @@
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-fetch/node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/node-fetch/node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
@@ -13067,8 +13074,6 @@
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "trouve-ton-profile",
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
@@ -10,6 +10,7 @@
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:coverage": "jest --coverage",
|
||||
"test:ci": "jest --runInBand",
|
||||
"serve:ssr:TrouveTonProfile": "node dist/trouve-ton-profile/server/server.mjs"
|
||||
},
|
||||
"private": true,
|
||||
@@ -50,11 +51,13 @@
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^18.18.0",
|
||||
"@types/node-fetch": "^2.6.13",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"jasmine-core": "~5.1.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"jest-preset-angular": "^14.6.1",
|
||||
"node-fetch": "^2.7.0",
|
||||
"postcss": "^8.4.47",
|
||||
"tailwindcss": "^3.4.12",
|
||||
"typescript": "~5.2.2"
|
||||
|
||||
@@ -21,6 +21,7 @@ describe('LoginComponent', () => {
|
||||
mockToastrService = {
|
||||
warning: jest.fn(),
|
||||
success: jest.fn(),
|
||||
info: jest.fn(),
|
||||
error: jest.fn()
|
||||
};
|
||||
|
||||
@@ -41,6 +42,11 @@ describe('LoginComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// si le composant instancie subscriptions/timers
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
@@ -79,9 +85,9 @@ describe('LoginComponent', () => {
|
||||
|
||||
await component.login({email: 'fail@test.com', password: 'fail'});
|
||||
|
||||
expect(mockToastrService.warning).toHaveBeenCalledWith(
|
||||
expect(mockToastrService.info).toHaveBeenCalledWith(
|
||||
'Vous devez vérifier votre adresse e-mail avant de vous connecter.',
|
||||
'Erreur de connexion',
|
||||
'Information de connexion',
|
||||
{
|
||||
closeButton: true,
|
||||
progressAnimation: 'decreasing',
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
import { setupZoneTestEnv } from "jest-preset-angular/setup-env/zone";
|
||||
import * as fetch from 'node-fetch';
|
||||
|
||||
(global as any).fetch = fetch;
|
||||
(global as any).Headers = fetch.Headers;
|
||||
(global as any).Request = fetch.Request;
|
||||
(global as any).Response = fetch.Response;
|
||||
|
||||
setupZoneTestEnv();
|
||||
|
||||
Reference in New Issue
Block a user