From 1e47203b61c1e8f46c19d724f5f0e2dbc764c756 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 10:55:14 +0300 Subject: [PATCH 1/9] Revert "chore(ci): remove server build temporarily" (closes #1612) This reverts commit c50a67f36b01bcb8e8f5f05ca3a7a54ee6cc1542. --- .github/workflows/nightly.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6c14f83bd..83b9c436c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -83,3 +83,36 @@ jobs: with: name: TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }} path: upload + + nightly-server: + name: Deploy server nightly + strategy: + fail-fast: false + matrix: + arch: [x64, arm64] + include: + - arch: x64 + runs-on: ubuntu-latest + - arch: arm64 + runs-on: ubuntu-24.04-arm + runs-on: ${{ matrix.runs-on }} + steps: + - uses: actions/checkout@v4 + + - name: Run the build + uses: ./.github/actions/build-server + with: + os: linux + arch: ${{ matrix.arch }} + + - name: Publish release + uses: softprops/action-gh-release@v2 + if: ${{ github.event_name != 'pull_request' }} + with: + make_latest: false + prerelease: true + draft: false + fail_on_unmatched_files: true + files: upload/*.* + tag_name: nightly + name: Nightly Build From de3fdbe01ad3222d54d42f070ca2ea703fa2f5ff Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 11:39:05 +0300 Subject: [PATCH 2/9] chore(gitignore): add upload dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 672bffee8..438043e86 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .DS_Store node_modules/ dist/ +upload/ build/ coverage/ src/public/app-dist/ From a039e15418c5dccafc7324599acec42dbd37cf71 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 11:39:12 +0300 Subject: [PATCH 3/9] feat(ci): report electron size --- .github/actions/report-size/action.yml | 79 ++++++++++++++++++++++++++ .github/workflows/dev.yml | 33 +++++++++++ 2 files changed, 112 insertions(+) create mode 100644 .github/actions/report-size/action.yml diff --git a/.github/actions/report-size/action.yml b/.github/actions/report-size/action.yml new file mode 100644 index 000000000..e39b8bab3 --- /dev/null +++ b/.github/actions/report-size/action.yml @@ -0,0 +1,79 @@ +name: 'Bundle size reporter' +description: 'Post bundle size difference compared to another branch' +inputs: + branch: + description: 'Branch to compare to' + required: true + default: 'main' + paths: + description: + 'Paths to json file bundle size report or folder containing bundles' + required: true + default: '/' + onlyDiff: + description: 'Report only different sizes' + required: false + default: 'false' + filter: + description: 'Regex filter based on file path' + required: false + unit: + description: 'Size unit' + required: false + default: 'KB' + + # Comment inputs + comment: + description: 'Post comment' + required: false + default: 'true' + header: + description: 'Comment header' + required: false + default: 'Bundle size report' + append: + description: 'Append comment' + required: false + default: 'false' + ghToken: + description: 'Github token' + required: false + +runs: + using: 'composite' + steps: + # Checkout branch to compare to [required] + - name: Checkout base branch + uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + path: br-base + token: ${{ inputs.ghToken }} + + # Generate the bundle size difference report [required] + - name: Generate report + id: bundleSize + uses: nejcm/bundle-size-reporter-action@v1.4.1 + with: + paths: ${{ inputs.paths }} + onlyDiff: ${{ inputs.onlyDiff }} + filter: ${{ inputs.filter }} + unit: ${{ inputs.unit }} + + # Post github action summary + - name: Post summary + if: ${{ steps.bundleSize.outputs.hasDifferences == 'true' }} # post only in case of changes + run: | + echo '${{ steps.bundleSize.outputs.summary }}' >> $GITHUB_STEP_SUMMARY + shell: bash + + # Post github action comment + - name: Post comment + uses: marocchino/sticky-pull-request-comment@v2 + if: ${{ steps.bundleSize.outputs.hasDifferences == 'true' }} # post only in case of changes + with: + number: ${{ github.event.pull_request.number }} + header: ${{ inputs.header }} + append: ${{ inputs.append }} + message: '${{ steps.bundleSize.outputs.summary }}' + GITHUB_TOKEN: ${{ inputs.ghToken }} diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index e7bff39e9..ae8b8a766 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -16,6 +16,39 @@ env: TEST_TAG: ${{ github.repository_owner }}/notes:test jobs: + report-electron-size: + name: Report Electron size + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "npm" + + - run: npm ci + + - name: Run the build + uses: ./.github/actions/build-electron + with: + os: linux + arch: x64 + shell: bash + forge_platform: linux + + - name: Run the Electron size report + uses: ./.github/actions/report-size + with: + paths: 'upload/**/*' + onlyDiff: 'true' + branch: 'develop' + header: 'Electron size report' + unit: 'MB' + ghToken: ${{ secrets.GITHUB_TOKEN }} + test_dev: name: Test development runs-on: ubuntu-latest From 4bf8e28595da7b1a88be9995a24003919b80de6d Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 11:58:58 +0300 Subject: [PATCH 4/9] fix(ci): add permissions to write comments --- .github/workflows/dev.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index ae8b8a766..a85707a99 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -15,6 +15,9 @@ env: IMAGE_NAME: ${{ github.repository_owner }}/notes TEST_TAG: ${{ github.repository_owner }}/notes:test +permissions: + pull-requests: write # for PR comments + jobs: report-electron-size: name: Report Electron size From acbdf98c847e535734eeedef7d1212160d9892ae Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 12:20:07 +0300 Subject: [PATCH 5/9] refactor(ci): remove unnecessary variables --- .github/actions/report-size/action.yml | 9 --------- .github/workflows/dev.yml | 1 - 2 files changed, 10 deletions(-) diff --git a/.github/actions/report-size/action.yml b/.github/actions/report-size/action.yml index e39b8bab3..739fbc08c 100644 --- a/.github/actions/report-size/action.yml +++ b/.github/actions/report-size/action.yml @@ -14,13 +14,6 @@ inputs: description: 'Report only different sizes' required: false default: 'false' - filter: - description: 'Regex filter based on file path' - required: false - unit: - description: 'Size unit' - required: false - default: 'KB' # Comment inputs comment: @@ -57,8 +50,6 @@ runs: with: paths: ${{ inputs.paths }} onlyDiff: ${{ inputs.onlyDiff }} - filter: ${{ inputs.filter }} - unit: ${{ inputs.unit }} # Post github action summary - name: Post summary diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index a85707a99..aad1ab97a 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -49,7 +49,6 @@ jobs: onlyDiff: 'true' branch: 'develop' header: 'Electron size report' - unit: 'MB' ghToken: ${{ secrets.GITHUB_TOKEN }} test_dev: From 9c2329a5e69d7c03ce190414e93a36f9c209cd8e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 12:22:57 +0300 Subject: [PATCH 6/9] feat(ci): report server size as well --- .github/workflows/dev.yml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index aad1ab97a..58f51a2b2 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -48,7 +48,38 @@ jobs: paths: 'upload/**/*' onlyDiff: 'true' branch: 'develop' - header: 'Electron size report' + header: 'Size report' + append: true + ghToken: ${{ secrets.GITHUB_TOKEN }} + report-server-size: + name: Report server size + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "npm" + + - run: npm ci + + - name: Run the build + uses: ./.github/actions/build-server + with: + os: linux + arch: x64 + + - name: Run the server size report + uses: ./.github/actions/report-size + with: + paths: 'upload/**/*' + onlyDiff: 'true' + branch: 'develop' + header: 'Size report' + append: true ghToken: ${{ secrets.GITHUB_TOKEN }} test_dev: From 194f05dc9d35e8d39199807a97a39ea7fb86b7ef Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 12:44:00 +0300 Subject: [PATCH 7/9] fix(ci): allow slashes for branch names in server build --- .github/actions/build-server/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-server/action.yml b/.github/actions/build-server/action.yml index d296838a2..13984e2ce 100644 --- a/.github/actions/build-server/action.yml +++ b/.github/actions/build-server/action.yml @@ -28,4 +28,5 @@ runs: run: | mkdir -p upload file=$(find dist -name '*.tar.xz' -print -quit) - cp "$file" "upload/TriliumNextNotes-Server-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }}.tar.xz" + name=${{ github.ref_name }} + cp "$file" "upload/TriliumNextNotes-Server-${name//\//-}-${{ inputs.os }}-${{ inputs.arch }}.tar.xz" From 8730a99aeb7696ee0c71e1390a6d6008c7beb1e8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 12:58:02 +0300 Subject: [PATCH 8/9] chore(ci): display size in MB --- .github/actions/report-size/action.yml | 9 +++++++++ .github/workflows/dev.yml | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/actions/report-size/action.yml b/.github/actions/report-size/action.yml index 739fbc08c..e39b8bab3 100644 --- a/.github/actions/report-size/action.yml +++ b/.github/actions/report-size/action.yml @@ -14,6 +14,13 @@ inputs: description: 'Report only different sizes' required: false default: 'false' + filter: + description: 'Regex filter based on file path' + required: false + unit: + description: 'Size unit' + required: false + default: 'KB' # Comment inputs comment: @@ -50,6 +57,8 @@ runs: with: paths: ${{ inputs.paths }} onlyDiff: ${{ inputs.onlyDiff }} + filter: ${{ inputs.filter }} + unit: ${{ inputs.unit }} # Post github action summary - name: Post summary diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 58f51a2b2..126bf3def 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -49,7 +49,7 @@ jobs: onlyDiff: 'true' branch: 'develop' header: 'Size report' - append: true + size: "MB" ghToken: ${{ secrets.GITHUB_TOKEN }} report-server-size: name: Report server size @@ -80,6 +80,7 @@ jobs: branch: 'develop' header: 'Size report' append: true + size: "MB" ghToken: ${{ secrets.GITHUB_TOKEN }} test_dev: From 2b8ec8f01f24f054a74574c9052733e0051d4440 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Apr 2025 12:58:55 +0300 Subject: [PATCH 9/9] fix(ci): remove appending --- .github/workflows/dev.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 126bf3def..2b1bb4c1f 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -48,8 +48,8 @@ jobs: paths: 'upload/**/*' onlyDiff: 'true' branch: 'develop' - header: 'Size report' - size: "MB" + header: 'Electron size report' + unit: "MB" ghToken: ${{ secrets.GITHUB_TOKEN }} report-server-size: name: Report server size @@ -78,9 +78,8 @@ jobs: paths: 'upload/**/*' onlyDiff: 'true' branch: 'develop' - header: 'Size report' - append: true - size: "MB" + header: 'Server size report' + unit: "MB" ghToken: ${{ secrets.GITHUB_TOKEN }} test_dev: