From 7a34b7f5019458967492272c2cfba565e365e723 Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:06:01 +0200 Subject: [PATCH 1/9] feat: add bundle stat monitoring --- .github/workflows/bundle-stats.yml | 44 ++++++++++++++++++++++++++++++ packages/backend/package.json | 1 + packages/backend/vite.config.ts | 2 ++ yarn.lock | 14 ++++++++-- 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/bundle-stats.yml diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml new file mode 100644 index 00000000..12c9098a --- /dev/null +++ b/.github/workflows/bundle-stats.yml @@ -0,0 +1,44 @@ +name: Comment with HTML on Commit + +on: + push: + branches: + - main # Adjust this if you want to target a different branch + +jobs: + generate-and-comment: + runs-on: ubuntu-latest + + steps: + # Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v2 + + # Generate the HTML file + # Replace this with the actual command to generate your HTML + - name: Generate HTML + run: | + echo '

Hello, World!

' > output.html + + # Read the generated HTML content + - name: Read HTML Content + id: read_html + run: | + html_content=$(cat output.html) + echo "::set-output name=html_content::$html_content" + + # Add a comment to the commit + - name: Comment on Commit + uses: peter-evans/create-or-update-comment@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + commit-id: ${{ github.sha }} + body: | +
+ Generated HTML +
+              ${{ steps.read_html.outputs.html_content }}
+              
+
+ diff --git a/packages/backend/package.json b/packages/backend/package.json index ae51ba39..02967096 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -43,6 +43,7 @@ "kysely-codegen": "^0.11.0", "postgres": "^3.4.3", "rollup-plugin-node-externals": "^7.1.1", + "rollup-plugin-visualizer": "^5.12.0", "typescript": "^5.4.5", "vitest": "^1.1.0" } diff --git a/packages/backend/vite.config.ts b/packages/backend/vite.config.ts index 3d0002a9..3d8deaf9 100644 --- a/packages/backend/vite.config.ts +++ b/packages/backend/vite.config.ts @@ -2,6 +2,7 @@ import { defineConfig } from 'vitest/config'; import packageJson from './package.json'; import path from 'path'; import { nodeExternals } from 'rollup-plugin-node-externals'; +import { visualizer } from 'rollup-plugin-visualizer'; const resolveXqlAliases = Object.keys(packageJson.dependencies) .filter((dep) => dep.startsWith('@synthql/')) @@ -30,6 +31,7 @@ export default defineConfig({ deps: true, peerDeps: true, }), + visualizer({ filename: "./build/stats.html" }) ], }, }, diff --git a/yarn.lock b/yarn.lock index 4515297e..7350dc10 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11091,6 +11091,16 @@ rollup-plugin-node-externals@^7.1.1: resolved "https://registry.yarnpkg.com/rollup-plugin-node-externals/-/rollup-plugin-node-externals-7.1.1.tgz#2a61e362a842fe15406fff86823392d2f5c79599" integrity sha512-rnIUt0zYdV05muRetoxOiFiKxrrfiyXuM/CgI+akv6NExBTaIiPkH2rCSE9JUCsjta1MXzQVAldpe5tJEszlwQ== +rollup-plugin-visualizer@^5.12.0: + version "5.12.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-5.12.0.tgz#661542191ce78ee4f378995297260d0c1efb1302" + integrity sha512-8/NU9jXcHRs7Nnj07PF2o4gjxmm9lXIrZ8r175bT9dK8qoLlvKTwRMArRCMgpMGlq8CTLugRvEmyMeMXIU2pNQ== + dependencies: + open "^8.4.0" + picomatch "^2.3.1" + source-map "^0.7.4" + yargs "^17.5.1" + rollup@^4.2.0: version "4.9.2" resolved "https://registry.npmjs.org/rollup/-/rollup-4.9.2.tgz" @@ -11569,7 +11579,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -source-map@^0.7.0: +source-map@^0.7.0, source-map@^0.7.4: version "0.7.4" resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz" integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA== @@ -13037,7 +13047,7 @@ yargs-parser@21.1.1, yargs-parser@^21.1.1: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== -yargs@^17.6.2, yargs@^17.7.2: +yargs@^17.5.1, yargs@^17.6.2, yargs@^17.7.2: version "17.7.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== From b4d762c064bab6cd811fda73111177517ab8d584 Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:08:23 +0200 Subject: [PATCH 2/9] adjust branches --- .github/workflows/bundle-stats.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml index 12c9098a..182438b3 100644 --- a/.github/workflows/bundle-stats.yml +++ b/.github/workflows/bundle-stats.yml @@ -2,8 +2,9 @@ name: Comment with HTML on Commit on: push: - branches: - - main # Adjust this if you want to target a different branch + branches-ignore: + - master + - gh-pages jobs: generate-and-comment: From 0603f21112677836e5516bb1c2401dec3fef49d4 Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:12:10 +0200 Subject: [PATCH 3/9] format --- .github/workflows/bundle-stats.yml | 69 ++++++++++++++---------------- packages/backend/vite.config.ts | 2 +- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml index 182438b3..3994a2ce 100644 --- a/.github/workflows/bundle-stats.yml +++ b/.github/workflows/bundle-stats.yml @@ -1,45 +1,42 @@ name: Comment with HTML on Commit on: - push: - branches-ignore: - - master - - gh-pages + push: + branches-ignore: + - master + - gh-pages jobs: - generate-and-comment: - runs-on: ubuntu-latest + generate-and-comment: + runs-on: ubuntu-latest - steps: - # Checkout the repository - - name: Checkout Repository - uses: actions/checkout@v2 + steps: + # Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v2 - # Generate the HTML file - # Replace this with the actual command to generate your HTML - - name: Generate HTML - run: | - echo '

Hello, World!

