2023-08-20 22:29:22 +03:00
|
|
|
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:
|
2023-09-29 06:02:26 +03:00
|
|
|
- uses: actions/checkout@v4
|
2023-08-20 22:29:22 +03:00
|
|
|
- name: Setup Node.js
|
|
|
|
uses: ./.github/actions/setup-node
|
2023-09-29 06:02:26 +03:00
|
|
|
with:
|
|
|
|
electron-install: false
|
2023-08-20 22:29:22 +03:00
|
|
|
- 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:
|
2023-09-29 06:02:26 +03:00
|
|
|
- uses: actions/checkout@v4
|
2023-08-20 22:29:22 +03:00
|
|
|
- name: Setup Node.js
|
|
|
|
uses: ./.github/actions/setup-node
|
|
|
|
timeout-minutes: 10
|
|
|
|
with:
|
2023-09-29 06:02:26 +03:00
|
|
|
extra-flags: workspaces focus @affine/electron @affine/monorepo @affine-test/affine-desktop
|
2023-08-20 22:29:22 +03:00
|
|
|
playwright-install: true
|
|
|
|
hard-link-nm: false
|
2023-09-17 23:26:06 +03:00
|
|
|
|
2023-08-20 22:29:22 +03:00
|
|
|
- name: Build AFFiNE native
|
|
|
|
uses: ./.github/actions/build-rust
|
|
|
|
with:
|
|
|
|
target: ${{ matrix.spec.target }}
|
2023-08-29 13:07:05 +03:00
|
|
|
package: '@affine/native'
|
2023-08-20 22:29:22 +03:00
|
|
|
nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
|
|
|
|
- name: Run unit tests
|
|
|
|
if: ${{ matrix.spec.test }}
|
|
|
|
shell: bash
|
2023-09-29 06:02:26 +03:00
|
|
|
run: yarn workspace @affine/electron vitest
|
2023-08-20 22:29:22 +03:00
|
|
|
|
|
|
|
- name: Download core artifact
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: core
|
|
|
|
path: apps/electron/resources/web-static
|
|
|
|
|
|
|
|
- name: Build Desktop Layers
|
|
|
|
run: yarn workspace @affine/electron build
|
|
|
|
|
|
|
|
- name: Run desktop tests
|
|
|
|
if: ${{ matrix.spec.test && matrix.spec.os == 'ubuntu-latest' }}
|
2023-09-17 23:26:06 +03:00
|
|
|
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn workspace @affine-test/affine-desktop e2e
|
2023-08-20 22:29:22 +03:00
|
|
|
env:
|
|
|
|
COVERAGE: true
|
|
|
|
|
|
|
|
- name: Run desktop tests
|
|
|
|
if: ${{ matrix.spec.test && matrix.spec.os != 'ubuntu-latest' }}
|
2023-09-17 23:26:06 +03:00
|
|
|
run: yarn workspace @affine-test/affine-desktop e2e
|
2023-08-20 22:29:22 +03:00
|
|
|
env:
|
|
|
|
COVERAGE: true
|
|
|
|
|
|
|
|
- name: Make bundle
|
|
|
|
if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }}
|
|
|
|
env:
|
|
|
|
SKIP_BUNDLE: true
|
2023-09-29 06:02:26 +03:00
|
|
|
SKIP_WEB_BUILD: true
|
2023-08-20 22:29:22 +03:00
|
|
|
run: yarn workspace @affine/electron make --platform=darwin --arch=arm64
|
|
|
|
|
2023-09-17 23:26:06 +03:00
|
|
|
- name: Output check
|
2023-08-20 22:29:22 +03:00
|
|
|
if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }}
|
|
|
|
run: |
|
2023-09-29 06:02:26 +03:00
|
|
|
yarn workspace @affine/electron ts-node-esm ./scripts/macos-arm64-output-check.mts
|
2023-08-20 22:29:22 +03:00
|
|
|
|
|
|
|
- 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
|