From 49afe6450ce252d30dfc0804545847d581c08707 Mon Sep 17 00:00:00 2001 From: Nguyen Nhat Minh Date: Thu, 25 Jul 2024 00:21:26 +0800 Subject: [PATCH 1/8] Add CI action for building and testing --- .github/workflows/node.js.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..b63fa3c --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,30 @@ +# 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: Node.js CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm run build --if-present + - run: npm test From 61c8b744684159687a7ef084a53df4d26d6d6d67 Mon Sep 17 00:00:00 2001 From: Nguyen Nhat Minh Date: Thu, 25 Jul 2024 00:25:57 +0800 Subject: [PATCH 2/8] Update node.js.yml --- .github/workflows/node.js.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index b63fa3c..c7f3cf0 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -26,5 +26,7 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + - run: npm install + - run: npm run lint - run: npm run build --if-present - run: npm test From 2e4d62e9ace3dca55098db1acb6529bc1cb59a43 Mon Sep 17 00:00:00 2001 From: Nguyen Nhat Minh Date: Thu, 25 Jul 2024 00:44:07 +0800 Subject: [PATCH 3/8] Add environment variables --- .github/workflows/node.js.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index c7f3cf0..01b77ce 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,6 +26,9 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + - env: + POSTGRES_URL: ${{ secrets.POSTGRES_URL }} + POSTGRES_DIRECT_URL: ${{ secrets.POSTGRES_DIRECT_URL }} - run: npm install - run: npm run lint - run: npm run build --if-present From 3b12ae203c7184aba23e09df36a39621679266f4 Mon Sep 17 00:00:00 2001 From: Nguyen Nhat Minh Date: Thu, 25 Jul 2024 00:45:23 +0800 Subject: [PATCH 4/8] Try to fix environment variable --- .github/workflows/node.js.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 01b77ce..9e3fe50 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -18,6 +18,10 @@ jobs: matrix: node-version: [20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + env: + POSTGRES_URL: ${{ secrets.POSTGRES_URL }} + POSTGRES_DIRECT_URL: ${{ secrets.POSTGRES_DIRECT_URL }} steps: - uses: actions/checkout@v4 @@ -26,9 +30,6 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' - - env: - POSTGRES_URL: ${{ secrets.POSTGRES_URL }} - POSTGRES_DIRECT_URL: ${{ secrets.POSTGRES_DIRECT_URL }} - run: npm install - run: npm run lint - run: npm run build --if-present From 6246339a2ccf12cb3d5796569a149e466b31ed16 Mon Sep 17 00:00:00 2001 From: Nguyen Nhat Minh Date: Thu, 25 Jul 2024 01:05:13 +0800 Subject: [PATCH 5/8] Set environment --- .github/workflows/node.js.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 9e3fe50..fa338f3 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -8,6 +8,7 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + jobs: build: @@ -18,7 +19,7 @@ jobs: matrix: node-version: [20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - + environment: preview env: POSTGRES_URL: ${{ secrets.POSTGRES_URL }} POSTGRES_DIRECT_URL: ${{ secrets.POSTGRES_DIRECT_URL }} From 45f12ce3ed0a2a3fa22194dcf938faafe9e24beb Mon Sep 17 00:00:00 2001 From: NhatMinh0208 Date: Thu, 25 Jul 2024 00:26:05 +0700 Subject: [PATCH 6/8] does this work --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2aaa177..ea1dc5a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "prisma generate && next build", + "build": "prisma generate --accelerate && next build", "start": "next start", "lint": "next lint", "prettier": "npx prettier . --write", From aee3882c37d0881d201255f23e76ea36f9184cd6 Mon Sep 17 00:00:00 2001 From: NhatMinh0208 Date: Thu, 25 Jul 2024 00:31:45 +0700 Subject: [PATCH 7/8] revert --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea1dc5a..2aaa177 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "prisma generate --accelerate && next build", + "build": "prisma generate && next build", "start": "next start", "lint": "next lint", "prettier": "npx prettier . --write", From d8b213ca503bce804298ca6f701d7a0dfc421ba3 Mon Sep 17 00:00:00 2001 From: NhatMinh0208 Date: Thu, 25 Jul 2024 08:03:01 +0700 Subject: [PATCH 8/8] Add Coveralls --- .github/workflows/node.js.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index fa338f3..22a4690 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -35,3 +35,5 @@ jobs: - run: npm run lint - run: npm run build --if-present - run: npm test + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2.3.0 \ No newline at end of file