Skip to content

Commit f80dc23

Browse files
committed
feat: optimize integration test speed
1 parent 0d28412 commit f80dc23

File tree

2 files changed

+123
-78
lines changed

2 files changed

+123
-78
lines changed

.github/actions/flutter_build/action.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ runs:
7474

7575
- name: Build AppFlowy
7676
working-directory: frontend
77-
run: cargo make --profile ${{ inputs.flutter_profile }} appflowy-core-dev
78-
shell: bash
79-
80-
- name: Run code generation
81-
working-directory: frontend
82-
run: cargo make code_generation
77+
run: |
78+
cargo make --profile ${{ inputs.flutter_profile }} appflowy-core-dev &
79+
cargo make code_generation
80+
wait
8381
shell: bash
8482

8583
- name: Flutter Analyzer
@@ -94,4 +92,4 @@ runs:
9492
- uses: actions/upload-artifact@v4
9593
with:
9694
name: ${{ github.run_id }}-${{ matrix.os }}
97-
path: appflowy_flutter.tar.gz
95+
path: appflowy_flutter.tar.gz

.github/workflows/flutter_ci.yaml

Lines changed: 118 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
strategy:
4040
fail-fast: true
4141
matrix:
42-
os: [ ubuntu-latest ]
42+
os: [ubuntu-latest]
4343
include:
4444
- os: ubuntu-latest
4545
flutter_profile: development-linux-x86_64
@@ -73,7 +73,7 @@ jobs:
7373
strategy:
7474
fail-fast: true
7575
matrix:
76-
os: [ windows-latest ]
76+
os: [windows-latest]
7777
include:
7878
- os: windows-latest
7979
flutter_profile: development-windows-x86
@@ -100,7 +100,7 @@ jobs:
100100
strategy:
101101
fail-fast: true
102102
matrix:
103-
os: [ macos-latest ]
103+
os: [macos-latest]
104104
include:
105105
- os: macos-latest
106106
flutter_profile: development-mac-x86_64
@@ -122,12 +122,12 @@ jobs:
122122
flutter_profile: ${{ matrix.flutter_profile }}
123123

124124
unit_test:
125-
needs: [ prepare-linux ]
125+
needs: [prepare-linux]
126126
if: github.event.pull_request.draft != true
127127
strategy:
128128
fail-fast: false
129129
matrix:
130-
os: [ ubuntu-latest ]
130+
os: [ubuntu-latest]
131131
include:
132132
- os: ubuntu-latest
133133
flutter_profile: development-linux-x86_64
@@ -216,11 +216,11 @@ jobs:
216216
shell: bash
217217

218218
cloud_integration_test:
219-
needs: [ prepare-linux ]
219+
needs: [prepare-linux]
220220
strategy:
221221
fail-fast: false
222222
matrix:
223-
os: [ ubuntu-latest ]
223+
os: [ubuntu-latest]
224224
include:
225225
- os: ubuntu-latest
226226
flutter_profile: development-linux-x86_64
@@ -317,96 +317,143 @@ jobs:
317317
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
318318
sudo apt-get install network-manager
319319
docker ps -a
320-
flutter test integration_test/cloud/cloud_runner.dart -d Linux --coverage
320+
flutter test integration_test/cloud/cloud_runner.dart -d Linux --coverage --reporter=github
321321
shell: bash
322322

323323
# split the integration tests into different machines to minimize the time
324324
integration_test_1:
325-
needs: [ prepare-linux ]
325+
needs: [prepare-linux]
326326
if: github.event.pull_request.draft != true
327327
strategy:
328328
fail-fast: false
329329
matrix:
330-
os: [ ubuntu-latest ]
330+
os: [ubuntu-latest]
331+
shard: [1, 2, 3, 4]
331332
include:
332333
- os: ubuntu-latest
333-
target: 'x86_64-unknown-linux-gnu'
334+
target: "x86_64-unknown-linux-gnu"
334335
runs-on: ${{ matrix.os }}
335336
steps:
336337
- name: Checkout source code
337338
uses: actions/checkout@v4
338339

339-
- name: Install video dependency
340-
run: |
341-
sudo apt-get update
342-
sudo apt-get -y install libmpv-dev mpv
343-
shell: bash
340+
- name: Install Rust toolchain
341+
id: rust_toolchain
342+
uses: actions-rs/toolchain@v1
343+
with:
344+
toolchain: ${{ env.RUST_TOOLCHAIN }}
345+
target: ${{ matrix.target }}
346+
override: true
347+
profile: minimal
344348

345-
- name: Flutter Integration Test 1
346-
uses: ./.github/actions/flutter_integration_test
349+
- name: Install flutter
350+
id: flutter
351+
uses: subosito/flutter-action@v2
347352
with:
348-
test_path: integration_test/desktop_runner_1.dart
349-
flutter_version: ${{ env.FLUTTER_VERSION }}
350-
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
351-
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
352-
rust_target: ${{ matrix.target }}
353+
channel: "stable"
354+
flutter-version: ${{ env.FLUTTER_VERSION }}
355+
cache: true
353356

