From a384d189737a8aff9f7a4291f23848a6a68b381a Mon Sep 17 00:00:00 2001 From: Tomas Scandalitta <38343557+tscandalitta@users.noreply.github.com> Date: Sat, 11 Jun 2022 18:16:06 -0300 Subject: [PATCH 01/13] Update deploy_to_test.yml --- .github/workflows/deploy_to_test.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/deploy_to_test.yml b/.github/workflows/deploy_to_test.yml index 057a535..1272fc2 100644 --- a/.github/workflows/deploy_to_test.yml +++ b/.github/workflows/deploy_to_test.yml @@ -39,18 +39,3 @@ jobs: apiKey: ${{ secrets.POSTMAN_API_KEY }} collection: ${{ secrets.POSTMAN_COLLECTION }} environment: ${{ secrets.POSTMAN_ENVIRONMENT }} - - - name: Merge test -> main - uses: devmasx/merge-branch@master - with: - type: now - from_branch: test - target_branch: main - github_token: ${{ github.token }} - - - uses: HiromiShikata/gh-actions-move-all-cards-on-projects@v1.0.1 - with: - project_name: Features - from_column_name: Desplegado en Testing - to_column_name: Desplegado en Produccion - github_token: ${{ secrets.GHTOKEN }} From b8854d9a555f160cd53d6adbfb6e62fe87f901a7 Mon Sep 17 00:00:00 2001 From: Tomas Scandalitta <38343557+tscandalitta@users.noreply.github.com> Date: Sat, 11 Jun 2022 18:19:04 -0300 Subject: [PATCH 02/13] Create deploy_to_production.yml --- .github/workflows/deploy_to_production.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/deploy_to_production.yml diff --git a/.github/workflows/deploy_to_production.yml b/.github/workflows/deploy_to_production.yml new file mode 100644 index 0000000..9f50303 --- /dev/null +++ b/.github/workflows/deploy_to_production.yml @@ -0,0 +1,22 @@ +name: Deploy a produccion + +on: [workflow_dispatch] + +jobs: + merge-and-deploy-to-production: + runs-on: ubuntu-latest + steps: + - name: Merge test -> main + uses: devmasx/merge-branch@master + with: + type: now + from_branch: test + target_branch: main + github_token: ${{ github.token }} + + - uses: HiromiShikata/gh-actions-move-all-cards-on-projects@v1.0.1 + with: + project_name: Features + from_column_name: Desplegado en Testing + to_column_name: Desplegado en Produccion + github_token: ${{ secrets.GHTOKEN }} From 5888bf1a8d4492715e214d93fb588df1eef5cdc3 Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Sat, 11 Jun 2022 18:23:48 -0300 Subject: [PATCH 03/13] add deploy to prod --- .github/workflows/deploy_to_production.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/deploy_to_production.yml b/.github/workflows/deploy_to_production.yml index 9f50303..090ce42 100644 --- a/.github/workflows/deploy_to_production.yml +++ b/.github/workflows/deploy_to_production.yml @@ -13,6 +13,16 @@ jobs: from_branch: test target_branch: main github_token: ${{ github.token }} + + - run: npm ci + - run: npm run build --if-present + + - name: Build, Push and Release a Docker container to Heroku. + uses: gonuit/heroku-docker-deploy@v1.3.3 + with: + email: ${{ secrets.HEROKU_EMAIL }} + heroku_api_key: ${{ secrets.HEROKU_API_KEY }} + heroku_app_name: ${{ secrets.HEROKU_APP_NAME_MAIN }} - uses: HiromiShikata/gh-actions-move-all-cards-on-projects@v1.0.1 with: From 14280e88cfb34295fd3beb5cc62c43323f27ceb9 Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Sat, 11 Jun 2022 18:25:41 -0300 Subject: [PATCH 04/13] add deploy to prod --- .github/workflows/deploy_to_production.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_to_production.yml b/.github/workflows/deploy_to_production.yml index 090ce42..475ed6d 100644 --- a/.github/workflows/deploy_to_production.yml +++ b/.github/workflows/deploy_to_production.yml @@ -14,8 +14,8 @@ jobs: target_branch: main github_token: ${{ github.token }} - - run: npm ci - - run: npm run build --if-present + #- run: npm ci + #- run: npm run build --if-present - name: Build, Push and Release a Docker container to Heroku. uses: gonuit/heroku-docker-deploy@v1.3.3 From 26c967510adf61a198c4d52ff9427cfd30994d74 Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Sat, 11 Jun 2022 18:27:10 -0300 Subject: [PATCH 05/13] Change something to trigger again deploy --- .github/workflows/deploy_to_production.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy_to_production.yml b/.github/workflows/deploy_to_production.yml index 475ed6d..3ab1c3f 100644 --- a/.github/workflows/deploy_to_production.yml +++ b/.github/workflows/deploy_to_production.yml @@ -13,6 +13,8 @@ jobs: from_branch: test target_branch: main github_token: ${{ github.token }} + + - uses: actions/checkout@v3 #- run: npm ci #- run: npm run build --if-present From fc5735a68c2fe12be91525985b1da4adc04e7a50 Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Sat, 11 Jun 2022 18:31:00 -0300 Subject: [PATCH 06/13] remove unncesary lines --- .github/workflows/deploy_to_production.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy_to_production.yml b/.github/workflows/deploy_to_production.yml index 3ab1c3f..4414a1e 100644 --- a/.github/workflows/deploy_to_production.yml +++ b/.github/workflows/deploy_to_production.yml @@ -15,9 +15,6 @@ jobs: github_token: ${{ github.token }} - uses: actions/checkout@v3 - - #- run: npm ci - #- run: npm run build --if-present - name: Build, Push and Release a Docker container to Heroku. uses: gonuit/heroku-docker-deploy@v1.3.3 From 3c72f59bda7f0a5682880e15164268dc8a236380 Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Sat, 11 Jun 2022 18:31:38 -0300 Subject: [PATCH 07/13] remove unnecesary files --- .github/workflows/deploy_to_test.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/deploy_to_test.yml b/.github/workflows/deploy_to_test.yml index 1272fc2..8c3147b 100644 --- a/.github/workflows/deploy_to_test.yml +++ b/.github/workflows/deploy_to_test.yml @@ -17,15 +17,6 @@ jobs: steps: - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - - run: npm ci - - run: npm run build --if-present - name: Build, Push and Release a Docker container to Heroku. uses: gonuit/heroku-docker-deploy@v1.3.3 From a0a61c6b7c8b0c686f67428371225c1cbdcddd5d Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Mon, 20 Jun 2022 17:33:38 -0300 Subject: [PATCH 08/13] add lint --- .github/workflows/create_PR_from_feature.yml | 12 ++++++++++ .husky/pre-commit | 4 ++++ package-lock.json | 23 ++++++++++++++++++++ package.json | 1 + 4 files changed, 40 insertions(+) create mode 100755 .husky/pre-commit diff --git a/.github/workflows/create_PR_from_feature.yml b/.github/workflows/create_PR_from_feature.yml index 782b9ea..4f1e4ce 100644 --- a/.github/workflows/create_PR_from_feature.yml +++ b/.github/workflows/create_PR_from_feature.yml @@ -50,3 +50,15 @@ jobs: if: always() with: comment_title: "Tests Results" + + lint: + runs-on: ubuntu-latest + needs: pr-to-test + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm run lint diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..83af404 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run lint:fix diff --git a/package-lock.json b/package-lock.json index 97ad980..c1f9822 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@types/supertest": "^2.0.12", "cors": "^2.8.5", + "dotenv": "^16.0.1", "express": "^4.17.3", "mongoose": "^6.3.1", "reflect-metadata": "^0.1.13", @@ -24,6 +25,7 @@ "@types/node": "^17.0.25", "@typescript-eslint/eslint-plugin": "^5.21.0", "@typescript-eslint/parser": "^5.21.0", + "husky": "^8.0.1", "jest": "^28.1.0", "jest-junit": "^13.2.0", "nodemon": "^2.0.16", @@ -3681,6 +3683,21 @@ "node": ">=10.17.0" } }, + "node_modules/husky": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -10046,6 +10063,12 @@ "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true }, + "husky": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", + "dev": true + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", diff --git a/package.json b/package.json index d461174..bcd1642 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@types/node": "^17.0.25", "@typescript-eslint/eslint-plugin": "^5.21.0", "@typescript-eslint/parser": "^5.21.0", + "husky": "^8.0.1", "jest": "^28.1.0", "jest-junit": "^13.2.0", "nodemon": "^2.0.16", From 9716f23630800ba27d2aba8f0d370ad359040f22 Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Mon, 20 Jun 2022 17:34:12 -0300 Subject: [PATCH 09/13] some message --- tests/UserController.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/UserController.test.ts b/tests/UserController.test.ts index 548c089..81bdfed 100644 --- a/tests/UserController.test.ts +++ b/tests/UserController.test.ts @@ -5,5 +5,10 @@ describe('test add function', () => { it('should start with four users', async () => { const response = await request(app).get('/users'); expect(response.body.users).toHaveLength(4); + + + + + }); }); \ No newline at end of file From a098fd89286d72e6a1eaae7252e39dea58120a7a Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Mon, 20 Jun 2022 17:35:42 -0300 Subject: [PATCH 10/13] Keep calm and commit --- .husky/pre-commit | 1 + 1 file changed, 1 insertion(+) diff --git a/.husky/pre-commit b/.husky/pre-commit index 83af404..d065461 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,3 +2,4 @@ . "$(dirname -- "$0")/_/husky.sh" npm run lint:fix +npm test From b0d4d277b678cc5cafc10a4ca62aa36557d8c0fb Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Mon, 20 Jun 2022 17:40:04 -0300 Subject: [PATCH 11/13] lint in husky --- .gitignore | 1 + .husky/pre-commit | 1 - package.json | 3 ++- tests/UserController.test.ts | 4 ---- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 6704566..660b871 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,4 @@ dist # TernJS port file .tern-port +junit.xml diff --git a/.husky/pre-commit b/.husky/pre-commit index d065461..83af404 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,4 +2,3 @@ . "$(dirname -- "$0")/_/husky.sh" npm run lint:fix -npm test diff --git a/package.json b/package.json index bcd1642..b58d41c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "start": "node dist/index.js", "lint": "eslint --ext ts,tsx .", "lint:fix": "eslint --ext ts,tsx . --fix", - "test": "jest --reporters='default' --reporters='jest-junit'" + "test": "jest --reporters='default' --reporters='jest-junit'", + "prepare": "husky install" }, "repository": { "type": "git", diff --git a/tests/UserController.test.ts b/tests/UserController.test.ts index 81bdfed..2c8db5b 100644 --- a/tests/UserController.test.ts +++ b/tests/UserController.test.ts @@ -6,9 +6,5 @@ describe('test add function', () => { const response = await request(app).get('/users'); expect(response.body.users).toHaveLength(4); - - - - }); }); \ No newline at end of file From ba58646927f3f9d1152f10bca4d8c517c80e7d40 Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Mon, 20 Jun 2022 17:42:40 -0300 Subject: [PATCH 12/13] test lint --- src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.ts b/src/index.ts index c65cd92..afb768a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +13,11 @@ const port = process.env.PORT || 4000; app.get('/', (_req, res) => { res.send('Hello World!!!!!!!!!!'); + + + + + }); db.connectDB(); From 2d4940ea8d73c6e73b1b14dee6700e14c2de337e Mon Sep 17 00:00:00 2001 From: Maxi Montenegro Date: Mon, 20 Jun 2022 17:43:14 -0300 Subject: [PATCH 13/13] remove unncesaty lines --- src/index.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index afb768a..01b8cb3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,10 +14,6 @@ const port = process.env.PORT || 4000; app.get('/', (_req, res) => { res.send('Hello World!!!!!!!!!!'); - - - - }); db.connectDB();