From 940dbbe9c3b70d363e4bd4faddc5bc9ae2e27bce Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sun, 20 Aug 2023 14:29:22 -0500 Subject: [PATCH] ci: split desktop test (#3849) --- .github/workflows/build-desktop.yml | 177 ++++++++++++++++++++++++++++ .github/workflows/build.yml | 122 +------------------ 2 files changed, 178 insertions(+), 121 deletions(-) create mode 100644 .github/workflows/build-desktop.yml diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.yml new file mode 100644 index 0000000000..85c6bc72d5 --- /dev/null +++ b/.github/workflows/build-desktop.yml @@ -0,0 +1,177 @@ +name: Build(Desktop) & Test + +on: + push: + branches: + - master + - v[0-9]+.[0-9]+.x-staging + - v[0-9]+.[0-9]+.x + paths-ignore: + - README.md + - .github/** + - '!.github/workflows/build-desktop.yml' + - '!.github/actions/build-rust/action.yml' + - '!.github/actions/setup-node/action.yml' + pull_request: + merge_group: + branches: + - master + - v[0-9]+.[0-9]+.x-staging + - v[0-9]+.[0-9]+.x + paths-ignore: + - README.md + - .github/** + - '!.github/workflows/build-desktop.yml' + - '!.github/actions/build-rust/action.yml' + - '!.github/actions/setup-node/action.yml' + +env: + DEBUG: napi:* + BUILD_TYPE: canary + APP_NAME: affine + COVERAGE: true + DISTRIBUTION: desktop + MACOSX_DEPLOYMENT_TARGET: '10.13' + NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} + +jobs: + build-core: + name: Build @affine/core + runs-on: ubuntu-latest + environment: development + + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js + uses: ./.github/actions/setup-node + - name: Build Plugins + run: yarn run build:plugins + - name: Build Core + run: yarn nx build @affine/core + - name: Upload core artifact + uses: actions/upload-artifact@v3 + with: + name: core + path: ./apps/core/dist + if-no-files-found: error + + desktop-test: + name: Desktop Test + runs-on: ${{ matrix.spec.os }} + environment: development + strategy: + fail-fast: false + # all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64 + matrix: + spec: + - { + os: macos-latest, + platform: macos, + arch: x64, + target: x86_64-apple-darwin, + test: true, + } + - { + os: macos-latest, + platform: macos, + arch: arm64, + target: aarch64-apple-darwin, + test: false, + } + - { + os: ubuntu-latest, + platform: linux, + arch: x64, + target: x86_64-unknown-linux-gnu, + test: true, + } + - { + os: windows-latest, + platform: windows, + arch: x64, + target: x86_64-pc-windows-msvc, + test: true, + } + needs: build-core + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js + uses: ./.github/actions/setup-node + timeout-minutes: 10 + with: + playwright-install: true + hard-link-nm: false + - name: Build AFFiNE native + uses: ./.github/actions/build-rust + with: + target: ${{ matrix.spec.target }} + nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} + - name: Run unit tests + if: ${{ matrix.spec.test }} + shell: bash + run: yarn vitest + working-directory: ./apps/electron + + - name: Download core artifact + uses: actions/download-artifact@v3 + with: + name: core + path: apps/electron/resources/web-static + + - name: Build Plugins + run: yarn run build:plugins + + - name: Build Desktop Layers + run: yarn workspace @affine/electron build + + - name: Upload desktop dist + uses: actions/upload-artifact@v3 + with: + name: dist-${{ matrix.spec.platform }}-${{ matrix.spec.arch }} + path: ./apps/electron/dist + + - name: Run desktop tests + if: ${{ matrix.spec.test && matrix.spec.os == 'ubuntu-latest' }} + run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn workspace @affine/electron test + env: + COVERAGE: true + + - name: Run desktop tests + if: ${{ matrix.spec.test && matrix.spec.os != 'ubuntu-latest' }} + run: yarn workspace @affine/electron test + env: + COVERAGE: true + + - name: Make bundle + if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }} + env: + SKIP_BUNDLE: true + run: yarn workspace @affine/electron make --platform=darwin --arch=arm64 + + - name: Bundle output check + if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }} + run: | + yarn ts-node-esm ./scripts/macos-arm64-output-check.mts + working-directory: apps/electron + + - name: Collect code coverage report + if: ${{ matrix.spec.test }} + run: yarn exec nyc report -t .nyc_output --report-dir .coverage --reporter=lcov + + - name: Upload e2e test coverage results + if: ${{ matrix.spec.test }} + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./.coverage/lcov.info + flags: e2etest-${{ matrix.spec.os }}-${{ matrix.spec.arch }} + name: affine + fail_ci_if_error: false + + - name: Upload test results + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: test-results-e2e-${{ matrix.spec.os }}-${{ matrix.spec.arch }} + path: ./test-results + if-no-files-found: ignore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e38316dfa7..16204f27b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,7 @@ env: BUILD_TYPE: canary APP_NAME: affine COVERAGE: true + DISTRIBUTION: browser MACOSX_DEPLOYMENT_TARGET: '10.13' NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} @@ -409,127 +410,6 @@ jobs: path: ./tests/affine-legacy/${{ matrix.spec.package }}/test-results if-no-files-found: ignore - desktop-test: - name: Desktop Test - runs-on: ${{ matrix.spec.os }} - environment: development - strategy: - fail-fast: false - # all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64 - matrix: - spec: - - { - os: macos-latest, - platform: macos, - arch: x64, - target: x86_64-apple-darwin, - test: true, - } - - { - os: macos-latest, - platform: macos, - arch: arm64, - target: aarch64-apple-darwin, - test: false, - } - - { - os: ubuntu-latest, - platform: linux, - arch: x64, - target: x86_64-unknown-linux-gnu, - test: true, - } - - { - os: windows-latest, - platform: windows, - arch: x64, - target: x86_64-pc-windows-msvc, - test: true, - } - needs: build-core - steps: - - uses: actions/checkout@v3 - - name: Setup Node.js - uses: ./.github/actions/setup-node - timeout-minutes: 10 - with: - playwright-install: true - hard-link-nm: false - - name: Build AFFiNE native - uses: ./.github/actions/build-rust - with: - target: ${{ matrix.spec.target }} - nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} - - name: Run unit tests - if: ${{ matrix.spec.test }} - shell: bash - run: yarn vitest - working-directory: ./apps/electron - - - name: Download core artifact - uses: actions/download-artifact@v3 - with: - name: core - path: apps/electron/resources/web-static - - - name: Build Plugins - run: yarn run build:plugins - - - name: Build Desktop Layers - run: yarn workspace @affine/electron build - - - name: Upload desktop dist - uses: actions/upload-artifact@v3 - with: - name: dist-${{ matrix.spec.platform }}-${{ matrix.spec.arch }} - path: ./apps/electron/dist - - - name: Run desktop tests - if: ${{ matrix.spec.test && matrix.spec.os == 'ubuntu-latest' }} - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn workspace @affine/electron test - env: - COVERAGE: true - - - name: Run desktop tests - if: ${{ matrix.spec.test && matrix.spec.os != 'ubuntu-latest' }} - run: yarn workspace @affine/electron test - env: - COVERAGE: true - - - name: Make bundle - if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }} - env: - SKIP_BUNDLE: true - run: yarn workspace @affine/electron make --platform=darwin --arch=arm64 - - - name: Bundle output check - if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }} - run: | - yarn ts-node-esm ./scripts/macos-arm64-output-check.mts - working-directory: apps/electron - - - name: Collect code coverage report - if: ${{ matrix.spec.test }} - run: yarn exec nyc report -t .nyc_output --report-dir .coverage --reporter=lcov - - - name: Upload e2e test coverage results - if: ${{ matrix.spec.test }} - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./.coverage/lcov.info - flags: e2etest-${{ matrix.spec.os }}-${{ matrix.spec.arch }} - name: affine - fail_ci_if_error: false - - - name: Upload test results - if: ${{ failure() }} - uses: actions/upload-artifact@v3 - with: - name: test-results-e2e-${{ matrix.spec.os }}-${{ matrix.spec.arch }} - path: ./test-results - if-no-files-found: ignore - unit-test: name: Unit Test runs-on: ubuntu-latest