From 0e8785e7ac598c849b93b4acb23a54a4e7f53e48 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 15 Apr 2025 08:57:28 +0100 Subject: [PATCH 1/3] Test release assets before deploy (#2257) --- .github/workflows/build_and_test.yaml | 96 ++------------------------- .github/workflows/build_linux.yaml | 11 +++ .github/workflows/build_macos.yaml | 14 ++++ .github/workflows/build_test.yaml | 68 +++++++++++++++++++ .github/workflows/build_windows.yaml | 10 +++ 5 files changed, 107 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/build_test.yaml diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index e3274ce1..bb294574 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -43,96 +43,8 @@ jobs: name: macOS uses: ./.github/workflows/build_macos.yaml - test: - needs: - - macos - - linux - - windows - strategy: - fail-fast: false - matrix: - include: - - name: macOS Universal - os: macos-14 - artifact: macos - executable: "/Users/runner/Applications/Element.app/Contents/MacOS/Element" - # We need to mount the DMG and copy the app to the Applications folder as a mounted DMG is - # read-only and thus would not allow us to override the fuses as is required for Playwright. - prepare_cmd: | - hdiutil attach ./dist/*.dmg -mountpoint /Volumes/Element && - rsync -a /Volumes/Element/Element.app ~/Applications/ && - hdiutil detach /Volumes/Element - - name: "Linux (amd64) (sqlcipher: system)" - os: ubuntu-22.04 - artifact: linux-amd64-sqlcipher-system - executable: "/opt/Element/element-desktop" - prepare_cmd: "sudo apt-get -qq update && sudo apt install ./dist/*.deb" - - name: "Linux (amd64) (sqlcipher: static)" - os: ubuntu-22.04 - artifact: linux-amd64-sqlcipher-static - executable: "/opt/Element/element-desktop" - prepare_cmd: "sudo apt-get -qq update && sudo apt install ./dist/*.deb" - - name: "Linux (arm64) (sqlcipher: system)" - os: ubuntu-22.04-arm - artifact: linux-arm64-sqlcipher-system - executable: "/opt/Element/element-desktop" - prepare_cmd: "sudo apt-get -qq update && sudo apt install -y ./dist/*.deb" - - name: "Linux (arm64) (sqlcipher: static)" - os: ubuntu-22.04-arm - artifact: linux-arm64-sqlcipher-static - executable: "/opt/Element/element-desktop" - prepare_cmd: "sudo apt-get -qq update && sudo apt install -y ./dist/*.deb" - - name: Windows (x86) - os: windows-2022 - artifact: win-ia32 - executable: "./dist/win-ia32-unpacked/Element.exe" - - name: Windows (x64) - os: windows-2022 - artifact: win-x64 - executable: "./dist/win-unpacked/Element.exe" - name: Test ${{ matrix.name }} - runs-on: ${{ matrix.os }} + tests-done: + needs: [windows, linux, macos] + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version-file: .node-version - cache: "yarn" - - - name: Install Deps - run: "yarn install --frozen-lockfile" - - - uses: actions/download-artifact@v4 - with: - name: ${{ matrix.artifact }} - path: dist - - - name: Prepare for tests - run: ${{ matrix.prepare_cmd }} - if: matrix.prepare_cmd - - # We previously disabled the `EnableNodeCliInspectArguments` fuse, but Playwright requires - # it to be enabled to test Electron apps, so turn it back on. - - name: Set EnableNodeCliInspectArguments fuse enabled - run: $RUN_AS npx @electron/fuses write --app ${{ matrix.executable }} EnableNodeCliInspectArguments=on - shell: bash - env: - # We need sudo on Linux as it is installed in /opt/ - RUN_AS: ${{ runner.os == 'Linux' && 'sudo' || '' }} - - - name: Run tests - uses: coactions/setup-xvfb@6b00cf1889f4e1d5a48635647013c0508128ee1a - timeout-minutes: 5 - with: - run: "yarn test ${{ runner.os != 'Linux' && '--ignore-snapshots' || '' }}" - env: - ELEMENT_DESKTOP_EXECUTABLE: ${{ matrix.executable }} - - - name: Upload HTML report - if: always() - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.artifact }}-test - path: playwright/html-report - retention-days: 14 + - run: echo "Tests successful" diff --git a/.github/workflows/build_linux.yaml b/.github/workflows/build_linux.yaml index 4fae86e4..a092c61e 100644 --- a/.github/workflows/build_linux.yaml +++ b/.github/workflows/build_linux.yaml @@ -183,3 +183,14 @@ jobs: test -f ./dist/element-desktop*.tar.gz env: ARCH: ${{ inputs.arch }} + + test: + needs: build + uses: ./.github/workflows/build_test.yaml + with: + artifact: linux-${{ inputs.arch }}-sqlcipher-${{ inputs.sqlcipher }} + runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04' }} + executable: /opt/Element/element-desktop + prepare_cmd: | + sudo apt-get -qq update + sudo apt install ./dist/*.deb diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index 7d4b88d6..22c63f09 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -145,3 +145,17 @@ jobs: run: | test -f ./dist/Element*.dmg test -f ./dist/Element*-mac.zip + + test: + needs: build + uses: ./.github/workflows/build_test.yaml + with: + artifact: macos + runs-on: macos-14 + executable: /Users/runner/Applications/Element.app/Contents/MacOS/Element + # We need to mount the DMG and copy the app to the Applications folder as a mounted DMG is + # read-only and thus would not allow us to override the fuses as is required for Playwright. + prepare_cmd: | + hdiutil attach ./dist/*.dmg -mountpoint /Volumes/Element && + rsync -a /Volumes/Element/Element.app ~/Applications/ && + hdiutil detach /Volumes/Element diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml new file mode 100644 index 00000000..afcea94e --- /dev/null +++ b/.github/workflows/build_test.yaml @@ -0,0 +1,68 @@ +# This action helps run Playwright tests within one of the build_* stages. +on: + workflow_call: + inputs: + runs-on: + type: string + required: true + description: "The runner image to use" + artifact: + type: string + required: true + description: "The name of the artifact to download" + executable: + type: string + required: true + description: "Path to the executable to test" + prepare_cmd: + type: string + required: false + description: "Command to run to prepare the executable or environment for testing" +permissions: {} +jobs: + test: + runs-on: ${{ inputs.runs-on }} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: "yarn" + + - name: Install Deps + run: "yarn install --frozen-lockfile" + + - uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact }} + path: dist + + - name: Prepare for tests + run: ${{ inputs.prepare_cmd }} + if: inputs.prepare_cmd + + # We previously disabled the `EnableNodeCliInspectArguments` fuse, but Playwright requires + # it to be enabled to test Electron apps, so turn it back on. + - name: Set EnableNodeCliInspectArguments fuse enabled + run: $RUN_AS npx @electron/fuses write --app ${{ inputs.executable }} EnableNodeCliInspectArguments=on + shell: bash + env: + # We need sudo on Linux as it is installed in /opt/ + RUN_AS: ${{ runner.os == 'Linux' && 'sudo' || '' }} + + - name: Run tests + uses: coactions/setup-xvfb@6b00cf1889f4e1d5a48635647013c0508128ee1a + timeout-minutes: 5 + with: + run: "yarn test ${{ runner.os != 'Linux' && '--ignore-snapshots' || '' }}" + env: + ELEMENT_DESKTOP_EXECUTABLE: ${{ inputs.executable }} + + - name: Upload HTML report + if: always() + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact }}-test + path: playwright/html-report + retention-days: 14 diff --git a/.github/workflows/build_windows.yaml b/.github/workflows/build_windows.yaml index 00f63511..53d5b008 100644 --- a/.github/workflows/build_windows.yaml +++ b/.github/workflows/build_windows.yaml @@ -216,3 +216,13 @@ jobs: Test-Path './dist/squirrel-windows*/element-desktop-*-full.nupkg' Test-Path './dist/squirrel-windows*/RELEASES' Test-Path './dist/Element*.msi' + + test: + needs: build + uses: ./.github/workflows/build_test.yaml + # We have no Windows ARM64 runners at this time + if: inputs.arch != 'arm64' + with: + artifact: win-${{ inputs.arch }} + runs-on: windows-2022 + executable: ${{ inputs.arch == 'ia32' && './dist/win-ia32-unpacked/Element.exe' || './dist/win-unpacked/Element.exe' }} From 2cdf1cf3b6c28bda3332c9e0cbff98e657d6878e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 15 Apr 2025 10:20:58 +0100 Subject: [PATCH 2/3] Attempt to fix tests for Nightly builds Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .github/workflows/build_linux.yaml | 2 +- .github/workflows/build_macos.yaml | 4 ++-- .github/workflows/build_windows.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_linux.yaml b/.github/workflows/build_linux.yaml index a092c61e..5af0f622 100644 --- a/.github/workflows/build_linux.yaml +++ b/.github/workflows/build_linux.yaml @@ -190,7 +190,7 @@ jobs: with: artifact: linux-${{ inputs.arch }}-sqlcipher-${{ inputs.sqlcipher }} runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04' }} - executable: /opt/Element/element-desktop + executable: /opt/Element/element-desktop* prepare_cmd: | sudo apt-get -qq update sudo apt install ./dist/*.deb diff --git a/.github/workflows/build_macos.yaml b/.github/workflows/build_macos.yaml index 22c63f09..0cb9c511 100644 --- a/.github/workflows/build_macos.yaml +++ b/.github/workflows/build_macos.yaml @@ -152,10 +152,10 @@ jobs: with: artifact: macos runs-on: macos-14 - executable: /Users/runner/Applications/Element.app/Contents/MacOS/Element + executable: /Users/runner/Applications/Element*.app/Contents/MacOS/Element* # We need to mount the DMG and copy the app to the Applications folder as a mounted DMG is # read-only and thus would not allow us to override the fuses as is required for Playwright. prepare_cmd: | hdiutil attach ./dist/*.dmg -mountpoint /Volumes/Element && - rsync -a /Volumes/Element/Element.app ~/Applications/ && + rsync -a /Volumes/Element/Element*.app ~/Applications/ && hdiutil detach /Volumes/Element diff --git a/.github/workflows/build_windows.yaml b/.github/workflows/build_windows.yaml index 53d5b008..e3638d2f 100644 --- a/.github/workflows/build_windows.yaml +++ b/.github/workflows/build_windows.yaml @@ -225,4 +225,4 @@ jobs: with: artifact: win-${{ inputs.arch }} runs-on: windows-2022 - executable: ${{ inputs.arch == 'ia32' && './dist/win-ia32-unpacked/Element.exe' || './dist/win-unpacked/Element.exe' }} + executable: ./dist/win*-unpacked/Element*.exe From fca69978aab3100ec7a1ac0a055dce90222ee00f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 15 Apr 2025 10:41:09 +0100 Subject: [PATCH 3/3] Attempt to fix tests for Nightly builds Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .github/workflows/build_test.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml index afcea94e..39fd8850 100644 --- a/.github/workflows/build_test.yaml +++ b/.github/workflows/build_test.yaml @@ -42,14 +42,24 @@ jobs: run: ${{ inputs.prepare_cmd }} if: inputs.prepare_cmd + - name: Expand executable path + id: executable + shell: bash + env: + EXECUTABLE: ${{ inputs.executable }} + run: | + FILES=($EXECUTABLE) + echo "path=${FILES[0]}" >> $GITHUB_OUTPUT + # We previously disabled the `EnableNodeCliInspectArguments` fuse, but Playwright requires # it to be enabled to test Electron apps, so turn it back on. - name: Set EnableNodeCliInspectArguments fuse enabled - run: $RUN_AS npx @electron/fuses write --app ${{ inputs.executable }} EnableNodeCliInspectArguments=on + run: $RUN_AS npx @electron/fuses write --app "$EXECUTABLE" EnableNodeCliInspectArguments=on shell: bash env: # We need sudo on Linux as it is installed in /opt/ RUN_AS: ${{ runner.os == 'Linux' && 'sudo' || '' }} + EXECUTABLE: ${{ steps.executable.outputs.path }} - name: Run tests uses: coactions/setup-xvfb@6b00cf1889f4e1d5a48635647013c0508128ee1a @@ -57,7 +67,7 @@ jobs: with: run: "yarn test ${{ runner.os != 'Linux' && '--ignore-snapshots' || '' }}" env: - ELEMENT_DESKTOP_EXECUTABLE: ${{ inputs.executable }} + ELEMENT_DESKTOP_EXECUTABLE: ${{ steps.executable.outputs.path }} - name: Upload HTML report if: always()