chore(pr): add integration tests #149
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: Dart Tests | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+*" | |
pull_request: | |
env: | |
api_level: 34 | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Flutter (use cache) | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
cache: true | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Prepare env file | |
run: cp .env.sample .env | |
- name: Run tests | |
run: | | |
dart run full_coverage | |
flutter test --coverage | |
- name: Upload coverage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: unit-test-coverage | |
path: coverage/lcov.info | |
integration-test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Flutter (use cache) | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
cache: true | |
- name: Cache Flutter dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.pub-cache | |
key: pub-cache-${{ runner.os }}-${{ hashFiles('pubspec.yaml', 'pubspec.lock') }} | |
restore-keys: | | |
pub-cache-${{ runner.os }}- | |
- name: Cache Flutter build outputs | |
uses: actions/cache@v4 | |
with: | |
path: build/ | |
key: flutter-build-${{ runner.os }}-${{ hashFiles('pubspec.yaml', 'pubspec.lock') }} | |
restore-keys: | | |
flutter-build-${{ runner.os }}- | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Prepare env file | |
run: cp .env.sample .env | |
- name: Install Android dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y lib32stdc++6 lib32z1 | |
- name: Setup Java 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
- 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: Setup Android SDK & Run integration tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ env.api_level }} | |
target: google_apis | |
arch: x86_64 | |
profile: pixel_6_pro | |
script: flutter test integration_test --coverage --coverage-path coverage/lcov-it.info | |
- name: Upload coverage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: integration-test-coverage | |
path: coverage/lcov-it.info | |
codecov: | |
needs: [test, integration-test] | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download unit test coverage artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: unit-test-coverage | |
path: coverage | |
- name: Download integration test coverage artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: integration-test-coverage | |
path: coverage | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage/lcov.info,coverage/lcov-it.info | |
sonar: | |
needs: [test, integration-test] | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Download unit test coverage artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: unit-test-coverage | |
path: coverage | |
- name: Download integration test coverage artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: integration-test-coverage | |
path: coverage | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
cache: true | |
- name: SonarQube Scan | |
uses: SonarSource/sonarqube-scan-action@v4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
prepare-release: | |
runs-on: ubuntu-latest | |
if: startsWith(github.head_ref, 'release-v') | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract version from branch | |
id: extract_version | |
run: | | |
branch_name="${{ github.head_ref }}" | |
version="${branch_name#release-v}" | |
echo "version=v$version" >> $GITHUB_ENV | |
- name: Generate changelog | |
uses: orhun/git-cliff-action@v4 | |
with: | |
config: cliff.toml | |
args: --tag ${{ env.version }} | |
env: | |
OUTPUT: CHANGELOG.md | |
GITHUB_REPO: ${{ github.repository }} | |
- name: Commit Changelog | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git checkout ${{ github.head_ref }} | |
git add CHANGELOG.md | |
git commit -m "Update CHANGELOG for version ${{ env.version }}" | |
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.head_ref }} | |
- name: Update version in pubspec.yaml | |
run: | | |
version_without_v=${{ env.version }} | |
version_without_v=${version_without_v#v} | |
sed -i "s/^version: .*/version: $version_without_v/" pubspec.yaml | |
git add pubspec.yaml | |
git commit -m "Update pubspec.yaml version to ${{ env.version }}" | |
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.head_ref || github.ref_name }} | |