There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
ci: rust build config
LongYinan768e55072d1a
diff --git a/.github/actions/build-rust/action.yml b/.github/actions/build-rust/action.ymlnew file mode 100644index 0000000000..4549065f7e--- /dev/null+++ b/.github/actions/build-rust/action.yml@@ -0,0 +1,47 @@+name: 'AFFiNE Rust build'+description: 'Rust build setup, including cache configuration'+inputs:+ target:+ description: 'Cargo target'+ required: true++runs:+ using: 'composite'+ steps:+ - name: Setup Rust+ uses: dtolnay/rust-toolchain@stable+ with:+ toolchain: stable+ targets: ${{ inputs.target }}++ - name: Cache cargo+ uses: actions/cache@v3+ with:+ path: |+ ~/.cargo/registry/index/+ ~/.cargo/registry/cache/+ ~/.cargo/git/db/+ .cargo-cache+ target/${{ inputs.target }}+ key: stable-${{ inputs.target }}-cargo-cache++ - name: Build+ if: ${{ inputs.target != 'x86_64-unknown-linux-gnu' && inputs.target != 'aarch64-unknown-linux-gnu' }}+ shell: bash+ run: yarn workspace @affine/native build --target ${{ inputs.target }}++ - name: Build+ if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' }}+ uses: addnab/docker-run-action@v3+ with:+ image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian+ options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build+ run: yarn workspace @affine/native build --target ${{ inputs.target }}++ - name: Build+ if: ${{ inputs.target == 'aarch64-unknown-linux-gnu' }}+ uses: addnab/docker-run-action@v3+ with:+ image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64+ options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build+ run: yarn workspace @affine/native build --target ${{ inputs.target }}diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 200236cc84..7d245cd025 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -20,6 +20,12 @@ on:- .github/**- '!.github/workflows/build.yml'+env:+ CARGO_BUILD_INCREMENTAL: 'false'+ DEBUG: napi:*+ APP_NAME: affine+ MACOSX_DEPLOYMENT_TARGET: '10.13'+jobs:lint:name: Lint@@ -273,7 +279,7 @@ jobs:- name: Upload test resultsif: ${{ failure() }}- uses: actions/upload-artifact@v2+ uses: actions/upload-artifact@v3with:name: test-results-e2e-${{ matrix.shard }}path: ./test-results@@ -281,17 +287,41 @@ jobs:dekstop-test:name: Desktop Test- runs-on: ubuntu-latest+ runs-on: ${{ matrix.spec.os }}environment: developmentstrategy:fail-fast: false# all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64matrix:spec:- - { os: macos-latest, platform: macos, arch: x64 }- - { os: macos-latest, platform: macos, arch: arm64 }- - { os: ubuntu-latest, platform: linux, arch: x64 }- - { os: windows-latest, platform: windows, arch: x64 }+ - {+ 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, build-electron]steps:- uses: actions/checkout@v3@@ -299,6 +329,10 @@ jobs:uses: ./.github/actions/setup-nodewith:playwright-install: true+ - name: Build AFFiNE native+ uses: ./.github/actions/build-rust+ with:+ target: ${{ matrix.spec.target }}- name: Download Ubuntu desktop artifactuses: actions/download-artifact@v3with:@@ -316,12 +350,18 @@ jobs:working-directory: apps/electron- name: Run desktop tests+ if: ${{ matrix.spec.test && matrix.spec.os == 'ubuntu-latest' }}run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn testworking-directory: apps/electron+ - name: Run desktop tests+ if: ${{ matrix.spec.test && matrix.spec.os != 'ubuntu-latest' }}+ run: yarn test+ working-directory: apps/electron+- name: Upload test resultsif: ${{ failure() }}- uses: actions/upload-artifact@v2+ uses: actions/upload-artifact@v3with:name: test-results-e2e-${{ matrix.shard }}path: ./test-resultsdiff --git a/.github/workflows/release-desktop-app.yml b/.github/workflows/release-desktop-app.ymlindex da77b8ebda..1d10a78fa2 100644--- a/.github/workflows/release-desktop-app.yml+++ b/.github/workflows/release-desktop-app.yml@@ -36,6 +36,10 @@ concurrency:env:BUILD_TYPE: ${{ github.event.inputs.build-type }}+ CARGO_BUILD_INCREMENTAL: 'false'+ DEBUG: napi:*+ APP_NAME: affine+ MACOSX_DEPLOYMENT_TARGET: '10.13'jobs:before-make:@@ -89,10 +93,30 @@ jobs:# all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64matrix:spec:- - { os: macos-latest, platform: macos, arch: x64 }- - { os: macos-latest, platform: macos, arch: arm64 }- - { os: ubuntu-latest, platform: linux, arch: x64 }- - { os: windows-latest, platform: windows, arch: x64 }+ - {+ os: macos-latest,+ platform: macos,+ arch: x64,+ target: x86_64-apple-darwin,+ }+ - {+ os: macos-latest,+ platform: macos,+ arch: arm64,+ target: aarch64-apple-darwin,+ }+ - {+ os: ubuntu-latest,+ platform: linux,+ arch: x64,+ target: x86_64-unknown-linux-gnu,+ }+ - {+ os: windows-latest,+ platform: windows,+ arch: x64,+ target: x86_64-pc-windows-msvc,+ }runs-on: ${{ matrix.spec.os }}needs: before-makeenv:@@ -104,6 +128,10 @@ jobs:- uses: actions/checkout@v3- name: Setup Node.jsuses: ./.github/actions/setup-node+ - name: Build AFFiNE native+ uses: ./.github/actions/build-rust+ with:+ target: ${{ matrix.spec.target }}- uses: actions/download-artifact@v3with:name: before-make-web-staticdiff --git a/Cargo.lock b/Cargo.lockindex 3393e7865b..8992cc4c9d 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3,7 +3,7 @@version = 3[[package]]-name = "affine_octobase"+name = "affine_native"version = "0.0.0"dependencies = ["anyhow",diff --git a/Cargo.toml b/Cargo.tomlindex 4246cf084e..8b5f358fa1 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,2 +1,8 @@[workspace]members = ["./packages/native"]++[profile.release]+lto = true+codegen-units = 1+opt-level = 3+strip = "symbols"diff --git a/apps/electron/tests/fixture.ts b/apps/electron/tests/fixture.tsindex 03ccad6d30..ed600e6e2d 100644--- a/apps/electron/tests/fixture.ts+++ b/apps/electron/tests/fixture.ts@@ -54,9 +54,16 @@ export const test = base.extend<{electronApp: async ({}, use) => {// a random id to avoid conflicts between testsconst id = generateUUID();+ const ext = process.platform === 'win32' ? '.cmd' : '';const electronApp = await electron.launch({args: [resolve(__dirname, '..'), '--app-name', 'affine-test-' + id],- executablePath: resolve(__dirname, '../node_modules/.bin/electron'),+ executablePath: resolve(+ __dirname,+ '..',+ 'node_modules',+ '.bin',+ `electron${ext}`+ ),colorScheme: 'light',});await use(electronApp);diff --git a/packages/native/Cargo.toml b/packages/native/Cargo.tomlindex ff2251fe19..28c13c05a6 100644--- a/packages/native/Cargo.toml+++ b/packages/native/Cargo.toml@@ -1,6 +1,6 @@[package]edition = "2021"-name = "affine_octobase"+name = "affine_native"version = "0.0.0"[lib]