mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
ci: add tauri ci (#1833)
* ci: add tauri ci * ci: update install windows scripts * Update tauri_ci.yaml * Update tauri_ci.yaml * ci: update
This commit is contained in:
parent
72768a2f77
commit
cbd351453d
74
.github/workflows/tauri_ci.yaml
vendored
Normal file
74
.github/workflows/tauri_ci.yaml
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
name: Tauri-CI
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "frontend/rust-lib/**"
|
||||
- "frontend/appflowy_tauri/**"
|
||||
|
||||
env:
|
||||
NODE_VERSION: "16"
|
||||
RUST_TOOLCHAIN: "1.65"
|
||||
|
||||
jobs:
|
||||
tauri-build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [macos-latest, ubuntu-20.04, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Install Rust toolchain
|
||||
id: rust_toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
||||
override: true
|
||||
profile: minimal
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
prefix-key: ${{ matrix.platform }}
|
||||
|
||||
- name: install dependencies (windows only)
|
||||
if: matrix.platform == 'windows-latest'
|
||||
working-directory: frontend
|
||||
run: |
|
||||
cargo install --force cargo-make
|
||||
cargo install --force duckscript_cli
|
||||
vcpkg integrate install
|
||||
cargo make appflowy-tauri-deps-tools
|
||||
|
||||
- name: install dependencies (ubuntu only)
|
||||
if: matrix.platform == 'ubuntu-20.04'
|
||||
working-directory: frontend
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
|
||||
cargo install --force cargo-make
|
||||
cargo make appflowy-tauri-deps-tools
|
||||
|
||||
- name: install dependencies (macOS only)
|
||||
if: matrix.platform == 'macos-latest'
|
||||
working-directory: frontend
|
||||
run: |
|
||||
cargo install --force cargo-make
|
||||
cargo make appflowy-tauri-deps-tools
|
||||
|
||||
- name: build
|
||||
working-directory: frontend/appflowy_tauri
|
||||
run: |
|
||||
mkdir dist
|
||||
npm install
|
||||
cargo make --cwd .. build_tauri_backend
|
||||
yarn && yarn build
|
||||
|
||||
- uses: tauri-apps/tauri-action@v0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -24,7 +24,7 @@ CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
|
||||
CARGO_MAKE_CRATE_NAME = "dart-ffi"
|
||||
LIB_NAME = "dart_ffi"
|
||||
CURRENT_APP_VERSION = "0.1.0"
|
||||
FLUTTER_DESKTOP_FEATURES = "flutter,rev-sqlite"
|
||||
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite"
|
||||
PRODUCT_NAME = "AppFlowy"
|
||||
# CRATE_TYPE: https://doc.rust-lang.org/reference/linkage.html
|
||||
# If you update the macOS's CRATE_TYPE, don't forget to update the
|
||||
@ -134,7 +134,7 @@ CRATE_TYPE = "cdylib"
|
||||
FLUTTER_OUTPUT_DIR = "Debug"
|
||||
LIB_EXT = "so"
|
||||
LINUX_ARCH = "arm64"
|
||||
FLUTTER_DESKTOP_FEATURES = "flutter,rev-sqlite,openssl_vendored"
|
||||
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
|
||||
|
||||
[env.production-linux-aarch64]
|
||||
BUILD_FLAG = "release"
|
||||
@ -145,7 +145,7 @@ FLUTTER_OUTPUT_DIR = "Release"
|
||||
LIB_EXT = "so"
|
||||
LINUX_ARCH = "arm64"
|
||||
APP_ENVIRONMENT = "production"
|
||||
FLUTTER_DESKTOP_FEATURES = "flutter,rev-sqlite,openssl_vendored"
|
||||
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
|
||||
|
||||
[tasks.echo_env]
|
||||
script = ['''
|
||||
@ -173,14 +173,14 @@ BUILD_FLAG = "debug"
|
||||
TARGET_OS = "android"
|
||||
CRATE_TYPE = "cdylib"
|
||||
FLUTTER_OUTPUT_DIR = "Debug"
|
||||
FLUTTER_DESKTOP_FEATURES = "flutter,rev-sqlite,openssl_vendored"
|
||||
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
|
||||
|
||||
[env.production-android]
|
||||
BUILD_FLAG = "release"
|
||||
TARGET_OS = "android"
|
||||
CRATE_TYPE = "cdylib"
|
||||
FLUTTER_OUTPUT_DIR = "Release"
|
||||
FLUTTER_DESKTOP_FEATURES = "flutter,rev-sqlite,openssl_vendored"
|
||||
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
|
||||
|
||||
[tasks.setup-crate-type]
|
||||
private = true
|
||||
|
@ -12,13 +12,14 @@
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.2.0",
|
||||
"google-protobuf": "^3.21.2",
|
||||
"ts-results": "^3.3.0",
|
||||
"nanoid": "^4.0.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
"react-dom": "^18.2.0",
|
||||
"ts-results": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tauri-apps/cli": "^1.2.2",
|
||||
"@types/google-protobuf": "^3.15.6",
|
||||
"@types/node": "^18.7.10",
|
||||
"@types/react": "^18.0.15",
|
||||
"@types/react-dom": "^18.0.6",
|
||||
|
2
frontend/appflowy_tauri/src-tauri/rust-toolchain.toml
Normal file
2
frontend/appflowy_tauri/src-tauri/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "1.65"
|
@ -14,10 +14,10 @@ use request::*;
|
||||
use tauri::Manager;
|
||||
|
||||
fn main() {
|
||||
let sdk = init_flowy_core();
|
||||
let flowy_core = init_flowy_core();
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![invoke_request])
|
||||
.manage(sdk)
|
||||
.manage(flowy_core)
|
||||
.on_window_event(|_window_event| {})
|
||||
.on_menu_event(|_menu| {})
|
||||
.on_page_load(|window, _payload| {
|
||||
@ -29,7 +29,8 @@ fn main() {
|
||||
});
|
||||
})
|
||||
.setup(|app| {
|
||||
if cfg!(debug_assertions) {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
let window = app.get_window("main").unwrap();
|
||||
window.open_devtools();
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
export {}
|
@ -0,0 +1 @@
|
||||
export {}
|
@ -0,0 +1 @@
|
||||
export {}
|
@ -0,0 +1 @@
|
||||
export {}
|
@ -0,0 +1 @@
|
||||
export {}
|
@ -32,8 +32,8 @@ flowy-notification = { path = "../flowy-notification" }
|
||||
flowy-derive = { path = "../flowy-derive" }
|
||||
|
||||
[features]
|
||||
default = ["flowy-core/dart", "flutter", "rev-sqlite"]
|
||||
flutter = []
|
||||
default = ["dart", "rev-sqlite"]
|
||||
dart = ["flowy-core/dart"]
|
||||
rev-sqlite = ["flowy-core/rev-sqlite"]
|
||||
http_sync = ["flowy-core/http_sync", "flowy-core/use_bunyan"]
|
||||
openssl_vendored = ["flowy-core/openssl_vendored"]
|
||||
|
@ -11,12 +11,10 @@ use grid_model::{CellRevision, DatabaseBlockRevision, RowChangeset, RowRevision}
|
||||
use lib_infra::future::FutureResult;
|
||||
use lib_infra::retry::spawn_retry;
|
||||
use lib_ot::core::EmptyAttributes;
|
||||
use parking_lot::RwLock;
|
||||
use revision_model::Revision;
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
// use tokio::sync::RwLock;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub struct DatabaseBlockRevisionEditor {
|
||||
#[allow(dead_code)]
|
||||
@ -57,7 +55,7 @@ impl DatabaseBlockRevisionEditor {
|
||||
}
|
||||
|
||||
pub async fn duplicate_block(&self, duplicated_block_id: &str) -> DatabaseBlockRevision {
|
||||
self.pad.read().duplicate_data(duplicated_block_id)
|
||||
self.pad.read().await.duplicate_data(duplicated_block_id)
|
||||
}
|
||||
|
||||
/// Create a row after the the with prev_row_id. If prev_row_id is None, the row will be appended to the list
|
||||
@ -112,16 +110,15 @@ impl DatabaseBlockRevisionEditor {
|
||||
}
|
||||
|
||||
pub async fn index_of_row(&self, row_id: &str) -> Option<usize> {
|
||||
self.pad.read().index_of_row(row_id)
|
||||
self.pad.read().await.index_of_row(row_id)
|
||||
}
|
||||
|
||||
pub async fn number_of_rows(&self) -> i32 {
|
||||
self.pad.read().rows.len() as i32
|
||||
self.pad.read().await.rows.len() as i32
|
||||
}
|
||||
|
||||
pub async fn get_row_rev(&self, row_id: &str) -> FlowyResult<Option<(usize, Arc<RowRevision>)>> {
|
||||
let duration = Duration::from_millis(300);
|
||||
if let Some(pad) = self.pad.try_read_for(duration) {
|
||||
if let Ok(pad) = self.pad.try_read() {
|
||||
Ok(pad.get_row_rev(row_id))
|
||||
} else {
|
||||
tracing::error!("Required grid block read lock failed, retrying");
|
||||
@ -143,7 +140,7 @@ impl DatabaseBlockRevisionEditor {
|
||||
where
|
||||
T: AsRef<str> + ToOwned + ?Sized,
|
||||
{
|
||||
let row_revs = self.pad.read().get_row_revs(row_ids)?;
|
||||
let row_revs = self.pad.read().await.get_row_revs(row_ids)?;
|
||||
Ok(row_revs)
|
||||
}
|
||||
|
||||
@ -152,7 +149,7 @@ impl DatabaseBlockRevisionEditor {
|
||||
field_id: &str,
|
||||
row_ids: Option<Vec<Cow<'_, String>>>,
|
||||
) -> FlowyResult<Vec<CellRevision>> {
|
||||
let cell_revs = self.pad.read().get_cell_revs(field_id, row_ids)?;
|
||||
let cell_revs = self.pad.read().await.get_cell_revs(field_id, row_ids)?;
|
||||
Ok(cell_revs)
|
||||
}
|
||||
|
||||
@ -160,7 +157,8 @@ impl DatabaseBlockRevisionEditor {
|
||||
where
|
||||
F: for<'a> FnOnce(&'a mut GridBlockRevisionPad) -> FlowyResult<Option<GridBlockRevisionChangeset>>,
|
||||
{
|
||||
let changeset = f(&mut self.pad.write())?;
|
||||
let mut write_guard = self.pad.write().await;
|
||||
let changeset = f(&mut write_guard)?;
|
||||
match changeset {
|
||||
None => {}
|
||||
Some(changeset) => {
|
||||
|
@ -2,11 +2,10 @@ use flowy_client_sync::client_database::GridBlockRevisionPad;
|
||||
use flowy_error::FlowyError;
|
||||
use grid_model::RowRevision;
|
||||
use lib_infra::retry::Action;
|
||||
|
||||
use parking_lot::RwLock;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub struct GetRowDataRetryAction {
|
||||
pub row_id: String,
|
||||
@ -23,8 +22,8 @@ impl Action for GetRowDataRetryAction {
|
||||
let row_id = self.row_id.clone();
|
||||
Box::pin(async move {
|
||||
match pad.try_read() {
|
||||
None => Ok(None),
|
||||
Some(read_guard) => Ok(read_guard.get_row_rev(&row_id)),
|
||||
Err(_) => Ok(None),
|
||||
Ok(read_guard) => Ok(read_guard.get_row_rev(&row_id)),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -70,7 +70,9 @@ cargo install diesel_cli --no-default-features --features sqlite
|
||||
|
||||
[tasks.install_diesel.windows]
|
||||
script = """
|
||||
cargo install diesel_cli --no-default-features --features sqlite
|
||||
#https://duredhelfinceleb.github.io/diesel_windows_install_doc/
|
||||
|
||||
cargo install diesel_cli --no-default-features --features "sqlite-bundled"
|
||||
"""
|
||||
dependencies = ["check_vcpkg"]
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
script = """
|
||||
npm install -g protoc-gen-ts
|
||||
"""
|
||||
script_runner = "@duckscript"
|
||||
script_runner = "@shell"
|
||||
|
||||
[tasks.install_tauri_protobuf.mac]
|
||||
script = """
|
||||
|
@ -1,5 +1,5 @@
|
||||
[tasks.tauri_build]
|
||||
description = "Build the Tauri backend & Run Code Generation"
|
||||
[tasks.build_tauri_backend]
|
||||
description = "Build the Tauri backend"
|
||||
script = ["""
|
||||
cd appflowy_tauri/src-tauri
|
||||
cargo build
|
||||
|
Loading…
Reference in New Issue
Block a user