mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
ci: split desktop test (#3849)
This commit is contained in:
@@ -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
|
||||||
+1
-121
@@ -30,6 +30,7 @@ env:
|
|||||||
BUILD_TYPE: canary
|
BUILD_TYPE: canary
|
||||||
APP_NAME: affine
|
APP_NAME: affine
|
||||||
COVERAGE: true
|
COVERAGE: true
|
||||||
|
DISTRIBUTION: browser
|
||||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||||
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
|
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
|
||||||
|
|
||||||
@@ -409,127 +410,6 @@ jobs:
|
|||||||
path: ./tests/affine-legacy/${{ matrix.spec.package }}/test-results
|
path: ./tests/affine-legacy/${{ matrix.spec.package }}/test-results
|
||||||
if-no-files-found: ignore
|
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:
|
unit-test:
|
||||||
name: Unit Test
|
name: Unit Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
Reference in New Issue
Block a user