chore(pr): add integration tests #134
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: | |
jobs: | |
setup-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
cache: true | |
# optional parameters follow | |
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache | |
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" # optional, change this to specify the cache path | |
pub-cache-key: "flutter-pub:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache of dart pub get dependencies | |
pub-cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" # optional, change this to specify the cache path | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Prepare env file | |
run: cp .env.sample .env | |
test: | |
needs: setup-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: Prepare env file | |
run: cp .env.sample .env | |
- name: Run tests | |
run: | | |
dart run full_coverage | |
flutter test --coverage | |
integration-test: | |
needs: setup-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: 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 Android SDK | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: 30 | |
target: google_apis | |
arch: x86_64 | |
script: flutter test integration_test --coverage --coverage-path coverage/lcov-it.info | |
# - name: Run integration tests | |
# run: flutter test integration_test --coverage --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: 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: 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 }} | |