From a4788c080cdc581a88fe1edfd7116cd87f482e9a Mon Sep 17 00:00:00 2001 From: soleil00 Date: Tue, 16 Apr 2024 10:31:51 +0200 Subject: [PATCH] chore : Set up Tests locally & implement Continuous Integration --- .github/workflows/deploy.yml | 51 ++++++++++++++++++++++++++++++++++ README.md | 17 ++++++++++++ jest.config.js | 11 ++++++++ package.json | 2 +- src/sequelize/config/config.js | 18 ++++++++++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 jest.config.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f680579 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,51 @@ +name: Eagle e-commerce CI/CD + +on: + push: + branches: + - main + - dev + + pull_request: + branches: + - main + - dev + + workflow_dispatch: + +jobs: + build: + name: Building code + runs-on: ubuntu-latest + + steps: + - name: Checkout the code + uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: "20" + + - name: Install dependencies + run: npm install + + - name: Running test + env: + DB_CONNECTION: ${{ secrets.DB_CONNECTION }} + run: npm run test + + - name: Build application + run: npm run build + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: soleil00/eagles-ec-be + + - name: Trigger Render Deployment + env: + RENDER_DEPLOYMENT_HOOK_URL: ${{ secrets.RENDER_DEPLOYMENT_HOOK_URL }} + run: | + curl -X POST $RENDER_DEPLOYMENT_HOOK_URL diff --git a/README.md b/README.md index 205a536..21b6478 100644 --- a/README.md +++ b/README.md @@ -1 +1,18 @@ # eagles-ec-be + +
+ Codecov + GitHub Actions Workflow Status + + + +
+ +### Technology used + +![Node.js](https://img.shields.io/badge/-Node.js-000000?style=flat&logo=node.js) +[![Passport.js](https://img.shields.io/badge/auth%20library-Passport.js-green)](http://www.passportjs.org/) +[![PostgreSQL](https://img.shields.io/badge/database-PostgreSQL-blue)](https://www.postgresql.org/) +[![Sequelize](https://img.shields.io/badge/ORM-Sequelize-orange)](https://sequelize.org/) +[![Jest](https://img.shields.io/badge/testing-Jest-red)](https://jestjs.io/) +[![ESLint](https://img.shields.io/badge/code%20style-ESLint-blueviolet)](https://eslint.org/) diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..36e4760 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,11 @@ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + preset: "ts-jest", + testEnvironment: "node", + testMatch: ["**/**/*.test.ts"], + verbose: true, + forceExit: true, + clearMocks: true, + resetMocks: true, + restoreMocks: true, +}; diff --git a/package.json b/package.json index b459380..f6b4824 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "seed": "npx sequelize-cli db:seed:all", "lint": "npx eslint .", "lint:fix": "npx eslint --fix .", - "test": " npm run lint && jest --detectOpenHandles --coverage" + "test": "jest --detectOpenHandles --coverage" }, "author": "atlp", "license": "MIT", diff --git a/src/sequelize/config/config.js b/src/sequelize/config/config.js index cb08438..bded937 100644 --- a/src/sequelize/config/config.js +++ b/src/sequelize/config/config.js @@ -5,13 +5,31 @@ module.exports = { development: { url: process.env.DB_CONNECTION, dialect: "postgres", + dialectOptions: { + ssl: { + require: true, + rejectUnauthorized: false, + }, + }, }, test: { url: process.env.DB_CONNECTION, dialect: "postgres", + dialectOptions: { + ssl: { + require: true, + rejectUnauthorized: false, + }, + }, }, production: { url: process.env.DB_CONNECTION, dialect: "postgres", + dialectOptions: { + ssl: { + require: true, + rejectUnauthorized: false, + }, + }, }, };