diff --git a/.github/workflows/jest-test.yml b/.github/workflows/jest-test.yml new file mode 100644 index 0000000..778af5f --- /dev/null +++ b/.github/workflows/jest-test.yml @@ -0,0 +1,90 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Tests Jest & Couverture + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "dev" ] + +jobs: + test: + name: Tests et Couverture + runs-on: ubuntu-22.04 + + strategy: + matrix: + node-version: [20.x] + fail-fast: false + + steps: + - name: Checkout du code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configuration de Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Cache des dépendances + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Installation des dépendances + run: | + npm ci + npm install -g jest + + - name: Exécution des tests + run: npm test -- --coverage --ci --testLocationInResults --json --outputFile=jest-results.json + continue-on-error: true + + - name: Vérification du seuil de couverture + run: | + COVERAGE=$(cat coverage/coverage-summary.json| jq -r '.total.lines.pct') + echo "Couverture actuelle : $COVERAGE%" + if (( $(echo "$COVERAGE < 80" | bc -l) )); then + echo "La couverture de code est inférieure à 80% ($COVERAGE%)" + exit 1 + else + echo "✅ La couverture de code est supérieure à 80% ($COVERAGE%)" + fi + + + + - name: Upload des résultats de test + uses: actions/upload-artifact@v4 + with: + name: test-results + path: | + jest-results.json + coverage/ + + - name: Publication sur Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: 223MapAction/app.Dashboard + file: ./coverage/coverage-summary.json + flags: unittests + name: codecov-umbrella + fail_ci_if_error: true + verbose: true + + - name: Commentaire sur la PR avec la couverture + if: github.event_name == 'pull_request' + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage/coverage-summary.json + flags: unittests + fail_ci_if_error: false diff --git a/public/index.html b/public/index.html index f86fb84..d86d6c1 100755 --- a/public/index.html +++ b/public/index.html @@ -79,7 +79,7 @@ integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin="" > - +