diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b558407..9885568 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -40,8 +40,10 @@ Specify if any documentation updates are required and provide details on what ne [![Request Review on PR Open](https://github.com/kleostro/tu-tu/actions/workflows/request_review.yml/badge.svg)](https://github.com/kleostro/tu-tu/actions/workflows/request_review.yml) - [x] The labels have been added ๐ŸŽจ [![Pull Request Labeler](https://github.com/kleostro/tu-tu/actions/workflows/labeler.yml/badge.svg)](https://github.com/kleostro/tu-tu/actions/workflows/labeler.yml) -- [x] My code doesn't generate any errors or warnings โ›“๏ธ - [![Continuous Integration](https://github.com/kleostro/tu-tu/actions/workflows/ci.yml/badge.svg)](https://github.com/kleostro/tu-tu/actions/workflows/ci.yml) +- [x] My code doesn't generate any errors or warnings โš ๏ธ + [![Code Formatter](https://github.com/kleostro/tu-tu/actions/workflows/format.yml/badge.svg)](https://github.com/kleostro/tu-tu/actions/workflows/format.yml) +- [x] My code passes all tests ๐Ÿงช + [![Test](https://github.com/kleostro/tu-tu/actions/workflows/test.yml/badge.svg)](https://github.com/kleostro/tu-tu/actions/workflows/test.yml) - [x] My code builds successfully โš™๏ธ [![Netlify Status](https://api.netlify.com/api/v1/badges/9704b9db-b410-40b1-8d2b-2eeed828626e/deploy-status)](https://app.netlify.com/sites/mad-wizards-tu-tu/deploys) diff --git a/.github/workflows/ci.yml b/.github/workflows/format.yml similarity index 56% rename from .github/workflows/ci.yml rename to .github/workflows/format.yml index fe39afa..8bb7702 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/format.yml @@ -1,4 +1,4 @@ -name: Continuous Integration +name: Format on: pull_request: @@ -26,20 +26,3 @@ jobs: - name: Format code with Prettier run: npm run ci:format - - test: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Install dependencies - run: npm install - - - name: Run Jest tests - run: npm test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3b82f72 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Test + +on: + pull_request: + types: [opened] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Run Jest tests + run: npm test + + - name: Generate coverage report + run: npm run test:coverage diff --git a/.husky/pre-commit b/.husky/pre-commit index d17b96c..5458781 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -29,4 +29,4 @@ run_tsc () { run_linter run_tsc -printf "${BASIC_GREEN} โœ” All checks passed. Happy coding${ENDCOLOR}!\n" \ No newline at end of file +printf "${BASIC_GREEN} โœ” All checks have passed. Happy coding!${ENDCOLOR}\n" \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push index 8bb222b..06c23b6 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1 +1,30 @@ -npx validate-branch-name \ No newline at end of file +#!/bin/bash + +BASIC_RED="\e[0;31m" +BASIC_GREEN="\e[0;32m" +BASIC_CYAN="\e[0;36m" +ENDCOLOR="\e[0m" + +run_branch_name_validation () { + echo -e "${BASIC_CYAN}Validating branch name${ENDCOLOR}" + npx validate-branch-name + if [[ $? -ne 0 ]] + then + exit 1 + fi +} + +run_tests () { + echo -e "${BASIC_CYAN}Running tests${ENDCOLOR}" + npm run test + if [[ $? -ne 0 ]] + then + echo -e "${BASIC_RED}Tests failed. Please fix the errors and try again.${ENDCOLOR}" + exit 1 + fi +} + +run_branch_name_validation +run_tests + +printf "${BASIC_GREEN} โœ” All checks have passed. Happy coding!${ENDCOLOR}\n" diff --git a/jest.config.ts b/jest.config.ts index c7f45b3..859b5fa 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -6,7 +6,7 @@ import type { Config } from 'jest'; const config: Config = { moduleDirectories: ['node_modules', ''], - transformIgnorePatterns: ['node_modules/(?!@angular|rxjs|@ngrx)'], + transformIgnorePatterns: ['node_modules/(?!@angular|rxjs|@ngrx)', '/dist'], clearMocks: true, collectCoverage: true, coverageDirectory: 'coverage', @@ -17,6 +17,7 @@ const config: Config = { moduleNameMapper: { '^src/(.*)$': '/src/$1', }, + testPathIgnorePatterns: ['/dist/', 'dist'], }; export default config;