354-
integration_test_2:
355-
needs: [ prepare-linux ]
356-
if: github.event.pull_request.draft != true
357-
strategy:
358-
fail-fast: false
359-
matrix:
360-
os: [ ubuntu-latest ]
361-
include:
362-
- os: ubuntu-latest
363-
target: 'x86_64-unknown-linux-gnu'
364-
runs-on: ${{ matrix.os }}
365-
steps:
366-
- name: Checkout source code
367-
uses: actions/checkout@v4
357+
- uses: taiki-e/install-action@v2
358+
with:
359+
tool: cargo-make@${{ env.CARGO_MAKE_VERSION }}
368360

369-
- name: Install video dependency
361+
- name: Install prerequisites
362+
working-directory: frontend
370363
run: |
364+
sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub
365+
sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list
371366
sudo apt-get update
372-
sudo apt-get -y install libmpv-dev mpv
367+
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
373368
shell: bash
374369

375-
- name: Flutter Integration Test 2
376-
uses: ./.github/actions/flutter_integration_test
370+
- name: Enable Flutter Desktop
371+
run: |
372+
flutter config --enable-linux-desktop
373+
shell: bash
374+
375+
- uses: actions/download-artifact@v4
377376
with:
378-
test_path: integration_test/desktop_runner_2.dart
379-
flutter_version: ${{ env.FLUTTER_VERSION }}
380-
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
381-
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
382-
rust_target: ${{ matrix.target }}
377+
name: ${{ github.run_id }}-ubuntu-latest
383378

384-
integration_test_3:
385-
needs: [ prepare-linux ]
386-
if: github.event.pull_request.draft != true
387-
strategy:
388-
fail-fast: false
389-
matrix:
390-
os: [ ubuntu-latest ]
391-
include:
392-
- os: ubuntu-latest
393-
target: 'x86_64-unknown-linux-gnu'
394-
runs-on: ${{ matrix.os }}
395-
steps:
396-
- name: Checkout source code
397-
uses: actions/checkout@v4
379+
- name: Uncompressed appflowy_flutter
380+
run: tar -xf appflowy_flutter.tar.gz
381+
shell: bash
398382

399-
- name: Install video dependency
383+
- name: Run Flutter integration tests
384+
working-directory: frontend/appflowy_flutter
400385
run: |
401-
sudo apt-get update
402-
sudo apt-get -y install libmpv-dev mpv
386+
export DISPLAY=:99
387+
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
388+
sudo apt-get install network-manager
389+
flutter test integration_test -d Linux --coverage --shard-index=${{ matrix.shard }} --total-shards=4
403390
shell: bash
404391

405-
- name: Flutter Integration Test 3
406-
uses: ./.github/actions/flutter_integration_test
407-
with:
408-
test_path: integration_test/desktop_runner_3.dart
409-
flutter_version: ${{ env.FLUTTER_VERSION }}
410-
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
411-
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
412-
rust_target: ${{ matrix.target }}
392+
# - name: Flutter Integration Test 1
393+
# uses: ./.github/actions/flutter_integration_test
394+
# with:
395+
# test_path: integration_test/desktop_runner_1.dart
396+
# flutter_version: ${{ env.FLUTTER_VERSION }}
397+
# rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
398+
# cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
399+
# rust_target: ${{ matrix.target }}
400+
401+
# integration_test_2:
402+
# needs: [prepare-linux]
403+
# if: github.event.pull_request.draft != true
404+
# strategy:
405+
# fail-fast: false
406+
# matrix:
407+
# os: [ubuntu-latest]
408+
# include:
409+
# - os: ubuntu-latest
410+
# target: "x86_64-unknown-linux-gnu"
411+
# runs-on: ${{ matrix.os }}
412+
# steps:
413+
# - name: Checkout source code
414+
# uses: actions/checkout@v4
415+
416+
# - name: Install video dependency
417+
# run: |
418+
# sudo apt-get update
419+
# sudo apt-get -y install libmpv-dev mpv
420+
# shell: bash
421+
422+
# - name: Flutter Integration Test 2
423+
# uses: ./.github/actions/flutter_integration_test
424+
# with:
425+
# test_path: integration_test/desktop_runner_2.dart
426+
# flutter_version: ${{ env.FLUTTER_VERSION }}
427+
# rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
428+
# cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
429+
# rust_target: ${{ matrix.target }}
430+
431+
# integration_test_3:
432+
# needs: [prepare-linux]
433+
# if: github.event.pull_request.draft != true
434+
# strategy:
435+
# fail-fast: false
436+
# matrix:
437+
# os: [ubuntu-latest]
438+
# include:
439+
# - os: ubuntu-latest
440+
# target: "x86_64-unknown-linux-gnu"
441+
# runs-on: ${{ matrix.os }}
442+
# steps:
443+
# - name: Checkout source code
444+
# uses: actions/checkout@v4
445+
446+
# - name: Install video dependency
447+
# run: |
448+
# sudo apt-get update
449+
# sudo apt-get -y install libmpv-dev mpv
450+
# shell: bash
451+
452+
# - name: Flutter Integration Test 3
453+
# uses: ./.github/actions/flutter_integration_test
454+
# with:
455+
# test_path: integration_test/desktop_runner_3.dart
456+
# flutter_version: ${{ env.FLUTTER_VERSION }}
457+
# rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
458+
# cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
459+
# rust_target: ${{ matrix.target }}

0 commit comments

Comments
 (0)