Skip to content

Commit

Permalink
feat: optimize integration test speed
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 committed Sep 23, 2024
1 parent 0d28412 commit a2bac4f
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 78 deletions.
12 changes: 5 additions & 7 deletions .github/actions/flutter_build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -94,4 +92,4 @@ runs:
- uses: actions/upload-artifact@v4
with:
name: ${{ github.run_id }}-${{ matrix.os }}
path: appflowy_flutter.tar.gz
path: appflowy_flutter.tar.gz
189 changes: 118 additions & 71 deletions .github/workflows/flutter_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }} --shard-count 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 }}
# - 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 }}

0 comments on commit a2bac4f

Please sign in to comment.