' > output.html + # Generate the HTML file + # Replace this with the actual command to generate your HTML + - name: Generate HTML + run: | + echo '

Hello, World!

' > output.html - # Read the generated HTML content - - name: Read HTML Content - id: read_html - run: | - html_content=$(cat output.html) - echo "::set-output name=html_content::$html_content" - - # Add a comment to the commit - - name: Comment on Commit - uses: peter-evans/create-or-update-comment@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - repository: ${{ github.repository }} - commit-id: ${{ github.sha }} - body: | -
- Generated HTML -
-              ${{ steps.read_html.outputs.html_content }}
-              
-
+ # Read the generated HTML content + - name: Read HTML Content + id: read_html + run: | + html_content=$(cat output.html) + echo "::set-output name=html_content::$html_content" + # Add a comment to the commit + - name: Comment on Commit + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | +
+ Generated HTML +
+                        ${{ steps.read_html.outputs.html_content }}
+                        
+
diff --git a/packages/backend/vite.config.ts b/packages/backend/vite.config.ts index 3d8deaf9..487a1271 100644 --- a/packages/backend/vite.config.ts +++ b/packages/backend/vite.config.ts @@ -31,7 +31,7 @@ export default defineConfig({ deps: true, peerDeps: true, }), - visualizer({ filename: "./build/stats.html" }) + visualizer({ filename: './build/stats.html' }), ], }, }, From 662794a169e947bbb87b2ba47b132a0739dface7 Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:14:23 +0200 Subject: [PATCH 4/9] wip --- .github/workflows/bundle-stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml index 3994a2ce..6b8170de 100644 --- a/.github/workflows/bundle-stats.yml +++ b/.github/workflows/bundle-stats.yml @@ -7,7 +7,7 @@ on: - gh-pages jobs: - generate-and-comment: + comment-with-bundle-stats: runs-on: ubuntu-latest steps: From 03214f01cac57acf6aeee1dd735a52677690a2dd Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:22:06 +0200 Subject: [PATCH 5/9] fix --- .github/workflows/bundle-stats.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml index 6b8170de..6b051d57 100644 --- a/.github/workflows/bundle-stats.yml +++ b/.github/workflows/bundle-stats.yml @@ -28,15 +28,24 @@ jobs: html_content=$(cat output.html) echo "::set-output name=html_content::$html_content" - # Add a comment to the commit - - name: Comment on Commit + - name: Find Comment + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Bundle Stats + + - name: Create or update comment uses: peter-evans/create-or-update-comment@v4 with: + comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} body: | + Build output +
- Generated HTML -
-                        ${{ steps.read_html.outputs.html_content }}
-                        
+ Bundle Stats +

more details

+ edit-mode: replace From 48bbae5874766f7d7e9ccb0cf19bbc3005e219ba Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:25:33 +0200 Subject: [PATCH 6/9] wip --- .github/workflows/bundle-stats.yml | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml index 6b051d57..c8ea16bb 100644 --- a/.github/workflows/bundle-stats.yml +++ b/.github/workflows/bundle-stats.yml @@ -28,24 +28,14 @@ jobs: html_content=$(cat output.html) echo "::set-output name=html_content::$html_content" - - name: Find Comment - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: Bundle Stats - - - name: Create or update comment + - name: Create comment uses: peter-evans/create-or-update-comment@v4 with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - Build output - -
- Bundle Stats -

more details

-
- edit-mode: replace + issue-number: 1 + body: | + This is a multi-line test comment + - With GitHub **Markdown** :sparkles: + - Created by [create-or-update-comment][1] + + [1]: https://github.com/peter-evans/create-or-update-comment + reactions: '+1' From f9cb3c55aedd37121a68b206e6cdeb14eb8472ea Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:28:59 +0200 Subject: [PATCH 7/9] fix --- .github/workflows/bundle-stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml index c8ea16bb..02479293 100644 --- a/.github/workflows/bundle-stats.yml +++ b/.github/workflows/bundle-stats.yml @@ -31,7 +31,7 @@ jobs: - name: Create comment uses: peter-evans/create-or-update-comment@v4 with: - issue-number: 1 + issue-number: ${{ github.event.pull_request.number }} body: | This is a multi-line test comment - With GitHub **Markdown** :sparkles: From 688c537f79fe73e871afe32481cdf985b19b58f1 Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:30:26 +0200 Subject: [PATCH 8/9] fix --- .github/workflows/bundle-stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml index 02479293..c9c2e7c5 100644 --- a/.github/workflows/bundle-stats.yml +++ b/.github/workflows/bundle-stats.yml @@ -31,7 +31,7 @@ jobs: - name: Create comment uses: peter-evans/create-or-update-comment@v4 with: - issue-number: ${{ github.event.pull_request.number }} + issue-number: ${{ github.event.number }} body: | This is a multi-line test comment - With GitHub **Markdown** :sparkles: From 9cc31cd15fb4de0bf650836f1e189631a826b18f Mon Sep 17 00:00:00 2001 From: Fernando Hurtado Date: Thu, 30 May 2024 23:35:14 +0200 Subject: [PATCH 9/9] fix --- .github/workflows/bundle-stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bundle-stats.yml b/.github/workflows/bundle-stats.yml index c9c2e7c5..b98537fe 100644 --- a/.github/workflows/bundle-stats.yml +++ b/.github/workflows/bundle-stats.yml @@ -1,7 +1,7 @@ name: Comment with HTML on Commit on: - push: + pull_request: branches-ignore: - master - gh-pages @@ -31,7 +31,7 @@ jobs: - name: Create comment uses: peter-evans/create-or-update-comment@v4 with: - issue-number: ${{ github.event.number }} + issue-number: ${{github.event.number}} body: | This is a multi-line test comment - With GitHub **Markdown** :sparkles: