ci: rework integration tests #43
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
# Heavily inspired by https://github.com/cfug/dio/blob/main/.github/workflows/tests.yml | |
name: Test and Code Coverage | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*.*.*' | |
paths-ignore: | |
- "**.md" | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- "**.md" | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash -leo pipefail {0} | |
jobs: | |
unit_tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
sdk: [ min, stable, beta ] | |
env: | |
TEST_PRESET: all | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
cache: true | |
channel: ${{ matrix.sdk == 'min' && 'stable' || matrix.sdk }} | |
flutter-version: ${{ matrix.sdk == 'min' && '3.22.0' || '' }} | |
- run: | | |
echo TARGET_DART_SDK=${{ matrix.sdk }} >> $GITHUB_ENV | |
# see https://github.com/invertase/melos/issues/796 | |
- uses: bluefireteam/melos-action@main | |
continue-on-error: true | |
with: | |
run-bootstrap: true | |
bootstrap-no-example: false | |
- uses: bluefireteam/melos-action@main | |
with: | |
run-bootstrap: true | |
bootstrap-no-example: true | |
- name: '[Verify step] ✨ Format' | |
if: ${{ matrix.sdk == 'stable' }} | |
run: melos run format | |
- name: '[Verify step] 🕵️ Analyze packages' | |
if: ${{ matrix.sdk == 'stable' }} | |
run: melos run analyze | |
# - name: '[Verify step] 🕵️ Run Pana' | |
# if: ${{ matrix.sdk == 'stable' }} | |
# run: | | |
# flutter pub global activate pana | |
# melos run pana | |
- name: '[Verify step] Test Dart packages [VM]' | |
run: melos run test:vm | |
- name: '[Verify step] Test Dart packages [Chrome]' | |
run: melos run test:web:chrome | |
- name: '[Verify step] Test Dart packages [Firefox]' | |
run: melos run test:web:firefox | |
- name: Remove dart_test.yaml Files | |
run: melos run remove_dart_test_yaml | |
- name: '[Verify step] Test Flutter packages' | |
run: melos run test:flutter | |
- name: '[Coverage] Format & print test coverage' | |
if: ${{ matrix.sdk == 'stable' }} | |
run: melos run coverage:combine | |
- name: Upload Unit Test Coverage Report | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.sdk == 'stable' }} | |
with: | |
name: unit-tests-coverage | |
path: coverage/lcov.info | |
# Upload | |
# - name: Report to Codecov | |
# uses: codecov/codecov-action@v4 | |
# if: ${{ matrix.sdk == 'stable' }} | |
# env: | |
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
# with: | |
# file: coverage/lcov.info | |
# fail_ci_if_error: false | |
# integration tests | |
android: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [29] | |
defaults: | |
run: | |
working-directory: packages/oidc/example | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
cache: true | |
channel: stable | |
flutter-version: 3.22.0 | |
# see https://github.com/invertase/melos/issues/796 | |
- uses: bluefireteam/melos-action@main | |
continue-on-error: true | |
with: | |
run-bootstrap: true | |
bootstrap-no-example: false | |
- uses: bluefireteam/melos-action@main | |
with: | |
run-bootstrap: true | |
bootstrap-no-example: true | |
- name: Remove dart_test.yaml Files | |
run: melos run remove_dart_test_yaml | |
- name: Enable KVM | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Gradle cache | |
uses: gradle/actions/setup-gradle@v3 | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }} | |
- 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: ${{ matrix.api-level }} | |
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 Android Emulator and Integration Tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
working-directory: packages/oidc/example | |
api-level: ${{ matrix.api-level }} | |
script: | | |
flutter test integration_test --coverage -d android --coverage-path android-coverage | |
ls android-coverage | |
- name: Upload Coverage Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: android-coverage | |
path: packages/oidc/example/android-coverage/lcov.info |