From f80dc23f0b3ea9239512e856ea809ba18c232eaa Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 23 Sep 2024 13:20:04 +0800 Subject: [PATCH] feat: optimize integration test speed --- .github/actions/flutter_build/action.yml | 12 +- .github/workflows/flutter_ci.yaml | 189 ++++++++++++++--------- 2 files changed, 123 insertions(+), 78 deletions(-) diff --git a/.github/actions/flutter_build/action.yml b/.github/actions/flutter_build/action.yml index 66bfce44a5a6..f9a1d2a150a1 100644 --- a/.github/actions/flutter_build/action.yml +++ b/.github/actions/flutter_build/action.yml @@ -74,12 +74,10 @@ runs: - name: Build AppFlowy working-directory: frontend - run: cargo make --profile ${{ inputs.flutter_profile }} appflowy-core-dev - shell: bash - - - name: Run code generation - working-directory: frontend - run: cargo make code_generation + run: | + cargo make --profile ${{ inputs.flutter_profile }} appflowy-core-dev & + cargo make code_generation + wait shell: bash - name: Flutter Analyzer @@ -94,4 +92,4 @@ runs: - uses: actions/upload-artifact@v4 with: name: ${{ github.run_id }}-${{ matrix.os }} - path: appflowy_flutter.tar.gz \ No newline at end of file + path: appflowy_flutter.tar.gz diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yaml index 9b9725a09f56..f1ff527922b2 100644 --- a/.github/workflows/flutter_ci.yaml +++ b/.github/workflows/flutter_ci.yaml @@ -39,7 +39,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ ubuntu-latest ] + os: [ubuntu-latest] include: - os: ubuntu-latest flutter_profile: development-linux-x86_64 @@ -73,7 +73,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ windows-latest ] + os: [windows-latest] include: - os: windows-latest flutter_profile: development-windows-x86 @@ -100,7 +100,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ macos-latest ] + os: [macos-latest] include: - os: macos-latest flutter_profile: development-mac-x86_64 @@ -122,12 +122,12 @@ jobs: flutter_profile: ${{ matrix.flutter_profile }} unit_test: - needs: [ prepare-linux ] + needs: [prepare-linux] if: github.event.pull_request.draft != true strategy: fail-fast: false matrix: - os: [ ubuntu-latest ] + os: [ubuntu-latest] include: - os: ubuntu-latest flutter_profile: development-linux-x86_64 @@ -216,11 +216,11 @@ jobs: shell: bash cloud_integration_test: - needs: [ prepare-linux ] + needs: [prepare-linux] strategy: fail-fast: false matrix: - os: [ ubuntu-latest ] + os: [ubuntu-latest] include: - os: ubuntu-latest flutter_profile: development-linux-x86_64 @@ -317,96 +317,143 @@ jobs: sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & sudo apt-get install network-manager docker ps -a - flutter test integration_test/cloud/cloud_runner.dart -d Linux --coverage + flutter test integration_test/cloud/cloud_runner.dart -d Linux --coverage --reporter=github shell: bash # split the integration tests into different machines to minimize the time integration_test_1: - needs: [ prepare-linux ] + needs: [prepare-linux] if: github.event.pull_request.draft != true strategy: fail-fast: false matrix: - os: [ ubuntu-latest ] + os: [ubuntu-latest] + shard: [1, 2, 3, 4] include: - os: ubuntu-latest - target: 'x86_64-unknown-linux-gnu' + target: "x86_64-unknown-linux-gnu" runs-on: ${{ matrix.os }} steps: - name: Checkout source code uses: actions/checkout@v4 - - name: Install video dependency - run: | - sudo apt-get update - sudo apt-get -y install libmpv-dev mpv - shell: bash + - name: Install Rust toolchain + id: rust_toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + target: ${{ matrix.target }} + override: true + profile: minimal - - name: Flutter Integration Test 1 - uses: ./.github/actions/flutter_integration_test + - name: Install flutter + id: flutter + uses: subosito/flutter-action@v2 with: - test_path: integration_test/desktop_runner_1.dart - flutter_version: ${{ env.FLUTTER_VERSION }} - rust_toolchain: ${{ env.RUST_TOOLCHAIN }} - cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} - rust_target: ${{ matrix.target }} + channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true - integration_test_2: - needs: [ prepare-linux ] - if: github.event.pull_request.draft != true - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - include: - - os: ubuntu-latest - target: 'x86_64-unknown-linux-gnu' - runs-on: ${{ matrix.os }} - steps: - - name: Checkout source code - uses: actions/checkout@v4 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-make@${{ env.CARGO_MAKE_VERSION }} - - name: Install video dependency + - 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 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 -y install libmpv-dev mpv + sudo apt-get install -y dart curl build-essential libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev keybinder-3.0 libnotify-dev network-manager libmpv-dev mpv shell: bash - - name: Flutter Integration Test 2 - uses: ./.github/actions/flutter_integration_test + - name: Enable Flutter Desktop + run: | + flutter config --enable-linux-desktop + shell: bash + + - uses: actions/download-artifact@v4 with: - test_path: integration_test/desktop_runner_2.dart - flutter_version: ${{ env.FLUTTER_VERSION }} - rust_toolchain: ${{ env.RUST_TOOLCHAIN }} - cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} - rust_target: ${{ matrix.target }} + name: ${{ github.run_id }}-ubuntu-latest - integration_test_3: - needs: [ prepare-linux ] - if: github.event.pull_request.draft != true - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - include: - - os: ubuntu-latest - target: 'x86_64-unknown-linux-gnu' - runs-on: ${{ matrix.os }} - steps: - - name: Checkout source code - uses: actions/checkout@v4 + - name: Uncompressed appflowy_flutter + run: tar -xf appflowy_flutter.tar.gz + shell: bash - - name: Install video dependency + - name: Run Flutter integration tests + working-directory: frontend/appflowy_flutter run: | - sudo apt-get update - sudo apt-get -y install libmpv-dev mpv + export DISPLAY=:99 + sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & + sudo apt-get install network-manager + flutter test integration_test -d Linux --coverage --shard-index=${{ matrix.shard }} --total-shards=4 shell: bash - - name: Flutter Integration Test 3 - uses: ./.github/actions/flutter_integration_test - with: - test_path: integration_test/desktop_runner_3.dart - flutter_version: ${{ env.FLUTTER_VERSION }} - rust_toolchain: ${{ env.RUST_TOOLCHAIN }} - cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} - rust_target: ${{ matrix.target }} \ No newline at end of file + # - name: Flutter Integration Test 1 + # uses: ./.github/actions/flutter_integration_test + # with: + # test_path: integration_test/desktop_runner_1.dart + # flutter_version: ${{ env.FLUTTER_VERSION }} + # rust_toolchain: ${{ env.RUST_TOOLCHAIN }} + # cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} + # rust_target: ${{ matrix.target }} + + # integration_test_2: + # needs: [prepare-linux] + # if: github.event.pull_request.draft != true + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu-latest] + # include: + # - os: ubuntu-latest + # target: "x86_64-unknown-linux-gnu" + # runs-on: ${{ matrix.os }} + # steps: + # - name: Checkout source code + # uses: actions/checkout@v4 + + # - name: Install video dependency + # run: | + # sudo apt-get update + # sudo apt-get -y install libmpv-dev mpv + # shell: bash + + # - name: Flutter Integration Test 2 + # uses: ./.github/actions/flutter_integration_test + # with: + # test_path: integration_test/desktop_runner_2.dart + # flutter_version: ${{ env.FLUTTER_VERSION }} + # rust_toolchain: ${{ env.RUST_TOOLCHAIN }} + # cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} + # rust_target: ${{ matrix.target }} + + # integration_test_3: + # needs: [prepare-linux] + # if: github.event.pull_request.draft != true + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu-latest] + # include: + # - os: ubuntu-latest + # target: "x86_64-unknown-linux-gnu" + # runs-on: ${{ matrix.os }} + # steps: + # - name: Checkout source code + # uses: actions/checkout@v4 + + # - name: Install video dependency + # run: | + # sudo apt-get update + # sudo apt-get -y install libmpv-dev mpv + # shell: bash + + # - name: Flutter Integration Test 3 + # uses: ./.github/actions/flutter_integration_test + # with: + # test_path: integration_test/desktop_runner_3.dart + # flutter_version: ${{ env.FLUTTER_VERSION }} + # rust_toolchain: ${{ env.RUST_TOOLCHAIN }} + # cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} + # rust_target: ${{ matrix.target }}