mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-11-28 08:24:27 +03:00
## Summary The changes below are prepared locally and have not been committed or pushed. - Save original URLs, user titles, selected text, images and PDFs through a versioned, file-backed Share Inbox. Stable document/attempt IDs, serialized imports and committed receipts make retries preserve user edits and recover native completion. - Keep rich previews transient. Share previews request transcript excerpts, clip optional display fields and bound response/image downloads. Saving does not wait for preview requests or persist provider metadata, transcript snapshots or dedicated preview blobs. - Restore the minimal App Group workspace-mode snapshot and `official`/`deferred` route. Official routes remain fixed for the pending share; deferred self-hosted previews use the selected server without a provider fallback. - Let bookmark and YouTube details read the current workspace's Link Preview API by URL. Full transcripts, chapters and timestamps load on expansion without document writes. Reuse editor styles and the existing portal for canvas details; isolate endpoint/base/transcript caches and keep transcript results out of persistent cache. ## Validation - Focused frontend suites: 128 tests passed; the 43 preview/details cases also passed after the final portal change. - `ShareInboxSafetyTests`: 57 tests passed on iOS 26.5 simulator. - `yarn typecheck` and full `yarn lint` passed. - iOS web bundle, Capacitor asset copy, and signed simulator App build with embedded ShareExtension passed. - Browser component checks: desktop, narrow viewport, light/dark themes, full transcript scrolling, canvas portal positioning and Escape dismissal. - Simulator Safari share: rich preview, cancellation, native-to-app handoff, workspace selection and successful save. The pending manifest contained original content and routing only, and was removed after import. Physical-device and network-capture matrices remain manual. The simulator YouTube iframe displayed player error 153; this is separate from the successful preview/import checks and video playback is not claimed as verified. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * iOS sharing now supports PDF files alongside images, with previews and attachment validation. * Share imports offer improved workspace selection, offline handling, retry recovery, and clearer error messages. * Link previews can display expandable metadata and transcript details for bookmarks and YouTube embeds. * Share inbox entries now identify unsupported versions and provide safer attachment resolution. * **Bug Fixes** * Improved cancellation, cleanup, and stale-request handling during sharing and importing. * Enhanced link-preview validation and protection against oversized or invalid responses. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: DarkSky <darksky2048@gmail.com>
1717 lines
53 KiB
YAML
1717 lines
53 KiB
YAML
name: Build & Test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- canary
|
|
- beta
|
|
- stable
|
|
- v[0-9]+.[0-9]+.x-staging
|
|
- v[0-9]+.[0-9]+.x
|
|
paths-ignore:
|
|
- README.md
|
|
pull_request:
|
|
merge_group:
|
|
|
|
env:
|
|
DEBUG: napi:*
|
|
BUILD_TYPE: canary
|
|
APP_NAME: affine
|
|
AFFINE_ENV: dev
|
|
COVERAGE: true
|
|
MACOSX_DEPLOYMENT_TARGET: '11.6'
|
|
DEPLOYMENT_TYPE: affine
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
analyze:
|
|
name: Analyze
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
NODE_OPTIONS: --max-old-space-size=14384
|
|
permissions:
|
|
actions: read
|
|
contents: read
|
|
security-events: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
language: ['javascript', 'typescript']
|
|
project: ['affine', 'blocksuite']
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Initialize CodeQL
|
|
uses: github/codeql-action/init@v3
|
|
with:
|
|
languages: ${{ matrix.language }}
|
|
source-root: ${{ matrix.project == 'affine' && '.' || 'blocksuite' }}
|
|
|
|
- name: Delete blocksuite before codeql analysis
|
|
if: ${{ matrix.project == 'affine' }}
|
|
run: rm -rf blocksuite
|
|
|
|
- name: Autobuild
|
|
uses: github/codeql-action/autobuild@v3
|
|
|
|
- name: Perform CodeQL Analysis
|
|
uses: github/codeql-action/analyze@v3
|
|
lint:
|
|
name: Lint
|
|
runs-on: ubuntu-24.04-arm
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Go (for actionlint)
|
|
uses: actions/setup-go@v7
|
|
with:
|
|
go-version: 'stable'
|
|
- name: Install actionlint
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.11
|
|
- name: Run actionlint
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
"$(go env GOPATH)/bin/actionlint"
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
electron-install: false
|
|
full-cache: true
|
|
- name: Run oxlint
|
|
run: yarn lint:ox
|
|
- name: Run i18n codegen
|
|
run: yarn affine @affine/i18n build
|
|
- name: Run Oxfmt
|
|
# Set nmMode in `actions/setup-node` will modify the .yarnrc.yml
|
|
run: |
|
|
git checkout .yarnrc.yml
|
|
yarn lint:format
|
|
- name: Yarn Dedupe
|
|
run: yarn dedupe --check
|
|
|
|
typecheck:
|
|
name: Typecheck
|
|
runs-on: ubuntu-24.04-arm
|
|
env:
|
|
NODE_OPTIONS: --max-old-space-size=14384
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
electron-install: false
|
|
full-cache: true
|
|
- name: Run i18n codegen
|
|
run: |
|
|
yarn affine @affine/i18n build
|
|
git checkout packages/frontend/i18n/src/i18n-completenesses.json
|
|
if git status --porcelain | grep -q .; then
|
|
echo "Run 'yarn affine @affine/i18n build' and make sure all generated i18n changes are submitted"
|
|
exit 1
|
|
else
|
|
echo "All generated i18n changes are submitted"
|
|
fi
|
|
- name: Run Type Check
|
|
run: yarn typecheck
|
|
- name: Run BS Docs Build
|
|
run: |
|
|
yarn affine bs-docs build
|
|
if git status --porcelain | grep -q .; then
|
|
echo "Run 'yarn typecheck && yarn affine bs-docs build' and make sure all changes are submitted"
|
|
exit 1
|
|
else
|
|
echo "All changes are submitted"
|
|
fi
|
|
|
|
mobile-native-build-filter:
|
|
name: Mobile native build filter
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
run-android: ${{ steps.mobile-native-filter.outputs.android }}
|
|
run-ios: ${{ steps.mobile-native-filter.outputs.ios }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: dorny/paths-filter@v3
|
|
id: mobile-native-filter
|
|
with:
|
|
filters: |
|
|
android:
|
|
- '.github/workflows/build-test.yml'
|
|
- 'packages/frontend/apps/android/**'
|
|
- 'packages/frontend/mobile-native/**'
|
|
- '.cargo/**'
|
|
- 'Cargo.lock'
|
|
- 'Cargo.toml'
|
|
- 'rust-toolchain*'
|
|
ios:
|
|
- '.github/workflows/build-test.yml'
|
|
- 'packages/frontend/apps/ios/**'
|
|
- 'packages/frontend/mobile-native/**'
|
|
- '.cargo/**'
|
|
- 'Cargo.lock'
|
|
- 'Cargo.toml'
|
|
- 'rust-toolchain*'
|
|
|
|
build-android-app:
|
|
name: Build Android app
|
|
if: ${{ needs.mobile-native-build-filter.outputs.run-android == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- mobile-native-build-filter
|
|
env:
|
|
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16'
|
|
CARGO_PROFILE_RELEASE_DEBUG: '1'
|
|
CARGO_PROFILE_RELEASE_LTO: 'thin'
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-tools/cli @affine/android
|
|
electron-install: false
|
|
|
|
- uses: actions/setup-java@v5
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '21'
|
|
cache: 'gradle'
|
|
|
|
- name: Setup Rust
|
|
uses: ./.github/actions/build-rust
|
|
with:
|
|
target: 'aarch64-linux-android'
|
|
package: 'affine_mobile_native'
|
|
no-build: 'true'
|
|
|
|
- name: Build Android web assets
|
|
run: yarn affine @affine/android build
|
|
env:
|
|
PUBLIC_PATH: '/'
|
|
|
|
- name: Write CI Firebase config
|
|
run: |
|
|
cat > packages/frontend/apps/android/App/app/google-services.json <<'JSON'
|
|
{
|
|
"project_info": {
|
|
"project_number": "1",
|
|
"project_id": "affine-ci",
|
|
"storage_bucket": "affine-ci.appspot.com"
|
|
},
|
|
"client": [
|
|
{
|
|
"client_info": {
|
|
"mobilesdk_app_id": "1:1:android:0000000000000000",
|
|
"android_client_info": {
|
|
"package_name": "app.affine.pro"
|
|
}
|
|
},
|
|
"oauth_client": [],
|
|
"api_key": [
|
|
{
|
|
"current_key": "ci-placeholder"
|
|
}
|
|
],
|
|
"services": {
|
|
"appinvite_service": {
|
|
"other_platform_oauth_client": []
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"configuration_version": "1"
|
|
}
|
|
JSON
|
|
|
|
- name: Cap sync
|
|
run: yarn workspace @affine/android cap sync
|
|
|
|
- name: Build Android debug app
|
|
working-directory: packages/frontend/apps/android/App
|
|
run: ./gradlew :app:assembleCanaryDebug --no-daemon --stacktrace
|
|
|
|
test-android-app:
|
|
name: Test Android app
|
|
if: ${{ needs.mobile-native-build-filter.outputs.run-android == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 40
|
|
needs:
|
|
- mobile-native-build-filter
|
|
env:
|
|
AFFINE_ANDROID_NATIVE_TARGET: x86_64
|
|
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16'
|
|
CARGO_PROFILE_RELEASE_DEBUG: '1'
|
|
CARGO_PROFILE_RELEASE_LTO: 'thin'
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-tools/cli @affine/android
|
|
electron-install: false
|
|
|
|
- uses: actions/setup-java@v5
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '21'
|
|
cache: 'gradle'
|
|
|
|
- name: Setup Rust
|
|
uses: ./.github/actions/build-rust
|
|
with:
|
|
target: 'x86_64-linux-android'
|
|
package: 'affine_mobile_native'
|
|
no-build: 'true'
|
|
|
|
- name: Build Android web assets
|
|
run: yarn affine @affine/android build
|
|
env:
|
|
PUBLIC_PATH: '/'
|
|
|
|
- name: Write CI Firebase config
|
|
run: |
|
|
cat > packages/frontend/apps/android/App/app/google-services.json <<'JSON'
|
|
{
|
|
"project_info": {
|
|
"project_number": "1",
|
|
"project_id": "affine-ci",
|
|
"storage_bucket": "affine-ci.appspot.com"
|
|
},
|
|
"client": [
|
|
{
|
|
"client_info": {
|
|
"mobilesdk_app_id": "1:1:android:0000000000000000",
|
|
"android_client_info": {
|
|
"package_name": "app.affine.pro"
|
|
}
|
|
},
|
|
"oauth_client": [],
|
|
"api_key": [
|
|
{
|
|
"current_key": "ci-placeholder"
|
|
}
|
|
],
|
|
"services": {
|
|
"appinvite_service": {
|
|
"other_platform_oauth_client": []
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"configuration_version": "1"
|
|
}
|
|
JSON
|
|
|
|
- name: Cap sync
|
|
run: yarn workspace @affine/android cap sync
|
|
|
|
- name: Run Android unit tests
|
|
working-directory: packages/frontend/apps/android/App
|
|
run: ./gradlew :app:testCanaryDebugUnitTest --no-daemon --stacktrace
|
|
|
|
- name: Enable KVM
|
|
run: sudo chmod 666 /dev/kvm
|
|
|
|
- name: Run Android instrumentation tests
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
with:
|
|
api-level: 35
|
|
arch: x86_64
|
|
profile: pixel_6
|
|
disable-animations: true
|
|
script: cd packages/frontend/apps/android/App && ./gradlew :app:connectedCanaryDebugAndroidTest --no-daemon --stacktrace
|
|
|
|
build-ios-app:
|
|
name: Build iOS app
|
|
if: ${{ needs.mobile-native-build-filter.outputs.run-ios == 'true' }}
|
|
runs-on: macos-15
|
|
needs:
|
|
- mobile-native-build-filter
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-tools/cli @affine/ios
|
|
electron-install: false
|
|
hard-link-nm: false
|
|
|
|
- uses: maxim-lobanov/setup-xcode@v1
|
|
with:
|
|
xcode-version: 26.2
|
|
|
|
- name: Setup Rust
|
|
uses: ./.github/actions/build-rust
|
|
with:
|
|
target: 'aarch64-apple-ios-sim'
|
|
package: 'affine_mobile_native'
|
|
no-build: 'true'
|
|
|
|
- name: Build iOS web assets
|
|
run: yarn affine @affine/ios build
|
|
env:
|
|
PUBLIC_PATH: '/'
|
|
|
|
- name: Cap sync
|
|
run: yarn workspace @affine/ios sync
|
|
|
|
- name: Build iOS simulator app
|
|
run: |
|
|
xcodebuild \
|
|
-workspace packages/frontend/apps/ios/App/App.xcworkspace \
|
|
-scheme App \
|
|
-configuration Debug \
|
|
-sdk iphonesimulator \
|
|
-destination 'generic/platform=iOS Simulator' \
|
|
ARCHS=arm64 \
|
|
ONLY_ACTIVE_ARCH=YES \
|
|
CODE_SIGNING_ALLOWED=NO \
|
|
CODE_SIGNING_REQUIRED=NO \
|
|
build
|
|
|
|
- name: Run iOS unit tests
|
|
run: |
|
|
device_id="$(xcrun simctl list devices available -j | ruby -rjson -e '
|
|
devices = JSON.parse(STDIN.read).fetch("devices").values.flatten
|
|
device = devices.find { |candidate| candidate.fetch("name").start_with?("iPhone") }
|
|
abort "No available iPhone simulator" unless device
|
|
puts device.fetch("udid")
|
|
')"
|
|
xcrun simctl boot "$device_id" || true
|
|
xcodebuild \
|
|
-project packages/frontend/apps/ios/App/App.xcodeproj \
|
|
-scheme AFFiNETests \
|
|
-configuration Debug \
|
|
-sdk iphonesimulator \
|
|
-destination "platform=iOS Simulator,id=$device_id" \
|
|
CODE_SIGNING_ALLOWED=NO \
|
|
CODE_SIGNING_REQUIRED=NO \
|
|
test
|
|
|
|
rust-test-filter:
|
|
name: Rust test filter
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
run-rust: ${{ steps.rust-filter.outputs.rust }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: dorny/paths-filter@v3
|
|
id: rust-filter
|
|
with:
|
|
filters: |
|
|
rust:
|
|
- '**/*.rs'
|
|
- '**/Cargo.toml'
|
|
- '**/Cargo.lock'
|
|
- '.cargo/**'
|
|
- 'rust-toolchain*'
|
|
- '.github/actions/build-rust/**'
|
|
- '.github/workflows/build-test.yml'
|
|
|
|
lint-rust:
|
|
name: Lint Rust
|
|
if: ${{ needs.rust-test-filter.outputs.run-rust == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- rust-test-filter
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: ./.github/actions/build-rust
|
|
with:
|
|
target: x86_64-unknown-linux-gnu
|
|
package: 'affine'
|
|
no-build: 'true'
|
|
- name: fmt check
|
|
run: |
|
|
rustup toolchain add nightly
|
|
rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt
|
|
cargo +nightly fmt --all -- --check
|
|
- name: Clippy
|
|
run: |
|
|
rustup component add clippy
|
|
cargo clippy --workspace --exclude affine_server_native --all-targets --all-features -- -D warnings
|
|
cargo clippy -p affine_server_native --all-targets --all-features -- -D warnings
|
|
|
|
check-git-status:
|
|
name: Check Git Status
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-server-native
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
full-cache: true
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Run Check
|
|
run: |
|
|
yarn affine init
|
|
yarn affine gql build
|
|
yarn affine i18n build
|
|
yarn affine server genconfig
|
|
git checkout packages/frontend/i18n/src/i18n-completenesses.json
|
|
if git status --porcelain | grep -q .; then
|
|
echo "Run 'yarn affine init && yarn affine gql build && yarn affine i18n build && yarn affine server genconfig' and make sure all changes are submitted"
|
|
exit 1
|
|
else
|
|
echo "All changes are submitted"
|
|
fi
|
|
|
|
check-yarn-binary:
|
|
name: Check yarn binary
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Run check
|
|
run: |
|
|
set -euo pipefail
|
|
yarn_version="$(node -e "console.log(require('./package.json').packageManager.split('@')[1])")"
|
|
yarn set version "$yarn_version"
|
|
git diff --exit-code
|
|
|
|
e2e-blocksuite-test:
|
|
name: E2E BlockSuite Test
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4, 5]
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-test/blocksuite @blocksuite/playground @blocksuite/integration-test
|
|
playwright-install: true
|
|
playwright-platform: 'chromium'
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Run playground build
|
|
run: yarn workspace @blocksuite/playground build
|
|
|
|
- name: Run playwright tests
|
|
run: yarn workspace @affine-test/blocksuite test --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-e2e-bs-${{ matrix.shard }}
|
|
path: ./test-results
|
|
if-no-files-found: ignore
|
|
|
|
e2e-blocksuite-cross-browser-test:
|
|
name: E2E BlockSuite Cross Browser Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-test/blocksuite @blocksuite/playground @blocksuite/integration-test
|
|
playwright-install: true
|
|
playwright-platform: 'chromium,firefox,webkit'
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Run playground build
|
|
run: yarn workspace @blocksuite/playground build
|
|
|
|
- name: Run integration browser tests
|
|
timeout-minutes: 10
|
|
run: yarn workspace @blocksuite/integration-test test:unit
|
|
|
|
- name: Run cross-platform playwright tests
|
|
timeout-minutes: 10
|
|
run: yarn workspace @affine-test/blocksuite test "cross-platform/" --forbid-only
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-e2e-bs-cross-browser
|
|
path: ./test-results
|
|
if-no-files-found: ignore
|
|
|
|
e2e-test:
|
|
name: E2E Test
|
|
runs-on: ubuntu-24.04-arm
|
|
env:
|
|
DISTRIBUTION: web
|
|
IN_CI_TEST: true
|
|
NODE_OPTIONS: --max-old-space-size=14384
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4, 5]
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-test/affine-local @affine/web @affine/server
|
|
playwright-install: true
|
|
playwright-platform: 'chromium'
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Run playwright tests
|
|
run: yarn affine @affine-test/affine-local e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-e2e-${{ matrix.shard }}
|
|
path: ./test-results
|
|
if-no-files-found: ignore
|
|
|
|
e2e-mobile-test:
|
|
name: E2E Mobile Test
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DISTRIBUTION: mobile
|
|
IN_CI_TEST: true
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2]
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-test/affine-mobile @affine/mobile
|
|
playwright-install: true
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Run playwright tests
|
|
run: yarn affine @affine-test/affine-mobile e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-e2e-mobile-${{ matrix.shard }}
|
|
path: ./test-results
|
|
if-no-files-found: ignore
|
|
|
|
unit-test:
|
|
name: Unit Test
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-native-linux
|
|
env:
|
|
DISTRIBUTION: web
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4, 5]
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
electron-install: true
|
|
playwright-install: true
|
|
playwright-platform: 'chromium,firefox,webkit'
|
|
full-cache: true
|
|
|
|
- name: Download affine.linux-x64-gnu.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: affine.linux-x64-gnu.node
|
|
path: ./packages/frontend/native
|
|
|
|
- name: Unit Test
|
|
run: yarn test:coverage --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
|
|
|
- name: Upload unit test coverage results
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./.coverage/store/lcov.info
|
|
flags: unittest
|
|
name: affine
|
|
fail_ci_if_error: false
|
|
|
|
build-native-linux:
|
|
name: Build AFFiNE native (x86_64-unknown-linux-gnu)
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16'
|
|
CARGO_PROFILE_RELEASE_DEBUG: '1'
|
|
CARGO_PROFILE_RELEASE_LTO: 'thin'
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/native
|
|
electron-install: false
|
|
- name: Setup filename
|
|
id: filename
|
|
working-directory: ${{ github.workspace }}
|
|
shell: bash
|
|
run: |
|
|
PLATFORM_ARCH_ABI="$(node -e "console.log(require('@napi-rs/cli').parseTriple('x86_64-unknown-linux-gnu').platformArchABI)")"
|
|
echo "filename=affine.$PLATFORM_ARCH_ABI.node" >> "$GITHUB_OUTPUT"
|
|
- name: Build AFFiNE native
|
|
uses: ./.github/actions/build-rust
|
|
with:
|
|
target: x86_64-unknown-linux-gnu
|
|
package: '@affine/native'
|
|
- name: Upload ${{ steps.filename.outputs.filename }}
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: ${{ steps.filename.outputs.filename }}
|
|
path: ${{ github.workspace }}/packages/frontend/native/${{ steps.filename.outputs.filename }}
|
|
if-no-files-found: error
|
|
|
|
build-native-macos:
|
|
name: Build AFFiNE native (${{ matrix.spec.target }})
|
|
runs-on: ${{ matrix.spec.os }}
|
|
env:
|
|
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16'
|
|
CARGO_PROFILE_RELEASE_DEBUG: '1'
|
|
CARGO_PROFILE_RELEASE_LTO: 'thin'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
spec:
|
|
- { os: macos-latest, target: x86_64-apple-darwin }
|
|
- { os: macos-latest, target: aarch64-apple-darwin }
|
|
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/native
|
|
electron-install: false
|
|
- name: Setup filename
|
|
id: filename
|
|
working-directory: ${{ github.workspace }}
|
|
shell: bash
|
|
run: |
|
|
PLATFORM_ARCH_ABI="$(node -e "console.log(require('@napi-rs/cli').parseTriple('${{ matrix.spec.target }}').platformArchABI)")"
|
|
echo "filename=affine.$PLATFORM_ARCH_ABI.node" >> "$GITHUB_OUTPUT"
|
|
- name: Build AFFiNE native
|
|
uses: ./.github/actions/build-rust
|
|
with:
|
|
target: ${{ matrix.spec.target }}
|
|
package: '@affine/native'
|
|
- name: Upload ${{ steps.filename.outputs.filename }}
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: ${{ steps.filename.outputs.filename }}
|
|
path: ${{ github.workspace }}/packages/frontend/native/${{ steps.filename.outputs.filename }}
|
|
if-no-files-found: error
|
|
|
|
# Split Windows build because it's too slow
|
|
# and other ci jobs required linux native
|
|
build-native-windows:
|
|
name: Build AFFiNE native (${{ matrix.spec.target }})
|
|
runs-on: ${{ matrix.spec.os }}
|
|
env:
|
|
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16'
|
|
CARGO_PROFILE_RELEASE_DEBUG: '1'
|
|
CARGO_PROFILE_RELEASE_LTO: 'thin'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
spec:
|
|
- { os: windows-latest, target: x86_64-pc-windows-msvc }
|
|
- { os: windows-latest, target: aarch64-pc-windows-msvc }
|
|
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: samypr100/setup-dev-drive@v3
|
|
with:
|
|
workspace-copy: true
|
|
drive-size: 8GB
|
|
drive-format: NTFS
|
|
env-mapping: |
|
|
CARGO_HOME,{{ DEV_DRIVE }}/.cargo
|
|
RUSTUP_HOME,{{ DEV_DRIVE }}/.rustup
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/native
|
|
electron-install: false
|
|
- name: Setup filename
|
|
id: filename
|
|
working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
|
|
shell: bash
|
|
run: |
|
|
PLATFORM_ARCH_ABI="$(node -e "console.log(require('@napi-rs/cli').parseTriple('${{ matrix.spec.target }}').platformArchABI)")"
|
|
echo "filename=affine.$PLATFORM_ARCH_ABI.node" >> "$GITHUB_OUTPUT"
|
|
- name: Build AFFiNE native
|
|
uses: ./.github/actions/build-rust
|
|
with:
|
|
target: ${{ matrix.spec.target }}
|
|
package: '@affine/native'
|
|
- name: Upload ${{ steps.filename.outputs.filename }}
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: ${{ steps.filename.outputs.filename }}
|
|
path: ${{ env.DEV_DRIVE_WORKSPACE }}/packages/frontend/native/${{ steps.filename.outputs.filename }}
|
|
if-no-files-found: error
|
|
|
|
build-server-native:
|
|
name: Build Server native
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
AFFINE_PRO_PUBLIC_KEY: |
|
|
-----BEGIN PUBLIC KEY-----
|
|
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEObwJiTmbui7rkWfPJ7Lozvuy2Rcl
|
|
otcrb0V6dlS2ijKEShm7ZttTwQn08xzesdjX/AxpoR5X9yfoHkauIBuuMQ==
|
|
-----END PUBLIC KEY-----
|
|
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16'
|
|
CARGO_PROFILE_RELEASE_DEBUG: '1'
|
|
CARGO_PROFILE_RELEASE_LTO: 'thin'
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/server-native
|
|
electron-install: false
|
|
- name: Build Rust
|
|
uses: ./.github/actions/build-rust
|
|
with:
|
|
target: 'x86_64-unknown-linux-gnu'
|
|
package: '@affine/server-native'
|
|
- name: Upload server-native.node
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native/server-native.node
|
|
if-no-files-found: error
|
|
|
|
build-electron-renderer:
|
|
name: Build @affine/electron renderer
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine/electron-renderer @affine/nbstore @toeverything/infra
|
|
electron-install: false
|
|
full-cache: true
|
|
- name: Build Electron renderer
|
|
run: yarn affine @affine/electron-renderer build
|
|
env:
|
|
DISTRIBUTION: desktop
|
|
- name: zip web
|
|
run: tar -czf dist.tar.gz --directory=packages/frontend/apps/electron-renderer/dist .
|
|
- name: Upload web artifact
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: web
|
|
path: dist.tar.gz
|
|
if-no-files-found: error
|
|
|
|
native-unit-test:
|
|
name: Native Unit Test
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-native-linux
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine-tools/cli @affine/monorepo @affine/native
|
|
electron-install: false
|
|
- name: Download affine.linux-x64-gnu.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: affine.linux-x64-gnu.node
|
|
path: ./packages/frontend/native
|
|
- name: Unit Test
|
|
run: yarn affine @affine/native test
|
|
|
|
server-test:
|
|
name: Server Test
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-server-native
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
node_index: [0, 1, 2, 3]
|
|
total_nodes: [4]
|
|
env:
|
|
NODE_ENV: test
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
REDIS_SERVER_HOST: localhost
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
mailer:
|
|
image: mailhog/mailhog
|
|
ports:
|
|
- 1025:1025
|
|
- 8025:8025
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine/server
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Prepare Server Test Environment
|
|
uses: ./.github/actions/server-test-env
|
|
|
|
- name: Run server tests
|
|
run: yarn affine @affine/server test:coverage --forbid-only
|
|
env:
|
|
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
|
|
CI_NODE_INDEX: ${{ matrix.node_index }}
|
|
CI_NODE_TOTAL: ${{ matrix.total_nodes }}
|
|
|
|
- name: Upload server test coverage results
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./packages/backend/server/.coverage/lcov.info
|
|
flags: server-test
|
|
name: affine
|
|
fail_ci_if_error: false
|
|
|
|
server-test-elasticsearch:
|
|
name: Server Test with Elasticsearch
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-server-native
|
|
env:
|
|
NODE_ENV: test
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
REDIS_SERVER_HOST: localhost
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
mailer:
|
|
image: mailhog/mailhog
|
|
ports:
|
|
- 1025:1025
|
|
- 8025:8025
|
|
steps:
|
|
# https://github.com/elastic/elastic-github-actions/blob/master/elasticsearch/README.md
|
|
- name: Configure sysctl limits for Elasticsearch
|
|
run: |
|
|
sudo swapoff -a
|
|
sudo sysctl -w vm.swappiness=1
|
|
sudo sysctl -w fs.file-max=262144
|
|
sudo sysctl -w vm.max_map_count=262144
|
|
|
|
- name: Runs Elasticsearch
|
|
uses: elastic/elastic-github-actions/elasticsearch@master
|
|
with:
|
|
stack-version: 9.0.1
|
|
security-enabled: false
|
|
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine/server
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Prepare Server Test Environment
|
|
with:
|
|
indexer-provider: elasticsearch
|
|
uses: ./.github/actions/server-test-env
|
|
|
|
- name: Run server tests with elasticsearch only
|
|
run: yarn affine @affine/server e2e:coverage src/__tests__/e2e/indexer/search-docs.spec.ts --forbid-only
|
|
env:
|
|
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
|
|
|
|
- name: Upload server test coverage results
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./packages/backend/server/.coverage/lcov.info
|
|
flags: server-test
|
|
name: affine
|
|
fail_ci_if_error: false
|
|
|
|
server-test-embedded:
|
|
name: Server Test with Embedded Search
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-server-native
|
|
env:
|
|
NODE_ENV: test
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
REDIS_SERVER_HOST: localhost
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine/server
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Prepare Server Test Environment
|
|
with:
|
|
indexer-provider: embedded
|
|
uses: ./.github/actions/server-test-env
|
|
|
|
- name: Run embedded Search provider E2E
|
|
run: >-
|
|
yarn affine @affine/server e2e:coverage
|
|
src/__tests__/e2e/indexer/aggregate.spec.ts
|
|
src/__tests__/e2e/indexer/search-docs.spec.ts
|
|
src/__tests__/e2e/indexer/search.spec.ts
|
|
--concurrency 1
|
|
--forbid-only
|
|
env:
|
|
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
|
|
|
|
- name: Upload server test coverage results
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./packages/backend/server/.coverage/lcov.info
|
|
flags: server-test
|
|
name: affine
|
|
fail_ci_if_error: false
|
|
|
|
server-test-manticoresearch:
|
|
name: Server Test with Manticore Search
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-server-native
|
|
env:
|
|
NODE_ENV: test
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
REDIS_SERVER_HOST: localhost
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
mailer:
|
|
image: mailhog/mailhog
|
|
ports:
|
|
- 1025:1025
|
|
- 8025:8025
|
|
manticore:
|
|
image: manticoresearch/manticore:29.0.2
|
|
env:
|
|
'searchd.listen': 'http:9308'
|
|
'searchd.network_timeout': '30'
|
|
ports:
|
|
- 9308:9308
|
|
options: >-
|
|
--health-cmd "wget -qO- --post-data='SHOW TABLES' 'http://127.0.0.1:9308/sql?mode=raw' >/dev/null"
|
|
--health-interval 5s
|
|
--health-timeout 5s
|
|
--health-retries 30
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine/server
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Prepare Server Test Environment
|
|
with:
|
|
indexer-provider: manticoresearch
|
|
uses: ./.github/actions/server-test-env
|
|
|
|
- name: Run Manticore Search provider E2E
|
|
run: yarn affine @affine/server e2e:coverage src/__tests__/e2e/indexer/manticore-provider.spec.ts --forbid-only
|
|
env:
|
|
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
|
|
|
|
- name: Upload server test coverage results
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./packages/backend/server/.coverage/lcov.info
|
|
flags: server-test
|
|
name: affine
|
|
fail_ci_if_error: false
|
|
|
|
server-e2e-test:
|
|
# the new version of server e2e test should be super fast, so sharding testing is not needed
|
|
name: Server E2E Test
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-server-native
|
|
env:
|
|
NODE_ENV: test
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
REDIS_SERVER_HOST: localhost
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine/server
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Prepare Server Test Environment
|
|
with:
|
|
indexer-provider: disabled
|
|
uses: ./.github/actions/server-test-env
|
|
|
|
- name: Run server tests
|
|
run: yarn affine @affine/server e2e:coverage --forbid-only
|
|
|
|
- name: Upload server test coverage results
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./packages/backend/server/.coverage/lcov.info
|
|
flags: server-test
|
|
name: affine
|
|
fail_ci_if_error: false
|
|
|
|
rust-test:
|
|
name: Run native tests
|
|
if: ${{ needs.rust-test-filter.outputs.run-rust == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- rust-test-filter
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
INVALIDATION_REDIS_URL: redis://localhost:6379/
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine/server
|
|
electron-install: false
|
|
- name: Setup Rust
|
|
uses: ./.github/actions/build-rust
|
|
with:
|
|
target: x86_64-unknown-linux-gnu
|
|
package: 'affine'
|
|
no-build: 'true'
|
|
|
|
- name: Install latest nextest release
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: nextest@0.9.98
|
|
|
|
- name: Initialize server-native test database
|
|
run: |
|
|
psql -h localhost -U postgres -c "CREATE DATABASE affine;"
|
|
psql -h localhost -U postgres -c "CREATE USER affine WITH PASSWORD 'affine';"
|
|
psql -h localhost -U postgres -c "ALTER USER affine WITH SUPERUSER;"
|
|
yarn affine @affine/server prisma migrate deploy
|
|
env:
|
|
PGPASSWORD: affine
|
|
|
|
- name: Run workspace Rust tests
|
|
run: cargo nextest run --workspace --exclude affine_server_native --features use-as-lib --release --no-fail-fast
|
|
|
|
- name: Run server-native Rust tests with PostgreSQL and Redis
|
|
run: cargo nextest run -p affine_server_native --release --no-fail-fast --test-threads=1
|
|
|
|
- name: Run native storage cleanup integration tests
|
|
run: cargo test -p affine_server_native --release blob_cleanup_projection_ -- --ignored --nocapture
|
|
|
|
copilot-test-filter:
|
|
name: Copilot test filter
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
run-api: ${{ steps.decision.outputs.run_api }}
|
|
run-e2e: ${{ steps.decision.outputs.run_e2e }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: dorny/paths-filter@v3
|
|
id: copilot-filter
|
|
with:
|
|
filters: |
|
|
api:
|
|
- 'packages/backend/server/src/plugins/copilot/**'
|
|
- 'packages/backend/server/tests/copilot.*'
|
|
e2e:
|
|
- 'packages/backend/server/src/plugins/copilot/**'
|
|
- 'packages/backend/server/tests/copilot.*'
|
|
- 'packages/frontend/core/src/blocksuite/ai/**'
|
|
- 'packages/frontend/core/src/modules/workspace-indexer-embedding/**'
|
|
- 'tests/affine-cloud-copilot/**'
|
|
|
|
- name: Decide test scope
|
|
id: decision
|
|
run: |
|
|
if [[ "${{ steps.copilot-filter.outputs.api }}" == "true" ]]; then
|
|
echo "run_api=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "run_api=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
if [[ "${{ steps.copilot-filter.outputs.e2e }}" == "true" ]]; then
|
|
echo "run_e2e=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "run_e2e=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
copilot-api-test:
|
|
name: Server Copilot Api Test
|
|
if: ${{ needs.copilot-test-filter.outputs.run-api == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-server-native
|
|
- copilot-test-filter
|
|
env:
|
|
NODE_ENV: test
|
|
DISTRIBUTION: web
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
REDIS_SERVER_HOST: localhost
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
mailer:
|
|
image: mailhog/mailhog
|
|
ports:
|
|
- 1025:1025
|
|
- 8025:8025
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine/server
|
|
electron-install: false
|
|
full-cache: true
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Prepare Server Test Environment
|
|
env:
|
|
SERVER_CONFIG: ${{ secrets.TEST_SERVER_CONFIG }}
|
|
uses: ./.github/actions/server-test-env
|
|
|
|
- name: Run server tests
|
|
run: yarn affine @affine/server test:copilot:coverage --forbid-only
|
|
env:
|
|
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
|
|
|
|
- name: Upload server test coverage results
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./packages/backend/server/.coverage/lcov.info
|
|
flags: server-test
|
|
name: affine
|
|
fail_ci_if_error: false
|
|
|
|
copilot-e2e-test:
|
|
name: Frontend Copilot E2E Test
|
|
if: ${{ needs.copilot-test-filter.outputs.run-e2e == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DISTRIBUTION: web
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
IN_CI_TEST: true
|
|
REDIS_SERVER_HOST: localhost
|
|
DEPLOYMENT_TYPE: affine
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shardIndex: [1, 2, 3, 4, 5]
|
|
shardTotal: [5]
|
|
needs:
|
|
- build-server-native
|
|
- copilot-test-filter
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-test/affine-cloud-copilot @affine/web @affine/server
|
|
playwright-install: true
|
|
playwright-platform: 'chromium'
|
|
electron-install: false
|
|
hard-link-nm: false
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Prepare Server Test Environment
|
|
env:
|
|
SERVER_CONFIG: ${{ secrets.TEST_SERVER_CONFIG }}
|
|
uses: ./.github/actions/server-test-env
|
|
|
|
- name: Run Copilot E2E Test ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
|
uses: ./.github/actions/copilot-test
|
|
with:
|
|
script: yarn affine @affine-test/affine-cloud-copilot e2e --forbid-only --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
|
|
|
cloud-e2e-test:
|
|
name: ${{ matrix.tests.name }}
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build-server-native
|
|
- build-native-linux
|
|
env:
|
|
DISTRIBUTION: web
|
|
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
|
REDIS_SERVER_HOST: localhost
|
|
IN_CI_TEST: true
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
tests:
|
|
- name: 'Cloud E2E Test 1/2'
|
|
shard: 1
|
|
script: yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=1/2
|
|
- name: 'Cloud E2E Test 2/2'
|
|
shard: 2
|
|
script: yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=2/2
|
|
- name: 'Cloud Desktop E2E Test'
|
|
shard: desktop
|
|
script: |
|
|
yarn affine @affine/electron build:dev
|
|
# Workaround for Electron apps failing to initialize on Ubuntu 24.04 due to AppArmor restrictions
|
|
# Disables unprivileged user namespaces restriction to allow Electron apps to run
|
|
# Reference: https://github.com/electron/electron/issues/42510
|
|
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
|
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn affine @affine-test/affine-desktop-cloud e2e
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
env:
|
|
POSTGRES_PASSWORD: affine
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
mailer:
|
|
image: mailhog/mailhog
|
|
ports:
|
|
- 1025:1025
|
|
- 8025:8025
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
with:
|
|
extra-flags: workspaces focus @affine/monorepo @affine-test/affine-cloud @affine-test/affine-desktop-cloud @affine/web @affine/server @affine/electron @affine/electron-renderer @affine/nbstore @toeverything/infra
|
|
playwright-install: true
|
|
playwright-platform: 'chromium'
|
|
electron-install: ${{ matrix.tests.shard == 'desktop' && 'true' || 'false' }}
|
|
hard-link-nm: false
|
|
|
|
- name: Download server-native.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-native.node
|
|
path: ./packages/backend/native
|
|
|
|
- name: Download affine.linux-x64-gnu.node
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: affine.linux-x64-gnu.node
|
|
path: ./packages/frontend/native
|
|
|
|
- name: Prepare Server Test Environment
|
|
uses: ./.github/actions/server-test-env
|
|
|
|
- name: ${{ matrix.tests.name }}
|
|
run: |
|
|
${{ matrix.tests.script }}
|
|
env:
|
|
DEV_SERVER_URL: http://localhost:8080
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-e2e-server-${{ matrix.tests.shard }}
|
|
path: ./test-results
|
|
if-no-files-found: ignore
|
|
|
|
desktop-test:
|
|
name: Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }})
|
|
runs-on: ${{ matrix.spec.os }}
|
|
needs:
|
|
- build-electron-renderer
|
|
- build-native-linux
|
|
- build-native-macos
|
|
- build-native-windows
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
spec:
|
|
- {
|
|
os: macos-latest,
|
|
platform: macos,
|
|
arch: x64,
|
|
target: x86_64-apple-darwin,
|
|
test: false,
|
|
}
|
|
- {
|
|
os: macos-latest,
|
|
platform: macos,
|
|
arch: arm64,
|
|
target: aarch64-apple-darwin,
|
|
test: true,
|
|
}
|
|
- {
|
|
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,
|
|
}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
timeout-minutes: 10
|
|
with:
|
|
extra-flags: workspaces focus @affine/electron @affine/monorepo @affine-test/affine-desktop @affine/nbstore @toeverything/infra
|
|
playwright-install: ${{ matrix.spec.test && 'true' || 'false' }}
|
|
playwright-platform: 'chromium'
|
|
hard-link-nm: false
|
|
enableScripts: false
|
|
|
|
- name: Setup filename
|
|
id: filename
|
|
shell: bash
|
|
run: |
|
|
PLATFORM_ARCH_ABI="$(node -e "console.log(require('@napi-rs/cli').parseTriple('${{ matrix.spec.target }}').platformArchABI)")"
|
|
echo "filename=affine.$PLATFORM_ARCH_ABI.node" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Download ${{ steps.filename.outputs.filename }}
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: ${{ steps.filename.outputs.filename }}
|
|
path: ./packages/frontend/native
|
|
|
|
- name: Run unit tests
|
|
if: ${{ matrix.spec.test }}
|
|
shell: bash
|
|
run: yarn affine @affine/electron vitest
|
|
|
|
- name: Download web artifact
|
|
uses: ./.github/actions/download-web
|
|
with:
|
|
path: packages/frontend/apps/electron/resources/web-static
|
|
|
|
- name: Build Desktop Layers
|
|
run: yarn affine @affine/electron build
|
|
|
|
- name: Run desktop tests
|
|
if: ${{ matrix.spec.os == 'ubuntu-latest' }}
|
|
run: |
|
|
# Workaround for Electron apps failing to initialize on Ubuntu 24.04 due to AppArmor restrictions
|
|
# Disables unprivileged user namespaces restriction to allow Electron apps to run
|
|
# Reference: https://github.com/electron/electron/issues/42510
|
|
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
|
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn affine @affine-test/affine-desktop e2e
|
|
|
|
- name: Run desktop tests
|
|
if: ${{ matrix.spec.test && matrix.spec.os != 'ubuntu-latest' }}
|
|
run: yarn affine @affine-test/affine-desktop e2e
|
|
|
|
- name: Make bundle (macOS)
|
|
if: ${{ matrix.spec.target == 'aarch64-apple-darwin' }}
|
|
env:
|
|
SKIP_BUNDLE: true
|
|
SKIP_WEB_BUILD: true
|
|
HOIST_NODE_MODULES: 1
|
|
run: yarn affine @affine/electron package --platform=darwin --arch=arm64
|
|
|
|
- name: Make Bundle (Windows)
|
|
if: ${{ matrix.spec.target == 'x86_64-pc-windows-msvc' }}
|
|
shell: bash
|
|
env:
|
|
SKIP_BUNDLE: true
|
|
SKIP_WEB_BUILD: true
|
|
HOIST_NODE_MODULES: 1
|
|
run: |
|
|
rm -rf packages/frontend/apps/electron/node_modules/@affine/nbstore/node_modules/@blocksuite/affine/node_modules
|
|
rm -rf packages/frontend/apps/electron/node_modules/@affine/native/node_modules
|
|
yarn affine @affine/electron package --platform=win32 --arch=x64
|
|
|
|
- name: Make Bundle (Linux)
|
|
run: |
|
|
sudo add-apt-repository universe
|
|
sudo apt install -y libfuse2 elfutils flatpak flatpak-builder
|
|
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
flatpak update
|
|
# some flatpak deps need git protocol.file.allow
|
|
git config --global protocol.file.allow always
|
|
yarn affine @affine/electron make --platform=linux --arch=x64
|
|
if: ${{ matrix.spec.target == 'x86_64-unknown-linux-gnu' }}
|
|
env:
|
|
SKIP_WEB_BUILD: 1
|
|
HOIST_NODE_MODULES: 1
|
|
|
|
- name: Output check
|
|
if: ${{ matrix.spec.os == 'macos-latest' && matrix.spec.arch == 'arm64' }}
|
|
run: |
|
|
yarn affine @affine/electron node ./scripts/macos-arm64-output-check.ts
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-e2e-${{ matrix.spec.os }}-${{ matrix.spec.arch }}
|
|
path: ./test-results
|
|
if-no-files-found: ignore
|
|
|
|
test-done:
|
|
needs:
|
|
- analyze
|
|
- lint
|
|
- typecheck
|
|
- mobile-native-build-filter
|
|
- build-android-app
|
|
- test-android-app
|
|
- build-ios-app
|
|
- lint-rust
|
|
- check-git-status
|
|
- check-yarn-binary
|
|
- e2e-test
|
|
- e2e-blocksuite-test
|
|
- e2e-blocksuite-cross-browser-test
|
|
- e2e-mobile-test
|
|
- unit-test
|
|
- build-native-linux
|
|
- build-native-macos
|
|
- build-native-windows
|
|
- build-server-native
|
|
- build-electron-renderer
|
|
- native-unit-test
|
|
- server-test
|
|
- server-test-elasticsearch
|
|
- server-test-embedded
|
|
- server-test-manticoresearch
|
|
- server-e2e-test
|
|
- rust-test
|
|
- rust-test-filter
|
|
- copilot-test-filter
|
|
- copilot-api-test
|
|
- copilot-e2e-test
|
|
- desktop-test
|
|
- cloud-e2e-test
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
name: 3, 2, 1 Launch
|
|
steps:
|
|
- run: exit 1
|
|
# Thank you, next https://github.com/vercel/next.js/blob/canary/.github/workflows/build_and_test.yml#L379
|
|
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}
|