From 6c2f5391cf3b968778d2c2b14175ec9eb74e6684 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 14:43:01 -0500
Subject: [PATCH 01/45] move workflows out of their own folders
---
.github/workflows/{backend => }/deploy-preview-backend.yml | 0
.github/workflows/{frontend => }/deploy-preview-frontend.yml | 0
.github/workflows/{backend => }/test-backend.yml | 0
.github/workflows/{frontend => }/test-frontend.yml | 0
4 files changed, 0 insertions(+), 0 deletions(-)
rename .github/workflows/{backend => }/deploy-preview-backend.yml (100%)
rename .github/workflows/{frontend => }/deploy-preview-frontend.yml (100%)
rename .github/workflows/{backend => }/test-backend.yml (100%)
rename .github/workflows/{frontend => }/test-frontend.yml (100%)
diff --git a/.github/workflows/backend/deploy-preview-backend.yml b/.github/workflows/deploy-preview-backend.yml
similarity index 100%
rename from .github/workflows/backend/deploy-preview-backend.yml
rename to .github/workflows/deploy-preview-backend.yml
diff --git a/.github/workflows/frontend/deploy-preview-frontend.yml b/.github/workflows/deploy-preview-frontend.yml
similarity index 100%
rename from .github/workflows/frontend/deploy-preview-frontend.yml
rename to .github/workflows/deploy-preview-frontend.yml
diff --git a/.github/workflows/backend/test-backend.yml b/.github/workflows/test-backend.yml
similarity index 100%
rename from .github/workflows/backend/test-backend.yml
rename to .github/workflows/test-backend.yml
diff --git a/.github/workflows/frontend/test-frontend.yml b/.github/workflows/test-frontend.yml
similarity index 100%
rename from .github/workflows/frontend/test-frontend.yml
rename to .github/workflows/test-frontend.yml
From d42fdb9cda70098ff81ebfc768e4071ac686b3e1 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 14:56:46 -0500
Subject: [PATCH 02/45] combine test workflows
---
.github/workflows/test-frontend.yml | 41 -------------------
.../workflows/{test-backend.yml => test.yml} | 37 ++++++++++++++---
2 files changed, 31 insertions(+), 47 deletions(-)
delete mode 100644 .github/workflows/test-frontend.yml
rename .github/workflows/{test-backend.yml => test.yml} (84%)
diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml
deleted file mode 100644
index 0584191..0000000
--- a/.github/workflows/test-frontend.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-name: Test Frontend
-on:
- push:
- branches: ['main', 'staging', 'prod']
- paths:
- - 'frontend/**'
- pull_request:
- branches: ['main', 'staging', 'prod']
- paths:
- - 'frontend/**'
-jobs:
- test-frontend:
- runs-on: ubuntu-latest
- defaults:
- run:
- shell: bash
- working-directory: frontend
- steps:
- - uses: actions/checkout@v4
- - name: Setup pnpm
- uses: pnpm/action-setup@v4
- with:
- version: 9
- run_install: false
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- cache: 'pnpm'
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
- - name: Run tests
- run: pnpm test:ci
- - name: Generate coverage report
- run: pnpm coverage
- - name: Upload coverage report
- uses: actions/upload-artifact@v4
- with:
- name: coverage-report
- path: coverage/
- retention-days: 7
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test.yml
similarity index 84%
rename from .github/workflows/test-backend.yml
rename to .github/workflows/test.yml
index 26bdc7b..390f370 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test.yml
@@ -1,14 +1,39 @@
-name: Test Backend
on:
push:
branches: ['main', 'staging', 'prod']
- paths:
- - 'backend/**'
pull_request:
branches: ['main', 'staging', 'prod']
- paths:
- - 'backend/**'
jobs:
+ test-frontend:
+ name: Test Frontend
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ shell: bash
+ working-directory: frontend
+ steps:
+ - uses: actions/checkout@v4
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v4
+ with:
+ version: 9
+ run_install: false
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ cache: 'pnpm'
+ - name: Install dependencies
+ run: pnpm install --frozen-lockfile
+ - name: Run tests
+ run: pnpm test:ci
+ - name: Generate coverage report
+ run: pnpm coverage
+ - name: Upload coverage report
+ uses: actions/upload-artifact@v4
+ with:
+ name: coverage-report-frontend
+ path: coverage/
test-backend:
name: Test Backend
runs-on: ubuntu-latest
@@ -55,7 +80,7 @@ jobs:
if: ${{ !env.ACT && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
- name: coverage-report
+ name: coverage-report-backend
path: coverage.html
- name: Comment PR
if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
From 34e301a27f23f9c93e1a0e1d6fdfa8fcd1b8f0ab Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:02:33 -0500
Subject: [PATCH 03/45] redefined working directory
---
.github/workflows/test.yml | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 390f370..847e67f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -7,10 +7,8 @@ jobs:
test-frontend:
name: Test Frontend
runs-on: ubuntu-latest
- defaults:
- run:
- shell: bash
- working-directory: frontend
+ shell: bash
+ working-directory: ./frontend
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
@@ -37,10 +35,8 @@ jobs:
test-backend:
name: Test Backend
runs-on: ubuntu-latest
- defaults:
- run:
- shell: bash
- working-directory: backend
+ shell: bash
+ working-directory: ./backend
services:
postgres:
image: postgres:16
From 32172a5e53e35e64ff8f4be2100140293eac2079 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:12:46 -0500
Subject: [PATCH 04/45] remove shell from test workflow
---
.github/workflows/test.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 847e67f..f28f3d9 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -7,7 +7,6 @@ jobs:
test-frontend:
name: Test Frontend
runs-on: ubuntu-latest
- shell: bash
working-directory: ./frontend
steps:
- uses: actions/checkout@v4
@@ -35,7 +34,6 @@ jobs:
test-backend:
name: Test Backend
runs-on: ubuntu-latest
- shell: bash
working-directory: ./backend
services:
postgres:
From 371df73be67f05bf2ad8e90a0252c1b2ec3a3ac4 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:17:16 -0500
Subject: [PATCH 05/45] fix working directory
---
.github/workflows/test.yml | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f28f3d9..55a4d6f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -7,7 +7,9 @@ jobs:
test-frontend:
name: Test Frontend
runs-on: ubuntu-latest
- working-directory: ./frontend
+ defaults:
+ run:
+ working-directory: ./frontend
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
@@ -34,7 +36,9 @@ jobs:
test-backend:
name: Test Backend
runs-on: ubuntu-latest
- working-directory: ./backend
+ defaults:
+ run:
+ working-directory: ./backend
services:
postgres:
image: postgres:16
From eb900a5af21037e490b33f17838b5af4f50725a6 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:20:29 -0500
Subject: [PATCH 06/45] echo pwd
---
.github/workflows/test.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 55a4d6f..3fd4991 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -11,6 +11,8 @@ jobs:
run:
working-directory: ./frontend
steps:
+ - name: Check pwd
+ run: pwd
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
@@ -52,6 +54,8 @@ jobs:
ports:
- 5432:5432
steps:
+ - name: Check pwd
+ run: pwd
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
From e25e71dca8bbc94d57acbd1eb20681242e1bce0c Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:21:51 -0500
Subject: [PATCH 07/45] update
---
.github/workflows/test.yml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3fd4991..c8679d6 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
- working-directory: ./frontend
+ working-directory: frontend
steps:
- - name: Check pwd
- run: pwd
+ - name: Check ls
+ run: ls
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
@@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
- working-directory: ./backend
+ working-directory: backend
services:
postgres:
image: postgres:16
@@ -54,8 +54,8 @@ jobs:
ports:
- 5432:5432
steps:
- - name: Check pwd
- run: pwd
+ - name: Check ls
+ run: ls
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
From 5abd7aaab97b95e47651684b4220c4451e474580 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:29:24 -0500
Subject: [PATCH 08/45] update
---
.github/workflows/test.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index c8679d6..0650032 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -11,9 +11,9 @@ jobs:
run:
working-directory: frontend
steps:
+ - uses: actions/checkout@v4
- name: Check ls
run: ls
- - uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
@@ -54,9 +54,9 @@ jobs:
ports:
- 5432:5432
steps:
+ - uses: actions/checkout@v4
- name: Check ls
run: ls
- - uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
From ebcd92ddc7c3bd042c8391704a6fec47851b0e3d Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:34:31 -0500
Subject: [PATCH 09/45] add working-directory to all steps
---
.github/workflows/test.yml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0650032..c6cbd87 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -21,17 +21,22 @@ jobs:
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
+ working-directory: frontend
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
+ working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Run tests
+ working-directory: frontend
run: pnpm test:ci
- name: Generate coverage report
+ working-directory: frontend
run: pnpm coverage
- name: Upload coverage report
uses: actions/upload-artifact@v4
+ working-directory: frontend
with:
name: coverage-report-frontend
path: coverage/
@@ -59,16 +64,21 @@ jobs:
run: ls
- name: Set up Go
uses: actions/setup-go@v4
+ working-directory: backend
with:
go-version: '1.23'
cache: true
- name: Install dependencies
+ working-directory: backend
run: go mod download
- name: Install Goose
+ working-directory: backend
run: go install github.com/pressly/goose/v3/cmd/goose@v3.22.1
- name: Run migrations
+ working-directory: backend
run: goose -dir .sqlc/migrations postgres "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" up
- name: Run tests
+ working-directory: backend
id: tests
continue-on-error: true
run: |
@@ -77,20 +87,24 @@ jobs:
# store the exit code explicitly
echo "::set-output name=exit_code::${PIPESTATUS[0]}"
- name: Generate coverage report
+ working-directory: backend
run: go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
if: ${{ !env.ACT && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
+ working-directory: backend
with:
name: coverage-report-backend
path: coverage.html
- name: Comment PR
if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
uses: actions/github-script@v7
+ working-directory: backend
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
- uses: actions/cache@v4
+ working-directory: backend
with:
path: |
~/.cache/go-build
From 8e6f20ee1f75f870462f89dc3bea946824ea5043 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:41:25 -0500
Subject: [PATCH 10/45] update
---
.github/workflows/test.yml | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index c6cbd87..09f3011 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -13,15 +13,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Check ls
- run: ls
+ run: ls -la
- name: Setup pnpm
+ working-directory: frontend
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Setup Node.js
- uses: actions/setup-node@v4
working-directory: frontend
+ uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
@@ -35,8 +36,8 @@ jobs:
working-directory: frontend
run: pnpm coverage
- name: Upload coverage report
- uses: actions/upload-artifact@v4
working-directory: frontend
+ uses: actions/upload-artifact@v4
with:
name: coverage-report-frontend
path: coverage/
From 07bf171a1f9a0a2065d4010b75fe71b31889f9c0 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:43:13 -0500
Subject: [PATCH 11/45] update
---
.github/workflows/test.yml | 44 +++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 09f3011..5fc28c8 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -4,49 +4,49 @@ on:
pull_request:
branches: ['main', 'staging', 'prod']
jobs:
- test-frontend:
+ test-./frontend:
name: Test Frontend
runs-on: ubuntu-latest
defaults:
run:
- working-directory: frontend
+ working-directory: ./frontend
steps:
- uses: actions/checkout@v4
- name: Check ls
- run: ls -la
+ run: ls
- name: Setup pnpm
- working-directory: frontend
+ working-directory: ./frontend
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Setup Node.js
- working-directory: frontend
+ working-directory: ./frontend
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
- working-directory: frontend
+ working-directory: ./frontend
run: pnpm install --frozen-lockfile
- name: Run tests
- working-directory: frontend
+ working-directory: ./frontend
run: pnpm test:ci
- name: Generate coverage report
- working-directory: frontend
+ working-directory: ./frontend
run: pnpm coverage
- name: Upload coverage report
- working-directory: frontend
uses: actions/upload-artifact@v4
+ working-directory: ./frontend
with:
- name: coverage-report-frontend
+ name: coverage-report-./frontend
path: coverage/
- test-backend:
+ test-./backend:
name: Test Backend
runs-on: ubuntu-latest
defaults:
run:
- working-directory: backend
+ working-directory: ./backend
services:
postgres:
image: postgres:16
@@ -65,21 +65,21 @@ jobs:
run: ls
- name: Set up Go
uses: actions/setup-go@v4
- working-directory: backend
+ working-directory: ./backend
with:
go-version: '1.23'
cache: true
- name: Install dependencies
- working-directory: backend
+ working-directory: ./backend
run: go mod download
- name: Install Goose
- working-directory: backend
+ working-directory: ./backend
run: go install github.com/pressly/goose/v3/cmd/goose@v3.22.1
- name: Run migrations
- working-directory: backend
+ working-directory: ./backend
run: goose -dir .sqlc/migrations postgres "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" up
- name: Run tests
- working-directory: backend
+ working-directory: ./backend
id: tests
continue-on-error: true
run: |
@@ -88,24 +88,24 @@ jobs:
# store the exit code explicitly
echo "::set-output name=exit_code::${PIPESTATUS[0]}"
- name: Generate coverage report
- working-directory: backend
+ working-directory: ./backend
run: go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
if: ${{ !env.ACT && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
- working-directory: backend
+ working-directory: ./backend
with:
- name: coverage-report-backend
+ name: coverage-report-./backend
path: coverage.html
- name: Comment PR
if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
uses: actions/github-script@v7
- working-directory: backend
+ working-directory: ./backend
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
- uses: actions/cache@v4
- working-directory: backend
+ working-directory: ./backend
with:
path: |
~/.cache/go-build
From 83f8014472a05e96a8e192ddca83e2f2b5013204 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:46:20 -0500
Subject: [PATCH 12/45] update
---
.github/workflows/test.yml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 5fc28c8..f71b8b2 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -11,12 +11,13 @@ jobs:
run:
working-directory: ./frontend
steps:
- - uses: actions/checkout@v4
+ - name: Checkout code
+ uses: actions/checkout@v4
- name: Check ls
run: ls
- name: Setup pnpm
- working-directory: ./frontend
uses: pnpm/action-setup@v4
+ working-directory: ./frontend
with:
version: 9
run_install: false
From 171c3b7a277fd3d80599cfabbf8e1ef4ff3215ca Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:48:07 -0500
Subject: [PATCH 13/45] update
---
.github/workflows/test.yml | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f71b8b2..0078be7 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -17,30 +17,24 @@ jobs:
run: ls
- name: Setup pnpm
uses: pnpm/action-setup@v4
- working-directory: ./frontend
with:
version: 9
run_install: false
- name: Setup Node.js
- working-directory: ./frontend
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
- working-directory: ./frontend
run: pnpm install --frozen-lockfile
- name: Run tests
- working-directory: ./frontend
run: pnpm test:ci
- name: Generate coverage report
- working-directory: ./frontend
run: pnpm coverage
- name: Upload coverage report
uses: actions/upload-artifact@v4
- working-directory: ./frontend
with:
- name: coverage-report-./frontend
+ name: coverage-report-frontend
path: coverage/
test-./backend:
name: Test Backend
@@ -61,26 +55,22 @@ jobs:
ports:
- 5432:5432
steps:
- - uses: actions/checkout@v4
+ - name: Checkout code
+ uses: actions/checkout@v3
- name: Check ls
run: ls
- name: Set up Go
uses: actions/setup-go@v4
- working-directory: ./backend
with:
go-version: '1.23'
cache: true
- name: Install dependencies
- working-directory: ./backend
run: go mod download
- name: Install Goose
- working-directory: ./backend
run: go install github.com/pressly/goose/v3/cmd/goose@v3.22.1
- name: Run migrations
- working-directory: ./backend
run: goose -dir .sqlc/migrations postgres "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" up
- name: Run tests
- working-directory: ./backend
id: tests
continue-on-error: true
run: |
@@ -89,24 +79,20 @@ jobs:
# store the exit code explicitly
echo "::set-output name=exit_code::${PIPESTATUS[0]}"
- name: Generate coverage report
- working-directory: ./backend
run: go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
if: ${{ !env.ACT && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
- working-directory: ./backend
with:
- name: coverage-report-./backend
+ name: coverage-report-backend
path: coverage.html
- name: Comment PR
if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
uses: actions/github-script@v7
- working-directory: ./backend
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
- uses: actions/cache@v4
- working-directory: ./backend
with:
path: |
~/.cache/go-build
From c229d351fc764c816007f507d17c3f481072a55a Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:49:23 -0500
Subject: [PATCH 14/45] update
---
.github/workflows/test.yml | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0078be7..3c95eb5 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -4,7 +4,7 @@ on:
pull_request:
branches: ['main', 'staging', 'prod']
jobs:
- test-./frontend:
+ test-frontend:
name: Test Frontend
runs-on: ubuntu-latest
defaults:
@@ -27,16 +27,19 @@ jobs:
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
+ working-directory: ./frontend
- name: Run tests
run: pnpm test:ci
+ working-directory: ./frontend
- name: Generate coverage report
run: pnpm coverage
+ working-directory: ./frontend
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report-frontend
path: coverage/
- test-./backend:
+ test-backend:
name: Test Backend
runs-on: ubuntu-latest
defaults:
From 7f8c77595427ed49c31ffc1cf0afe2d3ecb612f7 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:51:21 -0500
Subject: [PATCH 15/45] update
---
.github/workflows/test.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3c95eb5..1d2bc9e 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -15,6 +15,9 @@ jobs:
uses: actions/checkout@v4
- name: Check ls
run: ls
+ - name: NPM install
+ run: npm install -g pnpm
+ working-directory: ./frontend
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
From bdfbc4a15f32ca3d95edf0dab91ff53ce07ab34c Mon Sep 17 00:00:00 2001
From: Aidan Traboulay
Date: Fri, 22 Nov 2024 16:58:13 -0400
Subject: [PATCH 16/45] update
---
.github/workflows/deploy-preview-frontend.yml | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/deploy-preview-frontend.yml b/.github/workflows/deploy-preview-frontend.yml
index 2d9cde8..f310c18 100644
--- a/.github/workflows/deploy-preview-frontend.yml
+++ b/.github/workflows/deploy-preview-frontend.yml
@@ -5,6 +5,7 @@ on:
- main
paths:
- 'frontend/**'
+
jobs:
build-and-deploy-frontend:
runs-on: ubuntu-latest
@@ -15,31 +16,43 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
+
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
+
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
+
+ - name: Debug frontend directory
+ run: ls -la
+
- name: Get pnpm store directory
- shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
+
+ - name: Debug pnpm store path
+ run: echo "pnpm store path is: $STORE_PATH"
+
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('frontend/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
+
- name: Install dependencies
run: pnpm install --frozen-lockfile
+
- name: Build
run: pnpm build
+
- name: Deploy to server
uses: appleboy/scp-action@master
with:
From 33a5f458b57c69bbe0ea4737ade5a606a37f80ec Mon Sep 17 00:00:00 2001
From: Aidan Traboulay
Date: Fri, 22 Nov 2024 17:01:10 -0400
Subject: [PATCH 17/45] update
---
.github/workflows/deploy-preview-frontend.yml | 20 ++++---------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/.github/workflows/deploy-preview-frontend.yml b/.github/workflows/deploy-preview-frontend.yml
index f310c18..eaea1ed 100644
--- a/.github/workflows/deploy-preview-frontend.yml
+++ b/.github/workflows/deploy-preview-frontend.yml
@@ -5,7 +5,6 @@ on:
- main
paths:
- 'frontend/**'
-
jobs:
build-and-deploy-frontend:
runs-on: ubuntu-latest
@@ -16,29 +15,21 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
-
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
-
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
-
- - name: Debug frontend directory
- run: ls -la
-
+ cache-dependency-path: 'frontend/pnpm-lock.yaml'
- name: Get pnpm store directory
+ shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Debug pnpm store path
- run: echo "pnpm store path is: $STORE_PATH"
-
- name: Setup pnpm cache
uses: actions/cache@v3
with:
@@ -46,19 +37,16 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('frontend/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
-
- name: Install dependencies
run: pnpm install --frozen-lockfile
-
- name: Build
run: pnpm build
-
- name: Deploy to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.PREVIEW_SERVER_IP }}
username: ${{ secrets.PREVIEW_USER }}
key: ${{ secrets.PREVIEW_SERVER_SSH_KEY }}
- source: "dist/"
+ source: "frontend/dist/"
target: "${{ secrets.TARGET_DIR }}"
- strip_components: 1
+ strip_components: 2
\ No newline at end of file
From 73bdddc0b80408b1efbef42741c9a7355c668c7d Mon Sep 17 00:00:00 2001
From: Aidan Traboulay
Date: Fri, 22 Nov 2024 17:04:26 -0400
Subject: [PATCH 18/45] update
---
.github/workflows/deploy-preview-frontend.yml | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/deploy-preview-frontend.yml b/.github/workflows/deploy-preview-frontend.yml
index eaea1ed..6175bcc 100644
--- a/.github/workflows/deploy-preview-frontend.yml
+++ b/.github/workflows/deploy-preview-frontend.yml
@@ -8,10 +8,6 @@ on:
jobs:
build-and-deploy-frontend:
runs-on: ubuntu-latest
- defaults:
- run:
- shell: bash
- working-directory: frontend
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -25,21 +21,22 @@ jobs:
with:
node-version: '20'
cache: 'pnpm'
- cache-dependency-path: 'frontend/pnpm-lock.yaml'
+ cache-dependency-path: '**/pnpm-lock.yaml'
- name: Get pnpm store directory
- shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('frontend/pnpm-lock.yaml') }}
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
+ working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Build
+ working-directory: frontend
run: pnpm build
- name: Deploy to server
uses: appleboy/scp-action@master
From 9778fb0e6baa308b2f797801541e8373e0d09a90 Mon Sep 17 00:00:00 2001
From: Aidan Traboulay
Date: Fri, 22 Nov 2024 17:06:32 -0400
Subject: [PATCH 19/45] update
---
.github/workflows/deploy-preview-frontend.yml | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/.github/workflows/deploy-preview-frontend.yml b/.github/workflows/deploy-preview-frontend.yml
index 6175bcc..f88c156 100644
--- a/.github/workflows/deploy-preview-frontend.yml
+++ b/.github/workflows/deploy-preview-frontend.yml
@@ -15,26 +15,13 @@ jobs:
uses: pnpm/action-setup@v4
with:
version: 9
- run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- cache: 'pnpm'
- cache-dependency-path: '**/pnpm-lock.yaml'
- - name: Get pnpm store directory
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-store-
- name: Install dependencies
working-directory: frontend
- run: pnpm install --frozen-lockfile
+ run: pnpm install
- name: Build
working-directory: frontend
run: pnpm build
From 422a60efaddb7698c1948f1e4bc0b6ef1c9b0678 Mon Sep 17 00:00:00 2001
From: Aidan Traboulay
Date: Fri, 22 Nov 2024 17:07:39 -0400
Subject: [PATCH 20/45] update
---
.github/workflows/deploy-preview-frontend.yml | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/deploy-preview-frontend.yml b/.github/workflows/deploy-preview-frontend.yml
index f88c156..ae0e650 100644
--- a/.github/workflows/deploy-preview-frontend.yml
+++ b/.github/workflows/deploy-preview-frontend.yml
@@ -11,10 +11,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- - name: Setup pnpm
- uses: pnpm/action-setup@v4
- with:
- version: 9
+ - name: Install pnpm globally
+ run: npm install -g pnpm
- name: Setup Node.js
uses: actions/setup-node@v4
with:
From a6707636474e7e2ccf20221dd4b709c90b0baf09 Mon Sep 17 00:00:00 2001
From: Aidan Traboulay
Date: Fri, 22 Nov 2024 17:37:03 -0400
Subject: [PATCH 21/45] revert
---
.github/workflows/deploy-preview-frontend.yml | 31 ++++++++++++++-----
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/deploy-preview-frontend.yml b/.github/workflows/deploy-preview-frontend.yml
index ae0e650..f10a08f 100644
--- a/.github/workflows/deploy-preview-frontend.yml
+++ b/.github/workflows/deploy-preview-frontend.yml
@@ -8,20 +8,37 @@ on:
jobs:
build-and-deploy-frontend:
runs-on: ubuntu-latest
+ defaults:
+ run:
+ shell: bash
+ working-directory: frontend
steps:
- name: Checkout code
uses: actions/checkout@v4
- - name: Install pnpm globally
- run: npm install -g pnpm
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v4
+ with:
+ version: 9
+ run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
+ cache: 'pnpm'
+ - name: Get pnpm store directory
+ shell: bash
+ run: |
+ echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
+ - name: Setup pnpm cache
+ uses: actions/cache@v3
+ with:
+ path: ${{ env.STORE_PATH }}
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
+ restore-keys: |
+ ${{ runner.os }}-pnpm-store-
- name: Install dependencies
- working-directory: frontend
- run: pnpm install
+ run: pnpm install --frozen-lockfile
- name: Build
- working-directory: frontend
run: pnpm build
- name: Deploy to server
uses: appleboy/scp-action@master
@@ -29,6 +46,6 @@ jobs:
host: ${{ secrets.PREVIEW_SERVER_IP }}
username: ${{ secrets.PREVIEW_USER }}
key: ${{ secrets.PREVIEW_SERVER_SSH_KEY }}
- source: "frontend/dist/"
+ source: "dist/"
target: "${{ secrets.TARGET_DIR }}"
- strip_components: 2
\ No newline at end of file
+ strip_components: 1
\ No newline at end of file
From b81bc2a3630a438099f33ada4b82a70055016da9 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 21:31:28 -0500
Subject: [PATCH 22/45] separate test workflows
---
.../workflows/{test.yml => test-backend.yml} | 45 ++-----------------
.github/workflows/test-frontend.yml | 37 +++++++++++++++
2 files changed, 41 insertions(+), 41 deletions(-)
rename .github/workflows/{test.yml => test-backend.yml} (79%)
create mode 100644 .github/workflows/test-frontend.yml
diff --git a/.github/workflows/test.yml b/.github/workflows/test-backend.yml
similarity index 79%
rename from .github/workflows/test.yml
rename to .github/workflows/test-backend.yml
index 1d2bc9e..112e1af 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test-backend.yml
@@ -1,53 +1,16 @@
on:
push:
branches: ['main', 'staging', 'prod']
+ paths:
+ - 'backend/**'
pull_request:
branches: ['main', 'staging', 'prod']
+ paths:
+ - 'backend/**'
jobs:
- test-frontend:
- name: Test Frontend
- runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: ./frontend
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Check ls
- run: ls
- - name: NPM install
- run: npm install -g pnpm
- working-directory: ./frontend
- - name: Setup pnpm
- uses: pnpm/action-setup@v4
- with:
- version: 9
- run_install: false
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- cache: 'pnpm'
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
- working-directory: ./frontend
- - name: Run tests
- run: pnpm test:ci
- working-directory: ./frontend
- - name: Generate coverage report
- run: pnpm coverage
- working-directory: ./frontend
- - name: Upload coverage report
- uses: actions/upload-artifact@v4
- with:
- name: coverage-report-frontend
- path: coverage/
test-backend:
name: Test Backend
runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: ./backend
services:
postgres:
image: postgres:16
diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml
new file mode 100644
index 0000000..d041577
--- /dev/null
+++ b/.github/workflows/test-frontend.yml
@@ -0,0 +1,37 @@
+on:
+ push:
+ branches: ['main', 'staging', 'prod']
+ paths:
+ - 'frontend/**'
+ pull_request:
+ branches: ['main', 'staging', 'prod']
+ paths:
+ - 'frontend/**'
+jobs:
+ test-frontend:
+ name: Test Frontend
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v4
+ with:
+ version: 9
+ run_install: false
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ cache: 'pnpm'
+ - name: Install dependencies
+ run: pnpm install --frozen-lockfile
+ - name: Run tests
+ run: pnpm test:ci
+ - name: Generate coverage report
+ run: pnpm coverage
+ - name: Upload coverage report
+ uses: actions/upload-artifact@v4
+ with:
+ name: coverage-report-frontend
+ path: coverage/
From 09842b120ea9dccdb7bf013fa44a003f3188991c Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 21:53:36 -0500
Subject: [PATCH 23/45] update frontend page title
---
frontend/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/index.html b/frontend/index.html
index e4b78ea..f07f8f4 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -4,7 +4,7 @@
- Vite + React + TS
+ SPUR
From 23c994e8f0b612cf202a5dadaab5829bb09d641b Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 21:56:02 -0500
Subject: [PATCH 24/45] remove cache
---
.github/workflows/test-frontend.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml
index d041577..885dde0 100644
--- a/.github/workflows/test-frontend.yml
+++ b/.github/workflows/test-frontend.yml
@@ -23,7 +23,6 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'
- cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
From d1b9cff1f37323eb1d75449900e073a34596e641 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 22:01:24 -0500
Subject: [PATCH 25/45] ls
---
.github/workflows/test-frontend.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml
index 885dde0..a630672 100644
--- a/.github/workflows/test-frontend.yml
+++ b/.github/workflows/test-frontend.yml
@@ -14,6 +14,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
+ - name: Check ls
+ run: ls
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
From 80d0966f6e1aff06bfcd758aba494a7e85246022 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 23:03:20 -0500
Subject: [PATCH 26/45] change directory
---
.github/workflows/test-frontend.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml
index a630672..51b0d1f 100644
--- a/.github/workflows/test-frontend.yml
+++ b/.github/workflows/test-frontend.yml
@@ -14,8 +14,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- - name: Check ls
- run: ls
+ - name: Change directory
+ run: cd frontend
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
From d00971678038e74863f4127f17846e8092a56eb3 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 23:04:48 -0500
Subject: [PATCH 27/45] cd before running cmd
---
.github/workflows/test-frontend.yml | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml
index 51b0d1f..95e4635 100644
--- a/.github/workflows/test-frontend.yml
+++ b/.github/workflows/test-frontend.yml
@@ -14,8 +14,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- - name: Change directory
- run: cd frontend
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
@@ -26,13 +24,13 @@ jobs:
with:
node-version: '20'
- name: Install dependencies
- run: pnpm install --frozen-lockfile
+ run: cd frontend && pnpm install --frozen-lockfile
- name: Run tests
- run: pnpm test:ci
+ run: cd frontend && pnpm test:ci
- name: Generate coverage report
- run: pnpm coverage
+ run: cd frontend && pnpm coverage
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report-frontend
- path: coverage/
+ path: frontend/coverage/
From 70a5aed0b3cd60616e06a7c38167e0e3bdc0d4dc Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 23:09:12 -0500
Subject: [PATCH 28/45] update backend test with cd
---
.github/workflows/test-backend.yml | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index 112e1af..5d09ae5 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -26,29 +26,28 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
- - name: Check ls
- run: ls
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
cache: true
- name: Install dependencies
- run: go mod download
+ run: cd backend && go mod download
- name: Install Goose
- run: go install github.com/pressly/goose/v3/cmd/goose@v3.22.1
+ run: cd backend && go install github.com/pressly/goose/v3/cmd/goose@v3.22.1
- name: Run migrations
- run: goose -dir .sqlc/migrations postgres "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" up
+ run: cd backend && goose -dir .sqlc/migrations postgres "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" up
- name: Run tests
id: tests
continue-on-error: true
run: |
# run tests and capture output
+ cd backend
go test -v -coverprofile=coverage.out ./... 2>&1 | tee test_output.txt
# store the exit code explicitly
echo "::set-output name=exit_code::${PIPESTATUS[0]}"
- name: Generate coverage report
- run: go tool cover -html=coverage.out -o coverage.html
+ run: cd backend && go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
if: ${{ !env.ACT && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
From a28936757569445a761b202f27a4bf3312be4938 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 23:10:19 -0500
Subject: [PATCH 29/45] update backend readme with specific version for tooling
---
backend/README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/backend/README.md b/backend/README.md
index 86c0b78..6482d96 100644
--- a/backend/README.md
+++ b/backend/README.md
@@ -9,9 +9,9 @@ Make sure to download **VERSION 1.23** for best compatibility.
### Install Pre-requisite tools
-- Air (auto-reload backend): go install github.com/air-verse/air@latest
-- SQLc (generate type-safe code from SQL queries): go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
-- Goose (SQL migration management tool): go install github.com/pressly/goose/v3/cmd/goose@latest
+- Air (auto-reload backend): go install github.com/air-verse/air@1.61.1
+- SQLc (generate type-safe code from SQL queries): go install github.com/sqlc-dev/sqlc/cmd/sqlc@1.27.0
+- Goose (SQL migration management tool): go install github.com/pressly/goose/v3/cmd/goose@3.22.1
- Make
- Docker
@@ -22,8 +22,8 @@ Make sure to download **VERSION 1.23** for best compatibility.
1. Create a new PostgreSQL instance using docker with `make init-dev-db`
2. Start PostgreSQL for development `make start-dev-db`
- Check health of DB `make health-dev-db`
-4. Run migrations when ready `make up`
-5. Start development server `make dev`
+3. Run migrations when ready `make up`
+4. Start development server `make dev`
> Use `make query "SELECT ... FROM ..."` for quick query on the terminal.
> You should also checkout the other available commands in the Makefile.
From 02cbf0e6af0219143095a35c457a78b973a62754 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 23:28:54 -0500
Subject: [PATCH 30/45] update backend test flow
---
.github/workflows/test-backend.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index 5d09ae5..ba39c79 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -59,7 +59,7 @@ jobs:
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
+ script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('backend/test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
- uses: actions/cache@v4
with:
path: |
From c741c4b8e2953bde269d2c4a61f9368ad342a9c4 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 23:32:59 -0500
Subject: [PATCH 31/45] update backend test actions version
---
.github/workflows/test-backend.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index ba39c79..1505c34 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -25,9 +25,9 @@ jobs:
- 5432:5432
steps:
- name: Checkout code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up Go
- uses: actions/setup-go@v4
+ uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
From 0aa468654e58733362d8c68091d8697f7ede1cc4 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 23:37:35 -0500
Subject: [PATCH 32/45] update backend test flow
---
.github/workflows/test-backend.yml | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index 1505c34..ba4b722 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -44,8 +44,6 @@ jobs:
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./... 2>&1 | tee test_output.txt
- # store the exit code explicitly
- echo "::set-output name=exit_code::${PIPESTATUS[0]}"
- name: Generate coverage report
run: cd backend && go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
@@ -53,18 +51,10 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: coverage-report-backend
- path: coverage.html
+ path: backend/coverage.html
- name: Comment PR
if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('backend/test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
- - uses: actions/cache@v4
- with:
- path: |
- ~/.cache/go-build
- ~/go/pkg/mod
- key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- restore-keys: |
- ${{ runner.os }}-go-
From 8ce2858493cb62d5082db6644fa96e6d1c3a1f1e Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Sun, 24 Nov 2024 23:40:23 -0500
Subject: [PATCH 33/45] remove cache
---
.github/workflows/test-backend.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index ba4b722..6d7441c 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -30,7 +30,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: '1.23'
- cache: true
- name: Install dependencies
run: cd backend && go mod download
- name: Install Goose
From e167518a56e4b55aad912167d821522564cb7a69 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Mon, 25 Nov 2024 23:05:18 -0500
Subject: [PATCH 34/45] update deploy flows
---
.github/workflows/deploy-preview-backend.yml | 3 ++-
.github/workflows/deploy-preview-frontend.yml | 9 +++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/deploy-preview-backend.yml b/.github/workflows/deploy-preview-backend.yml
index 62325e5..6335769 100644
--- a/.github/workflows/deploy-preview-backend.yml
+++ b/.github/workflows/deploy-preview-backend.yml
@@ -46,8 +46,9 @@ jobs:
rm -rf repo
git clone git@github.com:${{ github.repository }}.git repo
cd repo
+ cd backend
echo "Copy deploy preview script"
- cp .github/scripts/deploy-preview.sh .
+ cp ../.github/scripts/deploy-preview.sh .
echo "Running deploy-preview.sh"
chmod +x deploy-preview.sh
./deploy-preview.sh
diff --git a/.github/workflows/deploy-preview-frontend.yml b/.github/workflows/deploy-preview-frontend.yml
index f10a08f..7a2b52e 100644
--- a/.github/workflows/deploy-preview-frontend.yml
+++ b/.github/workflows/deploy-preview-frontend.yml
@@ -37,15 +37,16 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
- run: pnpm install --frozen-lockfile
+ run: cd frontend && pnpm install --frozen-lockfile
- name: Build
- run: pnpm build
+ run: cd frontend && pnpm build
- name: Deploy to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.PREVIEW_SERVER_IP }}
username: ${{ secrets.PREVIEW_USER }}
key: ${{ secrets.PREVIEW_SERVER_SSH_KEY }}
- source: "dist/"
+ source: "frontend/dist/"
target: "${{ secrets.TARGET_DIR }}"
- strip_components: 1
\ No newline at end of file
+ strip_components: 1
+
From 2292291ce0e6dab15ba7a8012240017029e4f02e Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Mon, 25 Nov 2024 23:16:06 -0500
Subject: [PATCH 35/45] set pipeline code
---
.github/workflows/test-backend.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index 6d7441c..a510be8 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -43,6 +43,8 @@ jobs:
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./... 2>&1 | tee test_output.txt
+ # store the exit code explicitly
+ echo "::set-output name=exit_code::${PIPESTATUS[0]}"
- name: Generate coverage report
run: cd backend && go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
From 71de4d7ed2ea03c643b8a7e69eeb62e2ff44145b Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Mon, 25 Nov 2024 23:21:40 -0500
Subject: [PATCH 36/45] remove pr commenting after backend test
---
.github/workflows/test-backend.yml | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index a510be8..d75b3b0 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -42,9 +42,7 @@ jobs:
run: |
# run tests and capture output
cd backend
- go test -v -coverprofile=coverage.out ./... 2>&1 | tee test_output.txt
- # store the exit code explicitly
- echo "::set-output name=exit_code::${PIPESTATUS[0]}"
+ go test -v -coverprofile=coverage.out ./...
- name: Generate coverage report
run: cd backend && go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
@@ -53,9 +51,9 @@ jobs:
with:
name: coverage-report-backend
path: backend/coverage.html
- - name: Comment PR
- if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
- uses: actions/github-script@v7
- with:
- github-token: ${{ secrets.GITHUB_TOKEN }}
- script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('backend/test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
+ # - name: Comment PR
+ # if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
+ # uses: actions/github-script@v7
+ # with:
+ # github-token: ${{ secrets.GITHUB_TOKEN }}
+ # script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('backend/test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
From bbf402f9f43dbb5ee87ce571943eb370d5ad871d Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Mon, 25 Nov 2024 23:26:11 -0500
Subject: [PATCH 37/45] add back setting exit code
---
.github/workflows/test-backend.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index d75b3b0..db79133 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -30,6 +30,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: '1.23'
+ cache: true
- name: Install dependencies
run: cd backend && go mod download
- name: Install Goose
@@ -43,6 +44,8 @@ jobs:
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./...
+ # store the exit code explicitly
+ echo "::set-output name=exit_code::${PIPESTATUS[0]}"
- name: Generate coverage report
run: cd backend && go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
From f336f7a75e56c1d9a8bd6216ab33feb5e0fdf3c9 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Tue, 26 Nov 2024 12:33:54 -0500
Subject: [PATCH 38/45] remove coverage report upload
---
.github/workflows/test-backend.yml | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index db79133..ee67e05 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -38,22 +38,19 @@ jobs:
- name: Run migrations
run: cd backend && goose -dir .sqlc/migrations postgres "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" up
- name: Run tests
- id: tests
continue-on-error: true
run: |
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./...
- # store the exit code explicitly
- echo "::set-output name=exit_code::${PIPESTATUS[0]}"
- - name: Generate coverage report
- run: cd backend && go tool cover -html=coverage.out -o coverage.html
- - name: Upload coverage report
- if: ${{ !env.ACT && github.event_name == 'pull_request' }}
- uses: actions/upload-artifact@v4
- with:
- name: coverage-report-backend
- path: backend/coverage.html
+ # - name: Generate coverage report
+ # run: cd backend && go tool cover -html=coverage.out -o coverage.html
+ # - name: Upload coverage report
+ # if: ${{ !env.ACT && github.event_name == 'pull_request' }}
+ # uses: actions/upload-artifact@v4
+ # with:
+ # name: coverage-report-backend
+ # path: backend/coverage.html
# - name: Comment PR
# if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
# uses: actions/github-script@v7
From d8e69724baabfb6fa2977e1f23ff842d8bbf2f50 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Tue, 26 Nov 2024 13:07:35 -0500
Subject: [PATCH 39/45] check for exit code
---
.github/workflows/test-backend.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index ee67e05..b1f1156 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -43,6 +43,9 @@ jobs:
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./...
+ if [ $? -eq 1 ]; then
+ exit 1
+ fi
# - name: Generate coverage report
# run: cd backend && go tool cover -html=coverage.out -o coverage.html
# - name: Upload coverage report
From 9c2fecf2706b6509220d33faed951c7e97bdae68 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Tue, 26 Nov 2024 13:12:40 -0500
Subject: [PATCH 40/45] remove continue on error
---
.github/workflows/test-backend.yml | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index b1f1156..8363133 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -38,14 +38,10 @@ jobs:
- name: Run migrations
run: cd backend && goose -dir .sqlc/migrations postgres "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" up
- name: Run tests
- continue-on-error: true
run: |
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./...
- if [ $? -eq 1 ]; then
- exit 1
- fi
# - name: Generate coverage report
# run: cd backend && go tool cover -html=coverage.out -o coverage.html
# - name: Upload coverage report
@@ -54,9 +50,9 @@ jobs:
# with:
# name: coverage-report-backend
# path: backend/coverage.html
- # - name: Comment PR
- # if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
- # uses: actions/github-script@v7
- # with:
- # github-token: ${{ secrets.GITHUB_TOKEN }}
- # script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('backend/test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
+ - name: Comment PR
+ if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
+ uses: actions/github-script@v7
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('backend/test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
From 043e3f58b29c4b81aab267205585cdd2f67a841e Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Tue, 26 Nov 2024 13:13:11 -0500
Subject: [PATCH 41/45] generate backend html coverage
---
.github/workflows/test-backend.yml | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index 8363133..1fdb5bd 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -42,14 +42,14 @@ jobs:
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./...
- # - name: Generate coverage report
- # run: cd backend && go tool cover -html=coverage.out -o coverage.html
- # - name: Upload coverage report
- # if: ${{ !env.ACT && github.event_name == 'pull_request' }}
- # uses: actions/upload-artifact@v4
- # with:
- # name: coverage-report-backend
- # path: backend/coverage.html
+ - name: Generate coverage report
+ run: cd backend && go tool cover -html=coverage.out -o coverage.html
+ - name: Upload coverage report
+ if: ${{ !env.ACT && github.event_name == 'pull_request' }}
+ uses: actions/upload-artifact@v4
+ with:
+ name: coverage-report-backend
+ path: backend/coverage.html
- name: Comment PR
if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
uses: actions/github-script@v7
From 1252ba665d35d00e2622bb4b902d53120182079c Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Tue, 26 Nov 2024 13:16:07 -0500
Subject: [PATCH 42/45] move the coverage to html to test step
---
.github/workflows/test-backend.yml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index 1fdb5bd..25f6ea7 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -42,10 +42,9 @@ jobs:
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./...
- - name: Generate coverage report
- run: cd backend && go tool cover -html=coverage.out -o coverage.html
+ go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
- if: ${{ !env.ACT && github.event_name == 'pull_request' }}
+ if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
uses: actions/upload-artifact@v4
with:
name: coverage-report-backend
From 4f859bff2de2670b963da68f3a5277eb74f171c9 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Tue, 26 Nov 2024 13:18:52 -0500
Subject: [PATCH 43/45] separete coverage html
---
.github/workflows/test-backend.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index 25f6ea7..96b18fe 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -42,7 +42,9 @@ jobs:
# run tests and capture output
cd backend
go test -v -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
+ - name: Generate coverage report
+ if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
+ run: cd backend && go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
uses: actions/upload-artifact@v4
From 468cc57712db49dec86d0dafba4ccbd1197e5be7 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Tue, 26 Nov 2024 14:36:40 -0500
Subject: [PATCH 44/45] remove comment pr
---
.github/workflows/test-backend.yml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml
index 96b18fe..041e93c 100644
--- a/.github/workflows/test-backend.yml
+++ b/.github/workflows/test-backend.yml
@@ -51,9 +51,9 @@ jobs:
with:
name: coverage-report-backend
path: backend/coverage.html
- - name: Comment PR
- if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
- uses: actions/github-script@v7
- with:
- github-token: ${{ secrets.GITHUB_TOKEN }}
- script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('backend/test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
+ # - name: Comment PR
+ # if: ${{ !env.ACT && github.event_name == 'pull_request' && always() }}
+ # uses: actions/github-script@v7
+ # with:
+ # github-token: ${{ secrets.GITHUB_TOKEN }}
+ # script: "const fs = require('fs');\n\n// Read test output\nconst testOutput = fs.readFileSync('backend/test_output.txt', 'utf8');\n\n// Get coverage - look for the last coverage number in the output\nlet coverage = 'N/A';\nconst coverageMatches = testOutput.match(/coverage: (\\d+\\.\\d+)% of statements/g) || [];\nif (coverageMatches.length > 0) {\n const lastMatch = coverageMatches[coverageMatches.length - 1];\n coverage = lastMatch.match(/(\\d+\\.\\d+)%/)[1] + '%';\n}\n\n// Check if any tests failed\nconst hasFailed = testOutput.includes('FAIL') && !testOutput.includes('FAIL\\t[build failed]');\nconst testStatus = hasFailed ? 'failure' : 'success';\nconst color = testStatus === 'success' ? '✅' : '❌';\n\n// Parse test failures\nlet failureDetails = '';\nif (hasFailed) {\n const errorTraces = testOutput.match(/\\s+.*?_test\\.go:\\d+:[\\s\\S]*?Test:\\s+.*$/gm) || [];\n const failures = testOutput.match(/--- FAIL: .*?(?=(?:---|\\z))/gs) || [];\n \n failureDetails = `\n \n ❌ Test Failures
\n \n \\`\\`\\`\n ${failures.join('\\n')}\n \n Error Details:\n ${errorTraces.map(trace => trace.trim()).join('\\n')}\n \\`\\`\\`\n \n `;\n}\n\nconst output = `### Test Results ${color}\n\n**Status**: ${testStatus}\n**Coverage**: ${coverage}\n**OS**: \\`${{ runner.os }}\\`\n\n${failureDetails}\n\n\nTest Details
\n\n* Triggered by: @${{ github.actor }}\n* Commit: ${{ github.sha }}\n* Branch: ${{ github.ref }}\n* Workflow: ${{ github.workflow }}\n `;\n\n// Find existing comment\nconst { data: comments } = await github.rest.issues.listComments({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n});\n\nconst botComment = comments.find(comment => \n comment.user.type === 'Bot' && \n comment.body.includes('### Test Results')\n);\n\nif (botComment) {\n // Update existing comment\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: botComment.id,\n body: output\n });\n} else {\n // Create new comment\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body: output\n });\n}\n"
From 1e772b5fa187b2b18be1123148e95509ea57f6d2 Mon Sep 17 00:00:00 2001
From: jc <46619361+juancwu@users.noreply.github.com>
Date: Tue, 26 Nov 2024 14:37:24 -0500
Subject: [PATCH 45/45] output test coverage
---
backend/.gitignore | 5 ++++-
backend/Makefile | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/backend/.gitignore b/backend/.gitignore
index 164b143..af6d1cf 100644
--- a/backend/.gitignore
+++ b/backend/.gitignore
@@ -4,4 +4,7 @@ tmp
*.pem
-static
\ No newline at end of file
+static
+
+# ignore test coverage
+coverage.out
diff --git a/backend/Makefile b/backend/Makefile
index 3a8f7b3..8333cdb 100644
--- a/backend/Makefile
+++ b/backend/Makefile
@@ -73,7 +73,7 @@ start-testdb:
@goose -dir .sqlc/migrations postgres "$(TEST_DB_URL)" up
run-tests:
- @go test -v ./...
+ @go test -v -coverprofile=coverage.out ./...
stop-testdb:
@echo "Stopping test db..."