From c932f63e571c49d81cd7b837fb201968e40224df Mon Sep 17 00:00:00 2001 From: vedon Date: Tue, 3 Jan 2023 22:34:55 +0800 Subject: [PATCH] Fix/windows build (#1641) * fix: windows build & refactor release build target * refactor: merge dart_lint and dart_test into flutter_ci * refactor: merge rust_lint and rust_test into rust_ci * chore: update rust_ci.yaml --- .github/workflows/appflowy_editor_test.yml | 3 +- .github/workflows/ci.yaml | 100 ---- .github/workflows/dart_lint.yml | 86 --- .github/workflows/dart_test.yml | 80 --- .../{integration_test.yml => flutter_ci.yaml} | 118 ++-- .github/workflows/release.yml | 507 +++++++++--------- .github/workflows/release_docker.yml | 35 -- .github/workflows/rust_ci.yaml | 74 +++ .github/workflows/rust_coverage.yml | 53 +- .github/workflows/rust_lint.yml | 61 --- .github/workflows/rust_test.yml | 60 --- 11 files changed, 417 insertions(+), 760 deletions(-) delete mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/dart_lint.yml delete mode 100644 .github/workflows/dart_test.yml rename .github/workflows/{integration_test.yml => flutter_ci.yaml} (54%) delete mode 100644 .github/workflows/release_docker.yml create mode 100644 .github/workflows/rust_ci.yaml delete mode 100644 .github/workflows/rust_lint.yml delete mode 100644 .github/workflows/rust_test.yml diff --git a/.github/workflows/appflowy_editor_test.yml b/.github/workflows/appflowy_editor_test.yml index 5a729ebe88..d298140594 100644 --- a/.github/workflows/appflowy_editor_test.yml +++ b/.github/workflows/appflowy_editor_test.yml @@ -15,6 +15,7 @@ on: env: CARGO_TERM_COLOR: always + FLUTTER_VERSION: "3.3.9" jobs: tests: @@ -30,7 +31,7 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: "stable" - flutter-version: "3.3.9" + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true - name: Run FlowyEditor tests diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index d5486c0b63..0000000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,100 +0,0 @@ -name: CI - -on: - push: - branches: - - "main" - - "release/*" - - pull_request: - branches: - - "main" - - "release/*" - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - include: - - os: ubuntu-latest - flutter_profile: development-linux-x86_64 - - os: macos-latest - flutter_profile: development-mac-x86_64 - - os: windows-latest - flutter_profile: development-windows-x86 - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - - id: rust_toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: "stable-2022-04-07" - - - id: flutter - uses: subosito/flutter-action@v2 - with: - channel: "stable" - cache: true - flutter-version: "3.3.9" - - - name: Cache Cargo - id: cache-cargo - uses: actions/cache@v2 - with: - path: | - ~/.cargo - key: ${{ runner.os }}-cargo-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - name: Cache Rust - uses: actions/cache@v2 - with: - path: | - frontend/rust-lib/target - shared-lib/target - key: ${{ runner.os }}-rust-rust-lib-share-lib-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - name: Setup Environment - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub - sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list - sudo apt-get update - sudo apt-get install -y dart curl build-essential libsqlite3-dev libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev - sudo apt-get install keybinder-3.0 - elif [ "$RUNNER_OS" == "Windows" ]; then - vcpkg integrate install - elif [ "$RUNNER_OS" == "macOS" ]; then - echo 'do nothing' - fi - shell: bash - - - if: steps.cache-cargo.outputs.cache-hit != 'true' - name: Deps - working-directory: frontend - run: | - cargo install cargo-make - cargo install duckscript_cli - - - name: Cargo make appflowy-deps-tools - working-directory: frontend - run: | - cargo make appflowy-deps-tools - - - name: Config Flutter - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - flutter config --enable-linux-desktop - elif [ "$RUNNER_OS" == "macOS" ]; then - flutter config --enable-macos-desktop - elif [ "$RUNNER_OS" == "Windows" ]; then - flutter config --enable-windows-desktop - fi - shell: bash - - - name: Build - working-directory: frontend - run: | - cargo make --profile ${{ matrix.flutter_profile }} appflowy-dev diff --git a/.github/workflows/dart_lint.yml b/.github/workflows/dart_lint.yml deleted file mode 100644 index 7a9e4a0490..0000000000 --- a/.github/workflows/dart_lint.yml +++ /dev/null @@ -1,86 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Flutter lint - -on: - push: - branches: - - "main" - - "release/*" - paths: - - "frontend/app_flowy/**" - - pull_request: - branches: - - "main" - - "release/*" - paths: - - "frontend/app_flowy/**" - -env: - CARGO_TERM_COLOR: always - -jobs: - flutter-analyze: - name: flutter analyze - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - uses: subosito/flutter-action@v1 - with: - flutter-version: "3.3.9" - channel: "stable" - - uses: actions-rs/toolchain@v1 - with: - toolchain: "stable-2022-04-07" - - - name: Cache Cargo - id: cache-cargo - uses: actions/cache@v2 - with: - path: | - ~/.cargo - key: ${{ runner.os }}-cargo-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - name: Cache Rust - id: cache-rust-target - uses: actions/cache@v2 - with: - path: | - frontend/rust-lib/target - shared-lib/target - key: ${{ runner.os }}-rust-rust-lib-share-lib-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - if: steps.cache-cargo.outputs.cache-hit != 'true' - name: Rust Deps - working-directory: frontend - run: | - cargo install cargo-make - - - name: Cargo make flowy dev - working-directory: frontend - run: | - cargo make appflowy-deps-tools - - - name: Flutter Deps - run: flutter packages pub get - working-directory: frontend/app_flowy - - - name: Build FlowySDK - working-directory: frontend - run: | - cargo make --profile development-linux-x86_64 appflowy-sdk-dev - - - name: Flutter Code Generation - working-directory: frontend/app_flowy - run: | - flutter packages pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations -s en.json - flutter packages pub run build_runner build --delete-conflicting-outputs - - - name: Run Flutter Analyzer - working-directory: frontend/app_flowy - run: flutter analyze diff --git a/.github/workflows/dart_test.yml b/.github/workflows/dart_test.yml deleted file mode 100644 index 978ebe4696..0000000000 --- a/.github/workflows/dart_test.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Frontend test - -on: - push: - branches: - - "main" - - "release/*" - paths: - - "frontend/app_flowy/**" - - pull_request: - branches: - - "main" - - "release/*" - paths: - - "frontend/app_flowy/**" - -env: - CARGO_TERM_COLOR: always - -jobs: - tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: "stable-2022-04-07" - - - uses: subosito/flutter-action@v2 - with: - channel: "stable" - flutter-version: "3.3.9" - cache: true - - - name: Cache Cargo - uses: actions/cache@v2 - with: - path: | - ~/.cargo - key: ${{ runner.os }}-cargo-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - name: Cache Rust - id: cache-rust-target - uses: actions/cache@v2 - with: - path: | - frontend/rust-lib/target - shared-lib/target - key: ${{ runner.os }}-rust-rust-lib-share-lib-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - if: steps.cache-cargo.outputs.cache-hit != 'true' - name: Rust Deps - working-directory: frontend - run: | - cargo install cargo-make - cargo make appflowy-deps-tools - - - name: Flutter Deps - working-directory: frontend/app_flowy - run: | - flutter config --enable-linux-desktop - - - name: Build Test lib - working-directory: frontend - run: | - cargo make --profile test-linux build-test-lib - - - name: Flutter Code Generation - working-directory: frontend/app_flowy - run: | - flutter packages pub get - flutter packages pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations -s en.json - flutter packages pub run build_runner build --delete-conflicting-outputs - - - name: Run bloc tests - working-directory: frontend/app_flowy - run: | - flutter pub get - flutter test diff --git a/.github/workflows/integration_test.yml b/.github/workflows/flutter_ci.yaml similarity index 54% rename from .github/workflows/integration_test.yml rename to .github/workflows/flutter_ci.yaml index 5ba7714e28..674e3a54c9 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/flutter_ci.yaml @@ -1,4 +1,4 @@ -name: integration test +name: Flutter-CI on: push: @@ -6,56 +6,68 @@ on: - "main" - "release/*" paths: - - "frontend/app_flowy/**" + - "frontend/**" pull_request: branches: - "main" - "release/*" paths: - - "frontend/app_flowy/**" + - "frontend/**" env: - CARGO_TERM_COLOR: always + FLUTTER_VERSION: "3.3.9" + RUST_TOOLCHAIN: "1.65" jobs: - tests: + build: strategy: + fail-fast: false matrix: - os: [macos-latest] - + job: + - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest,} + - { target: x86_64-apple-darwin, os: macos-latest, } + - { target: x86_64-pc-windows-msvc, os: windows-latest, } + include: + - os: ubuntu-latest + flutter_profile: development-linux-x86_64 + - os: macos-latest + flutter_profile: development-mac-x86_64 + - os: windows-latest + flutter_profile: development-windows-x86 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: "stable-2022-04-07" + - name: Checkout source code + uses: actions/checkout@v2 - - uses: subosito/flutter-action@v2 + - name: Install Rust toolchain + id: rust_toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + target: ${{ matrix.job.target }} + override: true + components: rustfmt + profile: minimal + + - name: Install flutter + id: flutter + uses: subosito/flutter-action@v2 with: channel: "stable" - flutter-version: "3.3.9" + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true - - name: Cache Cargo - uses: actions/cache@v2 + - uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo - key: ${{ runner.os }}-cargo-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} + prefix-key: ${{ matrix.job.os }} - - name: Cache Rust - id: cache-rust-target - uses: actions/cache@v2 - with: - path: | - frontend/rust-lib/target - shared-lib/target - key: ${{ runner.os }}-rust-rust-lib-share-lib-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - name: Setup Environment + - name: Install prerequisites + working-directory: frontend run: | + cargo install --force cargo-make + cargo install --force duckscript_cli if [ "$RUNNER_OS" == "Linux" ]; then sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list @@ -64,31 +76,12 @@ jobs: sudo apt-get install keybinder-3.0 elif [ "$RUNNER_OS" == "Windows" ]; then vcpkg integrate install - cargo install --force duckscript_cli elif [ "$RUNNER_OS" == "macOS" ]; then echo 'do nothing' fi shell: bash - - if: steps.cache-cargo.outputs.cache-hit != 'true' - name: Rust Deps - working-directory: frontend - run: | - cargo install cargo-make - cargo make appflowy-deps-tools - - - name: Build Test lib - working-directory: frontend - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - cargo make --profile production-linux-x86_64 appflowy - elif [ "$RUNNER_OS" == "macOS" ]; then - cargo make --profile production-mac-x86_64 appflowy - elif [ "$RUNNER_OS" == "Windows" ]; then - cargo make --profile production-windows-x86 appflowy - fi - - - name: Config Flutter + - name: Enable Flutter Desktop run: | if [ "$RUNNER_OS" == "Linux" ]; then flutter config --enable-linux-desktop @@ -99,14 +92,30 @@ jobs: fi shell: bash - - name: Flutter Code Generation + - name: Build AppFlowy + working-directory: frontend + run: | + cargo make --profile ${{ matrix.flutter_profile }} appflowy-dev + + - name: Flutter Analyzer + working-directory: frontend/app_flowy + run: flutter analyze + + #Just run one platform + - if: $RUNNER_OS" == "Linux" + name: Build Flutter unit test lib + working-directory: frontend + run: | + cargo make build-test-lib + + - if: $RUNNER_OS" == "Linux" + name: Run Flutter unit tests working-directory: frontend/app_flowy run: | - flutter packages pub get - flutter packages pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations -s en.json - flutter packages pub run build_runner build --delete-conflicting-outputs + flutter pub get + flutter test - - name: Run AppFlowy tests + - name: Run Flutter integration tests working-directory: frontend/app_flowy run: | if [ "$RUNNER_OS" == "Linux" ]; then @@ -119,10 +128,9 @@ jobs: shell: bash - uses: codecov/codecov-action@v3 - with: + with: name: appflowy flags: appflowy env_vars: ${{ matrix.os }} fail_ci_if_error: true verbose: true - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 72aadb4383..dffdcf3312 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,10 @@ on: tags: - '*' +env: + FLUTTER_VERSION: "3.3.9" + RUST_TOOLCHAIN: "1.65" + jobs: create-release: runs-on: ubuntu-latest @@ -31,268 +35,48 @@ jobs: release_name: v${{ github.ref }} body_path: ${{ env.RELEASE_NOTES_PATH }} - build-linux-x86: - runs-on: ubuntu-latest - needs: create-release - env: - LINUX_APP_RELEASE_PATH: frontend/app_flowy/product/${{ github.ref_name }}/linux/Release - LINUX_ZIP_NAME: AppFlowy-linux-x86.tar.gz - LINUX_PACKAGE_NAME: AppFlowy_${{ github.ref_name }}_linux-amd64.deb - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup environment - Rust and Cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: 'stable-2022-04-07' - - - name: Setup environment - Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - flutter-version: '3.3.9' - - - name: Pre build - working-directory: frontend - run: | - sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub - sudo apt-get update - sudo apt-get install -y build-essential libsqlite3-dev libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev - sudo apt-get install keybinder-3.0 - source $HOME/.cargo/env - cargo install --force cargo-make - cargo install --force duckscript_cli - cargo make appflowy-deps-tools - - - name: Build Linux app - working-directory: frontend - run: | - flutter config --enable-linux-desktop - cargo make --env APP_VERSION=${{ github.ref_name }} --profile production-linux-x86_64 appflowy - - - name: Configuring Linux Package - working-directory: frontend - run: | - mkdir -p ../${{ env.LINUX_APP_RELEASE_PATH }}/package/opt - mkdir -p ../${{ env.LINUX_APP_RELEASE_PATH }}/package/usr/share/applications - cp -r ./scripts/linux_installer ../${{ env.LINUX_APP_RELEASE_PATH }}/package/DEBIAN - cd ../${{ env.LINUX_APP_RELEASE_PATH }}/package/DEBIAN - grep -rl "\[CHANGE_THIS\]" ./control | xargs sed -i "s/\[CHANGE_THIS\]/${{ github.ref_name }}/" - chmod 0755 {postinst,postrm} - - - name: Build Linux package - working-directory: ${{ env.LINUX_APP_RELEASE_PATH }} - run: | - mv AppFlowy package/opt/ - cd package - - # Update Exec & icon path in desktop entry - grep -rl "\[CHANGE_THIS\]" ./opt/AppFlowy/appflowy.desktop.temp | xargs sed -i "s/\[CHANGE_THIS\]/\/opt/" - # Add desktop entry in package - mv ./opt/AppFlowy/appflowy.desktop.temp ./usr/share/applications/appflowy.desktop - - # Build - cd ../ && dpkg-deb --build --root-owner-group -Z xz package ${{ env.LINUX_PACKAGE_NAME }} - - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ${{ env.LINUX_APP_RELEASE_PATH }}/${{ env.LINUX_ZIP_NAME }} - asset_name: ${{ env.LINUX_ZIP_NAME }} - asset_content_type: application/octet-stream - - - name: Upload Release Asset Install Package - id: upload-release-asset-install-package - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ${{ env.LINUX_APP_RELEASE_PATH }}/${{ env.LINUX_PACKAGE_NAME }} - asset_name: ${{ env.LINUX_PACKAGE_NAME }} - asset_content_type: application/octet-stream - - build-linux-x86-alt: - runs-on: ubuntu-18.04 - needs: create-release - env: - LINUX_APP_RELEASE_PATH: frontend/app_flowy/product/${{ github.ref_name }}/linux/Release - LINUX_PACKAGE_NAME: AppFlowy_${{ github.ref_name }}_linux-amd64-alt.deb - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup environment - Rust and Cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: 'stable-2022-04-07' - - - name: Setup environment - Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - flutter-version: '3.3.9' - - - name: Pre build - working-directory: frontend - run: | - sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub - sudo apt-get update - sudo apt-get install -y build-essential libsqlite3-dev libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev - sudo apt-get install keybinder-3.0 - source $HOME/.cargo/env - cargo install --force cargo-make - cargo install --force duckscript_cli - cargo make appflowy-deps-tools - - - name: Build Linux app - working-directory: frontend - run: | - flutter config --enable-linux-desktop - cargo make --env APP_VERSION=${{ github.ref_name }} --profile production-linux-x86_64 appflowy - - - name: Configuring Linux Package - working-directory: frontend - run: | - mkdir -p ../${{ env.LINUX_APP_RELEASE_PATH }}/package/opt - mkdir -p ../${{ env.LINUX_APP_RELEASE_PATH }}/package/usr/share/applications - cp -r ./scripts/linux_installer ../${{ env.LINUX_APP_RELEASE_PATH }}/package/DEBIAN - cd ../${{ env.LINUX_APP_RELEASE_PATH }}/package/DEBIAN - grep -rl "\[CHANGE_THIS\]" ./control | xargs sed -i "s/\[CHANGE_THIS\]/${{ github.ref_name }}/" - chmod 0755 {postinst,postrm} - - - name: Build Linux package - working-directory: ${{ env.LINUX_APP_RELEASE_PATH }} - run: | - mv AppFlowy package/opt/ - cd package - - # Update Exec & icon path in desktop entry - grep -rl "\[CHANGE_THIS\]" ./opt/AppFlowy/appflowy.desktop.temp | xargs sed -i "s/\[CHANGE_THIS\]/\/opt/" - # Add desktop entry in package - mv ./opt/AppFlowy/appflowy.desktop.temp ./usr/share/applications/appflowy.desktop - - # Build - cd ../ && dpkg-deb --build --root-owner-group -Z xz package ${{ env.LINUX_PACKAGE_NAME }} - - - name: Upload Alternative Release Asset Install Package - id: upload-release-asset-install-package - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ${{ env.LINUX_APP_RELEASE_PATH }}/${{ env.LINUX_PACKAGE_NAME }} - asset_name: ${{ env.LINUX_PACKAGE_NAME }} - asset_content_type: application/octet-stream - - build-macos-x86_64: - runs-on: macos-latest - needs: create-release - env: - MACOS_APP_RELEASE_PATH: frontend/app_flowy/product/${{ github.ref_name }}/macos/Release - MACOS_X86_ZIP_NAME: Appflowy-macos-x86_64.zip - MACOS_DMG_NAME: Appflowy-macos-x86_64-installer - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup environment - Rust and Cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: 'stable-2022-04-07' - - - name: Setup environment - Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - flutter-version: '3.3.9' - - - name: Pre build - working-directory: frontend - run: | - source $HOME/.cargo/env - cargo install --force cargo-make - cargo install --force duckscript_cli - cargo make appflowy-deps-tools - - - name: Build macOS app for x86_64 - working-directory: frontend - run: | - flutter config --enable-macos-desktop - cargo make --env APP_VERSION=${{ github.ref_name }} --profile production-mac-x86_64 appflowy - - - name: Create MacOS dmg - run: | - brew install create-dmg - create-dmg \ - --volname ${{ env.MACOS_DMG_NAME }} \ - --hide-extension "AppFlowy.app" \ - --background frontend/scripts/dmg_assets/AppFlowyInstallerBackground.jpg \ - --window-size 600 450 \ - --icon-size 94 \ - --icon "AppFlowy.app" 141 249 \ - --app-drop-link 458 249 \ - "${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_DMG_NAME }}.dmg" \ - "${{ env.MACOS_APP_RELEASE_PATH }}/AppFlowy.app" - - - name: Archive macOS app - working-directory: ${{ env.MACOS_APP_RELEASE_PATH }} - run: zip --symlinks -qr ${{ env.MACOS_X86_ZIP_NAME }} AppFlowy.app - - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_X86_ZIP_NAME }} - asset_name: ${{ env.MACOS_X86_ZIP_NAME }} - asset_content_type: application/octet-stream - - name: Upload DMG Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_DMG_NAME }}.dmg - asset_name: ${{ env.MACOS_DMG_NAME }}.dmg - asset_content_type: application/octet-stream - - build-windows-x86_64: - runs-on: windows-latest + build-for-windows: + name: ${{ matrix.job.target }} (${{ matrix.job.os }}) needs: create-release env: WINDOWS_APP_RELEASE_PATH: frontend\app_flowy\product\${{ github.ref_name }}\windows - WINDOWS_ZIP_NAME: AppFlowy-windows-x86_64.zip - WINDOWS_INSTALLER_NAME: AppFlowy-${{ github.ref_name }}-windows-x86_64 + WINDOWS_ZIP_NAME: AppFlowy_${{ github.ref_name }}_windows-x86_64.zip + WINDOWS_INSTALLER_NAME: AppFlowy_${{ github.ref_name }}_windows-x86_64 + runs-on: ${{ matrix.job.os }} + strategy: + fail-fast: false + matrix: + job: + - { target: x86_64-pc-windows-msvc, os: windows-2019 } steps: - - name: Checkout + - name: Checkout source code uses: actions/checkout@v3 - - name: Setup environment - Rust and Cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: 'stable-2022-04-07' - - - name: Setup environment - Flutter + - name: Install flutter uses: subosito/flutter-action@v2 with: - channel: 'stable' - flutter-version: '3.3.9' + channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true - - name: Pre build + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + target: ${{ matrix.job.target }} + override: true + components: rustfmt + profile: minimal + + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: ${{ matrix.job.os }} + + - name: Install prerequisites working-directory: frontend run: | - vcpkg integrate install cargo install --force cargo-make cargo install --force duckscript_cli - cargo make appflowy-deps-tools - name: Build Windows app working-directory: frontend @@ -300,11 +84,12 @@ jobs: flutter config --enable-windows-desktop cargo make --env APP_VERSION=${{ github.ref_name }} --profile production-windows-x86 appflowy - - uses: vimtor/action-zip@v1 + - name: Archive Asset + uses: vimtor/action-zip@v1 with: files: ${{ env.WINDOWS_APP_RELEASE_PATH }}\ dest: ${{ env.WINDOWS_APP_RELEASE_PATH }}\${{ env.WINDOWS_ZIP_NAME }} - + - name: Copy installer config & icon file working-directory: frontend run: | @@ -315,7 +100,7 @@ jobs: run: | iscc /F${{ env.WINDOWS_INSTALLER_NAME }} inno_setup_config.iss /DAppVersion=${{ github.ref_name }} - - name: Upload Release Asset + - name: Upload Asset id: upload-release-asset uses: actions/upload-release-asset@v1 env: @@ -336,3 +121,221 @@ jobs: asset_path: ${{ env.WINDOWS_APP_RELEASE_PATH }}\Output\${{ env.WINDOWS_INSTALLER_NAME }}.exe asset_name: ${{ env.WINDOWS_INSTALLER_NAME }}.exe asset_content_type: application/octet-stream + + build-for-macOS: + name: ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-args }}] + runs-on: ${{ matrix.job.os }} + needs: create-release + env: + MACOS_APP_RELEASE_PATH: frontend/app_flowy/product/${{ github.ref_name }}/macos/Release + MACOS_X86_ZIP_NAME: AppFlowy_${{ github.ref_name }}_macos-x86_64.zip + MACOS_DMG_NAME: AppFlowy_${{ github.ref_name }}_macos-x86_64 + strategy: + fail-fast: false + matrix: + job: + - { target: x86_64-apple-darwin, os: macos-10.15, extra-build-args: "" } + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Install flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + target: ${{ matrix.job.target }} + override: true + components: rustfmt + profile: minimal + + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: ${{ matrix.job.os }} + + - name: Install prerequisites + working-directory: frontend + run: | + cargo install --force cargo-make + cargo install --force duckscript_cli + + - name: Build AppFlowy + working-directory: frontend + run: | + flutter config --enable-macos-desktop + cargo make --env APP_VERSION=${{ github.ref_name }} --profile production-mac-x86_64 appflowy + + - name: Create macOS dmg + run: | + brew install create-dmg + create-dmg \ + --volname ${{ env.MACOS_DMG_NAME }} \ + --hide-extension "AppFlowy.app" \ + --background frontend/scripts/dmg_assets/AppFlowyInstallerBackground.jpg \ + --window-size 600 450 \ + --icon-size 94 \ + --icon "AppFlowy.app" 141 249 \ + --app-drop-link 458 249 \ + "${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_DMG_NAME }}.dmg" \ + "${{ env.MACOS_APP_RELEASE_PATH }}/AppFlowy.app" + + - name: Archive Asset + working-directory: ${{ env.MACOS_APP_RELEASE_PATH }} + run: zip --symlinks -qr ${{ env.MACOS_X86_ZIP_NAME }} AppFlowy.app + + - name: Upload Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_X86_ZIP_NAME }} + asset_name: ${{ env.MACOS_X86_ZIP_NAME }} + asset_content_type: application/octet-stream + + - name: Upload DMG Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ${{ env.MACOS_APP_RELEASE_PATH }}/${{ env.MACOS_DMG_NAME }}.dmg + asset_name: ${{ env.MACOS_DMG_NAME }}.dmg + asset_content_type: application/octet-stream + + build-for-linux: + name: ${{ matrix.job.target }} (${{ matrix.job.os }}) [${{ matrix.job.extra-build-args }}] + runs-on: ${{ matrix.job.os }} + needs: create-release + env: + LINUX_APP_RELEASE_PATH: frontend/app_flowy/product/${{ github.ref_name }}/linux/Release + LINUX_ZIP_NAME: AppFlowy_${{ matrix.job.target }}_${{ matrix.job.os }}.tar.gz + LINUX_PACKAGE_NAME: AppFlowy_${{ github.ref_name }}_${{ matrix.job.os }}.deb + strategy: + fail-fast: false + matrix: + job: + - { arch: x86_64, target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, extra-build-args: "", } + - { arch: x86_64, target: x86_64-unknown-linux-gnu, os: ubuntu-18.04, extra-build-args: "", } + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Install flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + target: ${{ matrix.job.target }} + override: true + components: rustfmt + profile: minimal + + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: ${{ matrix.job.os }} + + - name: Install prerequisites + working-directory: frontend + run: | + sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub + sudo apt-get update + sudo apt-get install -y build-essential libsqlite3-dev libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev + sudo apt-get install keybinder-3.0 + source $HOME/.cargo/env + cargo install --force cargo-make + cargo install --force duckscript_cli + + - name: Build AppFlowy + working-directory: frontend + run: | + flutter config --enable-linux-desktop + cargo make --env APP_VERSION=${{ github.ref_name }} --profile production-linux-x86_64 appflowy + + - name: Archive Assert + working-directory: ${{ env.LINUX_APP_RELEASE_PATH }} + run: tar -czf ${{ env.LINUX_ZIP_NAME }} * + + - name: Configuring Linux Package + working-directory: frontend + run: | + mkdir -p ../${{ env.LINUX_APP_RELEASE_PATH }}/package/opt + mkdir -p ../${{ env.LINUX_APP_RELEASE_PATH }}/package/usr/share/applications + cp -r ./scripts/linux_installer ../${{ env.LINUX_APP_RELEASE_PATH }}/package/DEBIAN + cd ../${{ env.LINUX_APP_RELEASE_PATH }}/package/DEBIAN + grep -rl "\[CHANGE_THIS\]" ./control | xargs sed -i "s/\[CHANGE_THIS\]/${{ github.ref_name }}/" + chmod 0755 {postinst,postrm} + + - name: Build Linux package + working-directory: ${{ env.LINUX_APP_RELEASE_PATH }} + run: | + mv AppFlowy package/opt/ + cd package + + # Update Exec & icon path in desktop entry + grep -rl "\[CHANGE_THIS\]" ./opt/AppFlowy/appflowy.desktop.temp | xargs sed -i "s/\[CHANGE_THIS\]/\/opt/" + # Add desktop entry in package + mv ./opt/AppFlowy/appflowy.desktop.temp ./usr/share/applications/appflowy.desktop + + # Build + cd ../ && dpkg-deb --build --root-owner-group -Z xz package ${{ env.LINUX_PACKAGE_NAME }} + + - name: Upload Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ${{ env.LINUX_APP_RELEASE_PATH }}/${{ env.LINUX_ZIP_NAME }} + asset_name: ${{ env.LINUX_ZIP_NAME }} + asset_content_type: application/octet-stream + + - name: Upload Asset Install Package + id: upload-release-asset-install-package + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ${{ env.LINUX_APP_RELEASE_PATH }}/${{ env.LINUX_PACKAGE_NAME }} + asset_name: ${{ env.LINUX_PACKAGE_NAME }} + asset_content_type: application/octet-stream + +# build-for-docker: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v2 +# +# - name: Login to Docker Hub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKER_HUB_USERNAME }} +# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} +# +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v1 +# +# - name: Build and push +# uses: docker/build-push-action@v2 +# with: +# context: . +# file: ./frontend/scripts/docker-buildfiles/Dockerfile +# builder: ${{ steps.buildx.outputs.name }} +# push: true +# tags: ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_client:${{ github.ref_name }} +# cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/af_build_cache:buildcache +# cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/af_build_cache:buildcache,mode=max diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml deleted file mode 100644 index 5c64195ef3..0000000000 --- a/.github/workflows/release_docker.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: release_docker - -on: - push: - branches: - - 'main' - tags: - - '*' - -jobs: - build-docker-image: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - file: ./frontend/scripts/docker-buildfiles/Dockerfile - builder: ${{ steps.buildx.outputs.name }} - push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_client:${{ github.ref_name }} - cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/af_build_cache:buildcache - cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/af_build_cache:buildcache,mode=max diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yaml new file mode 100644 index 0000000000..d5f57aca64 --- /dev/null +++ b/.github/workflows/rust_ci.yaml @@ -0,0 +1,74 @@ +name: Rust-CI + +on: + push: + branches: + - "main" + - "release/*" + paths: + - "frontend/rust-lib/**" + - "shared-lib/**" + + pull_request: + branches: + - "main" + - "release/*" + paths: + - "frontend/rust-lib/**" + - "shared-lib/**" + +env: + CARGO_TERM_COLOR: always + RUST_TOOLCHAIN: "1.65" + +jobs: + test-on-ubuntu: + runs-on: ubuntu-latest + steps: + - name: Install Rust toolchain + id: rust_toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + override: true + components: rustfmt, clippy + profile: minimal + + - name: Install prerequisites + working-directory: frontend + run: | + cargo install --force cargo-make + cargo install --force duckscript_cli + + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: ${{ matrix.job.os }} + + - name: Build FlowySDK + working-directory: frontend + run: | + cargo make --profile development-linux-x86_64 appflowy-sdk-dev + + - name: rustfmt rust-lib + run: cargo fmt --all -- --check + working-directory: frontend/rust-lib/ + + - name: clippy rust-lib + run: cargo clippy --no-default-features + working-directory: frontend/rust-lib + + - name: Run rust-lib tests + working-directory: frontend/rust-lib + run: RUST_LOG=info cargo test --no-default-features --features="sync" + + - name: rustfmt shared-lib + run: cargo fmt --all -- --check + working-directory: shared-lib + + - name: clippy shared-lib + run: cargo clippy --no-default-features + working-directory: shared-lib + + - name: Run shared-lib tests + working-directory: shared-lib + run: RUST_LOG=info cargo test --no-default-features diff --git a/.github/workflows/rust_coverage.yml b/.github/workflows/rust_coverage.yml index 578368ac15..c98c3d0a4d 100644 --- a/.github/workflows/rust_coverage.yml +++ b/.github/workflows/rust_coverage.yml @@ -11,52 +11,45 @@ on: env: CARGO_TERM_COLOR: always + FLUTTER_VERSION: "3.3.9" + RUST_TOOLCHAIN: "1.65" jobs: tests: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - - id: rust_toolchain + - name: Install Rust toolchain + id: rust_toolchain uses: actions-rs/toolchain@v1 with: - toolchain: 'stable-2022-04-07' + toolchain: ${{ env.RUST_TOOLCHAIN }} + target: ${{ matrix.job.target }} + override: true + profile: minimal - - name: Cache Cargo - uses: actions/cache@v2 - with: - path: | - ~/.cargo - key: ${{ runner.os }}-cargo-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - name: Cache Rust - uses: actions/cache@v2 - with: - path: | - frontend/rust-lib/target - shared-lib/target - key: ${{ runner.os }}-rust-rust-lib-share-lib-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - - name: Install cargo-make - working-directory: frontend - run: | - cargo install cargo-make - - - name: Setup environment - Flutter + - name: Install flutter + id: flutter uses: subosito/flutter-action@v2 with: - channel: 'stable' - flutter-version: '3.3.9' + channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true + + - name: Install prerequisites + working-directory: frontend + run: | + cargo install --force cargo-make + cargo install --force duckscript_cli + + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: ${{ matrix.job.os }} - name: Install code-coverage tools working-directory: frontend run: | sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub sudo apt-get update - sudo apt-get install -y build-essential libsqlite3-dev libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev sudo apt-get install keybinder-3.0 cargo install grcov rustup component add llvm-tools-preview diff --git a/.github/workflows/rust_lint.yml b/.github/workflows/rust_lint.yml deleted file mode 100644 index f7e20647d1..0000000000 --- a/.github/workflows/rust_lint.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Rust lint - -on: - push: - branches: - - "main" - - "release/*" - paths: - - "frontend/rust-lib/**" - - "shared-lib/**" - - pull_request: - branches: - - "main" - - "release/*" - paths: - - "frontend/rust-lib/**" - - "shared-lib/**" - -env: - CARGO_TERM_COLOR: always - -jobs: - rust-fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 'stable-2022-04-07' - override: true - - uses: subosito/flutter-action@v1 - with: - flutter-version: '3.3.9' - channel: "stable" - - - name: Rust Deps - working-directory: frontend - run: | - cargo install cargo-make - cargo make appflowy-deps-tools - - - name: Build FlowySDK - working-directory: frontend - run: | - cargo make --profile development-linux-x86_64 appflowy-sdk-dev - - - run: rustup component add rustfmt - working-directory: frontend/rust-lib - - name: rustfmt - run: cargo fmt --all -- --check - working-directory: frontend/rust-lib/ - - - - run: rustup component add clippy - working-directory: frontend/rust-lib - - name: clippy - run: cargo clippy --no-default-features - working-directory: frontend/rust-lib - diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml deleted file mode 100644 index 3f49d5085b..0000000000 --- a/.github/workflows/rust_test.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Backend test - -on: - push: - branches: - - "main" - - "release/*" - paths: - - "frontend/rust-lib/**" - - "shared-lib/**" - - pull_request: - branches: - - "main" - - "release/*" - paths: - - "frontend/rust-lib/**" - - "shared-lib/**" - -env: - CARGO_TERM_COLOR: always - -jobs: - tests: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - id: rust_toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: 'stable-2022-04-07' - - - name: Cache Cargo - uses: actions/cache@v2 - with: - path: | - ~/.cargo - key: ${{ runner.os }}-cargo-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - name: Cache Rust - uses: actions/cache@v2 - with: - path: | - frontend/rust-lib/target - shared-lib/target - key: ${{ runner.os }}-rust-rust-lib-share-lib-${{ steps.rust_toolchain.outputs.rustc_hash }}-${{ hashFiles('./frontend/rust-lib/Cargo.toml') }} - - - name: Install cargo-make - working-directory: frontend - run: cargo install cargo-make - - - name: Run rust-lib tests - working-directory: frontend/rust-lib - run: RUST_LOG=info cargo test --no-default-features --features="sync" - - - name: Run shared-lib tests - working-directory: shared-lib - run: RUST_LOG=info cargo test --no-default-features