Build and test package #87
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and test package | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
# runs the CI everyday at 6AM | |
- cron: "0 6 * * *" | |
jobs: | |
semantic_pull_request: | |
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1 | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
# Setup | |
- uses: actions/checkout@v3 | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.10.4' | |
channel: 'stable' | |
cache: true | |
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} | |
- uses: bluefireteam/melos-action@v2 | |
# Dart/Flutter format checking | |
- name: Clean before check-format | |
run: melos clean | |
- name: Boostrap everything | |
run: melos bs | |
- name: Check Dart format | |
run: melos run check-format --no-select | |
# JS bundle | |
- name: Generate JS bundle | |
run: melos generate-js | |
# Dart/Flutter | |
- name: Generate dart code | |
run: melos codegen --no-select | |
- name: Dart code analysis | |
run: melos run analyze --no-select | |
- name: Run Dart tests | |
run: melos run test --no-select | |
# Check if all the generated code is up to date | |
- name: Check git diff | |
run: melos git-check | |
# ios_integration_test: | |
# runs-on: macos-latest | |
# timeout-minutes: 360 | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - uses: subosito/flutter-action@v2 | |
# with: | |
# flutter-version: '3.10.4' | |
# channel: 'stable' | |
# cache: true | |
# cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} | |
# - uses: bluefireteam/melos-action@v2 | |
# - name: Start iOS Simulator | |
# run: | | |
# DEVICE_ID=$(xcrun xctrace list devices | grep iPhone | head -1 | awk '{print $NF}' | tr -d '()') | |
# echo "DEVICE_ID=$DEVICE_ID" >> $GITHUB_ENV | |
# xcrun simctl boot $DEVICE_ID | |
# - name: Run Flutter integration tests | |
# working-directory: ./example | |
# run: flutter test --flavor production -d ${{ env.DEVICE_ID }} integration_test | |
android_integration_test: | |
runs-on: macos-latest | |
timeout-minutes: 360 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.10.4' | |
channel: 'stable' | |
cache: true | |
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} | |
- uses: bluefireteam/melos-action@v2 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: zulu | |
java-version: "11.x" | |
- name: Gradle cache | |
uses: gradle/gradle-build-action@v2 | |
- name: AVD cache | |
uses: actions/cache@v3 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-33 | |
- name: create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: 33 | |
target: google_apis | |
arch: x86_64 | |
ram-size: 1024M | |
disk-size: 2048M | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
script: echo "Generated AVD snapshot for caching." | |
- name: Run Flutter integration tests | |
uses: Wandalen/wretry.action@v1.3.0 # sometimes android tests are flaky | |
with: | |
attempt_limit: 5 | |
action: reactivecircus/android-emulator-runner@v2 | |
with: | | |
api-level: 33 | |
target: google_apis | |
arch: x86_64 | |
ram-size: 1024M | |
disk-size: 2048M | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
working-directory: ./example | |
script: flutter test --flavor production -d `flutter devices | grep android | tr ' ' '\n' | grep emulator-` integration_test |