mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
ci: rust build config
This commit is contained in:
47
.github/actions/build-rust/action.yml
vendored
Normal file
47
.github/actions/build-rust/action.yml
vendored
Normal file
@@ -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 }}
|
||||||
54
.github/workflows/build.yml
vendored
54
.github/workflows/build.yml
vendored
@@ -20,6 +20,12 @@ on:
|
|||||||
- .github/**
|
- .github/**
|
||||||
- '!.github/workflows/build.yml'
|
- '!.github/workflows/build.yml'
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_BUILD_INCREMENTAL: 'false'
|
||||||
|
DEBUG: napi:*
|
||||||
|
APP_NAME: affine
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
@@ -273,7 +279,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload test results
|
- name: Upload test results
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: test-results-e2e-${{ matrix.shard }}
|
name: test-results-e2e-${{ matrix.shard }}
|
||||||
path: ./test-results
|
path: ./test-results
|
||||||
@@ -281,17 +287,41 @@ jobs:
|
|||||||
|
|
||||||
dekstop-test:
|
dekstop-test:
|
||||||
name: Desktop Test
|
name: Desktop Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.spec.os }}
|
||||||
environment: development
|
environment: development
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
# all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64
|
# all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64
|
||||||
matrix:
|
matrix:
|
||||||
spec:
|
spec:
|
||||||
- { os: macos-latest, platform: macos, arch: x64 }
|
- {
|
||||||
- { os: macos-latest, platform: macos, arch: arm64 }
|
os: macos-latest,
|
||||||
- { os: ubuntu-latest, platform: linux, arch: x64 }
|
platform: macos,
|
||||||
- { os: windows-latest, platform: windows, arch: x64 }
|
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]
|
needs: [build, build-electron]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -299,6 +329,10 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
with:
|
||||||
playwright-install: true
|
playwright-install: true
|
||||||
|
- name: Build AFFiNE native
|
||||||
|
uses: ./.github/actions/build-rust
|
||||||
|
with:
|
||||||
|
target: ${{ matrix.spec.target }}
|
||||||
- name: Download Ubuntu desktop artifact
|
- name: Download Ubuntu desktop artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -316,12 +350,18 @@ jobs:
|
|||||||
working-directory: apps/electron
|
working-directory: apps/electron
|
||||||
|
|
||||||
- name: Run desktop tests
|
- name: Run desktop tests
|
||||||
|
if: ${{ matrix.spec.test && matrix.spec.os == 'ubuntu-latest' }}
|
||||||
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test
|
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test
|
||||||
working-directory: apps/electron
|
working-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 results
|
- name: Upload test results
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: test-results-e2e-${{ matrix.shard }}
|
name: test-results-e2e-${{ matrix.shard }}
|
||||||
path: ./test-results
|
path: ./test-results
|
||||||
|
|||||||
36
.github/workflows/release-desktop-app.yml
vendored
36
.github/workflows/release-desktop-app.yml
vendored
@@ -36,6 +36,10 @@ concurrency:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
BUILD_TYPE: ${{ github.event.inputs.build-type }}
|
BUILD_TYPE: ${{ github.event.inputs.build-type }}
|
||||||
|
CARGO_BUILD_INCREMENTAL: 'false'
|
||||||
|
DEBUG: napi:*
|
||||||
|
APP_NAME: affine
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
before-make:
|
before-make:
|
||||||
@@ -89,10 +93,30 @@ jobs:
|
|||||||
# all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64
|
# all combinations: macos-latest x64, macos-latest arm64, windows-latest x64, ubuntu-latest x64
|
||||||
matrix:
|
matrix:
|
||||||
spec:
|
spec:
|
||||||
- { os: macos-latest, platform: macos, arch: x64 }
|
- {
|
||||||
- { os: macos-latest, platform: macos, arch: arm64 }
|
os: macos-latest,
|
||||||
- { os: ubuntu-latest, platform: linux, arch: x64 }
|
platform: macos,
|
||||||
- { os: windows-latest, platform: windows, arch: x64 }
|
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 }}
|
runs-on: ${{ matrix.spec.os }}
|
||||||
needs: before-make
|
needs: before-make
|
||||||
env:
|
env:
|
||||||
@@ -104,6 +128,10 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
|
- name: Build AFFiNE native
|
||||||
|
uses: ./.github/actions/build-rust
|
||||||
|
with:
|
||||||
|
target: ${{ matrix.spec.target }}
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: before-make-web-static
|
name: before-make-web-static
|
||||||
|
|||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -3,7 +3,7 @@
|
|||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "affine_octobase"
|
name = "affine_native"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|||||||
@@ -1,2 +1,8 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["./packages/native"]
|
members = ["./packages/native"]
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
opt-level = 3
|
||||||
|
strip = "symbols"
|
||||||
|
|||||||
@@ -54,9 +54,16 @@ export const test = base.extend<{
|
|||||||
electronApp: async ({}, use) => {
|
electronApp: async ({}, use) => {
|
||||||
// a random id to avoid conflicts between tests
|
// a random id to avoid conflicts between tests
|
||||||
const id = generateUUID();
|
const id = generateUUID();
|
||||||
|
const ext = process.platform === 'win32' ? '.cmd' : '';
|
||||||
const electronApp = await electron.launch({
|
const electronApp = await electron.launch({
|
||||||
args: [resolve(__dirname, '..'), '--app-name', 'affine-test-' + id],
|
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',
|
colorScheme: 'light',
|
||||||
});
|
});
|
||||||
await use(electronApp);
|
await use(electronApp);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
name = "affine_octobase"
|
name = "affine_native"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|||||||
Reference in New Issue
Block a user