From 059ff66330cccda54041727963d581fd33f24d1e Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Thu, 25 Apr 2024 16:14:16 +0200 Subject: [PATCH 01/15] ft(CI):create workflow file -we are creating workflow file -we are runing test,linting and build for the workflow -right now we are not run deployment. story id: #17 --- .github/workflows/workflow_for_ecomm.yml | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/workflow_for_ecomm.yml diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml new file mode 100644 index 00000000..2eebd5bb --- /dev/null +++ b/.github/workflows/workflow_for_ecomm.yml @@ -0,0 +1,38 @@ +name: CI for ecomm-project for Dynamite + +on: + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + +jobs: + build: + #git hub offer virtual machines to run workflows so we will be using ubuntu lastest version its standand one + #we using ubuntu because we want to use lunex terminal + runs-on: ubuntu-latest + + strategy: + matrix: + #each version we specify we be tested on + #we are only limited to 3 versions + node-version: [16.x, 18.x, 20.x] + + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} #this will help use know which version we are testing on. + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs + - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster + - run: npm test #this line will run test script + - name: linting using GitHub Super Linter + uses: super-linter/super-linter@v6.4. #we giong to use the linter to check the issues in code before build but after test + env: + VALIDATE_ALL_CODEBASE: false #will check the linking for only new or edited files + DEFAULT_BRANCH: develop #this state the default branch + DISABLE_ERRORS: true #this will prevent the CI to fail because the linter fail only N.B this if because its first time using this linter after some time i will change true to farse + - run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json + \ No newline at end of file From d16f2ba9e1e87f9449d8cc9ceba8217491757a43 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Thu, 25 Apr 2024 16:39:54 +0200 Subject: [PATCH 02/15] bug(CI):change super linter version -i changed the version of github super linter to latest version #17 --- .github/workflows/workflow_for_ecomm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index 2eebd5bb..71a3767d 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -29,7 +29,7 @@ jobs: - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster - run: npm test #this line will run test script - name: linting using GitHub Super Linter - uses: super-linter/super-linter@v6.4. #we giong to use the linter to check the issues in code before build but after test + uses: super-linter/super-linter@v6.4.1 #we giong to use the linter to check the issues in code before build but after test env: VALIDATE_ALL_CODEBASE: false #will check the linking for only new or edited files DEFAULT_BRANCH: develop #this state the default branch From 615b44c2464e2025a5236dedb20c55853360d64a Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Thu, 25 Apr 2024 16:45:54 +0200 Subject: [PATCH 03/15] bug(ci):add if statement on run test line -the script run test is not present in packege.json -if not present pass it with no error #17 --- .github/workflows/workflow_for_ecomm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index 71a3767d..ca4c4ee7 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -27,7 +27,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster - - run: npm test #this line will run test script + - run: npm test --if-present #this line will run test script - name: linting using GitHub Super Linter uses: super-linter/super-linter@v6.4.1 #we giong to use the linter to check the issues in code before build but after test env: From 40f122d45bd692f4a701aa50d3218aded7a3e9e5 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Thu, 25 Apr 2024 16:50:34 +0200 Subject: [PATCH 04/15] bg(ci):add git token _super linter new git token to report the status #17 --- .github/workflows/workflow_for_ecomm.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index ca4c4ee7..9a00aa3a 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -31,6 +31,7 @@ jobs: - name: linting using GitHub Super Linter uses: super-linter/super-linter@v6.4.1 #we giong to use the linter to check the issues in code before build but after test env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_ALL_CODEBASE: false #will check the linking for only new or edited files DEFAULT_BRANCH: develop #this state the default branch DISABLE_ERRORS: true #this will prevent the CI to fail because the linter fail only N.B this if because its first time using this linter after some time i will change true to farse From e1e7198ea80b25b4e9f25120926291b78dd2b8fe Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Thu, 25 Apr 2024 17:02:07 +0200 Subject: [PATCH 05/15] bug(ci): change the run lint line - am nolonger using super linter #17 --- .github/workflows/workflow_for_ecomm.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index 9a00aa3a..d5e96260 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -28,12 +28,6 @@ jobs: cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster - run: npm test --if-present #this line will run test script - - name: linting using GitHub Super Linter - uses: super-linter/super-linter@v6.4.1 #we giong to use the linter to check the issues in code before build but after test - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_ALL_CODEBASE: false #will check the linking for only new or edited files - DEFAULT_BRANCH: develop #this state the default branch - DISABLE_ERRORS: true #this will prevent the CI to fail because the linter fail only N.B this if because its first time using this linter after some time i will change true to farse + - run: npm run lint --if-present - run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json \ No newline at end of file From 2e2db15a15af4c40cca633b4b3196c292f1b2ea4 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Thu, 25 Apr 2024 17:31:57 +0200 Subject: [PATCH 06/15] bug(ci):chnage run test - i have changed npm test to -npm runtest #17 --- .github/workflows/workflow_for_ecomm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index d5e96260..aa789d2f 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -27,7 +27,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster - - run: npm test --if-present #this line will run test script + - run: npm run test --if-present #this line will run test script - run: npm run lint --if-present - run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json \ No newline at end of file From d1a43547358b2facf5ff872525f8c27fcea65449 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Mon, 29 Apr 2024 18:58:23 +0200 Subject: [PATCH 07/15] fix(backend):upload coverage to coverolls -we are adding the script to help upload the coverage #17 --- .github/workflows/workflow_for_ecomm.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index aa789d2f..3eb9cacb 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -30,4 +30,8 @@ jobs: - run: npm run test --if-present #this line will run test script - run: npm run lint --if-present - run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json - \ No newline at end of file + - run: npm run test:ci --if-present # this will run test with coverage flag + + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 + \ No newline at end of file From 137c8bc7bf92654d3ca3c05e0aa6168e22e70a65 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Mon, 29 Apr 2024 19:20:11 +0200 Subject: [PATCH 08/15] fix:check if the coverage works --- .github/workflows/workflow_for_ecomm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index 3eb9cacb..e8248747 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -28,7 +28,7 @@ jobs: cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster - run: npm run test --if-present #this line will run test script - - run: npm run lint --if-present + #- run: npm run lint --if-present - run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json - run: npm run test:ci --if-present # this will run test with coverage flag From 51886ba0d9f3febc35e737ab5fd770ff3b660986 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Mon, 29 Apr 2024 19:41:32 +0200 Subject: [PATCH 09/15] fix:allow coverage empty --- .github/workflows/workflow_for_ecomm.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index e8248747..faca6b46 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -34,4 +34,5 @@ jobs: - name: Upload coverage to Coveralls uses: coverallsapp/github-action@v2 - \ No newline at end of file + with: + allow-empty: true \ No newline at end of file From 566f83de3559f2731b84171f9a06c9cd0c1cf976 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Mon, 29 Apr 2024 19:50:16 +0200 Subject: [PATCH 10/15] fix: now test coverage with the lint --- .github/workflows/workflow_for_ecomm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index faca6b46..50bad5e1 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -28,7 +28,7 @@ jobs: cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster - run: npm run test --if-present #this line will run test script - #- run: npm run lint --if-present + - run: npm run lint --if-present - run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json - run: npm run test:ci --if-present # this will run test with coverage flag From 8e54d268bb4d10f05950a5b2b4802becec4005b8 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Tue, 30 Apr 2024 10:20:23 +0200 Subject: [PATCH 11/15] fix: come back to coomit with no confict fix: lint From 54ab9bfe8b36eb645a234f95b2600e94f6e3eac8 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Tue, 30 Apr 2024 12:36:06 +0200 Subject: [PATCH 12/15] fix: fix all bugs - the env file was created -env file contain all need valiables #17 --- .github/workflows/workflow_for_ecomm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index 50bad5e1..d85c3ab1 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -28,7 +28,7 @@ jobs: cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster - run: npm run test --if-present #this line will run test script - - run: npm run lint --if-present + - run: npm run lint --if-present # run tle linting - run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json - run: npm run test:ci --if-present # this will run test with coverage flag From 733bdaa3141db62507bb67096c2e5fe827a90396 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Tue, 30 Apr 2024 13:28:32 +0200 Subject: [PATCH 13/15] fix: change the env valiable #17 --- .github/workflows/workflow_for_ecomm.yml | 2 +- src/app.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workflow_for_ecomm.yml b/.github/workflows/workflow_for_ecomm.yml index d85c3ab1..274db453 100644 --- a/.github/workflows/workflow_for_ecomm.yml +++ b/.github/workflows/workflow_for_ecomm.yml @@ -28,7 +28,7 @@ jobs: cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs - run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster - run: npm run test --if-present #this line will run test script - - run: npm run lint --if-present # run tle linting + - run: npm run lint --if-present # run tle - run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json - run: npm run test:ci --if-present # this will run test with coverage flag diff --git a/src/app.ts b/src/app.ts index f49e9ce0..537f6b52 100644 --- a/src/app.ts +++ b/src/app.ts @@ -32,11 +32,11 @@ app.get('/', (req: Request, res: Response) => { }); // Middleware to handle all endpoint routes -app.use(process.env.ALL as string, route); +app.use('/api/v1', route); // Endpoint for serving Swagger documentation app.use( - process.env.DOCS as string, + '/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec) ); From 108d7eb7a087cd680d7c1b52303fecc4124c314f Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Tue, 30 Apr 2024 13:41:23 +0200 Subject: [PATCH 14/15] fix: change the linking --- src/controller/user.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controller/user.ts b/src/controller/user.ts index febc0bc5..a85998b2 100644 --- a/src/controller/user.ts +++ b/src/controller/user.ts @@ -3,7 +3,13 @@ import {User} from '../database/models'; const userRepository = dbConnection.getRepository(User) -export const createUser = async(data:any) => { +interface UserData { + firstName: string; + lastName: string; + age: number; + } + +export const createUser = async(data: UserData) => { const user = new User() user.firstName = data.firstName user.lastName = data.lastName From dd68de2b629bb563a36cb3963fbc78932a5d59b4 Mon Sep 17 00:00:00 2001 From: niyibi250 Date: Tue, 30 Apr 2024 13:43:55 +0200 Subject: [PATCH 15/15] fix: linting --- src/database/models/user.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database/models/user.ts b/src/database/models/user.ts index aa46d723..5fa1058a 100644 --- a/src/database/models/user.ts +++ b/src/database/models/user.ts @@ -1,4 +1,4 @@ -import { Entity, PrimaryGeneratedColumn, Column } from "typeorm" +import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm' @Entity() export class User {