GitHub Actions #3833
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: GitHub Actions | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * SUN" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Get project Flutter version 🏷️ | |
id: fvm-config | |
uses: kuhnroyal/flutter-fvm-config-action@v1.2.0 | |
- name: Setup Flutter 💻 | |
uses: subosito/flutter-action@v2.16.0 | |
id: setup-flutter | |
with: | |
flutter-version: ${{ steps.fvm-config.outputs.FLUTTER_VERSION }} | |
cache: true | |
cache-key: ${{ runner.os }}-flutter-${{ steps.fvm-config.outputs.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} | |
- name: Cache Pub 💾 | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/.dart_tool | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pub- | |
- name: Run tests 🧪 | |
run: | | |
flutter pub get | |
flutter pub run build_runner build --delete-conflicting-outputs | |
flutter test --coverage --concurrency=12 | |
flutter pub run remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$' -r 'extensions\.dart' | |
- name: Upload coverage report 📡 | |
uses: codecov/codecov-action@v5.0.2 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
files: ./coverage/lcov.info | |
flags: appainter | |
integration-test: | |
name: Integration test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
type: | |
- macos | |
- windows | |
- linux | |
# Disabled because forever hanging on GitHub Actions | |
# - web | |
include: | |
- type: macos | |
os: macos-latest | |
- type: windows | |
os: windows-latest | |
- type: linux | |
os: ubuntu-latest | |
# Disabled because forever hanging on GitHub Actions | |
# - type: web | |
# os: macos-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Get project Flutter version 🏷️ | |
id: fvm-config | |
uses: kuhnroyal/flutter-fvm-config-action@v1.2.0 | |
- name: Setup Flutter 💻 | |
uses: subosito/flutter-action@v2.16.0 | |
id: setup-flutter | |
with: | |
flutter-version: ${{ steps.fvm-config.outputs.FLUTTER_VERSION }} | |
cache: true | |
cache-key: ${{ runner.os }}-flutter-${{ steps.fvm-config.outputs.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} | |
- name: Setup ChromeDriver 🚘 | |
uses: nanasess/setup-chromedriver@v2.2.2 | |
if: ${{ matrix.type == 'web' }} | |
- name: Cache Pub 💾 | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/.pub-cache | |
**/.dart_tool | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pub- | |
- name: Patch for Linux build 🩹 | |
if: ${{ matrix.type == 'linux' }} | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y ninja-build libgtk-3-dev | |
- name: Write Google service info file for MacOS 📝 | |
if: ${{ matrix.type == 'macos' }} | |
run: printf "${{ secrets.GOOGLE_SERVICE_INFO_MACOS }}" > macos/Runner/GoogleService-Info.plist | |
- name: Run tests 🧪 | |
shell: bash | |
run: | | |
flutter pub get | |
flutter pub run build_runner build --delete-conflicting-outputs | |
flutter build ${{ matrix.type }} --no-tree-shake-icons --target=integration_test/app_test.dart | |
if [ "${{ matrix.type }}" == "linux" ]; then | |
xvfb-run flutter test integration_test -d ${{ matrix.type }} | |
elif [ "${{ matrix.type }}" == "web" ]; then | |
export DISPLAY=:99 | |
chromedriver --port=4444 & | |
flutter drive \ | |
--driver=test_driver/integration_test.dart \ | |
--target=integration_test/app_test.dart \ | |
-d web-server | |
else | |
flutter test integration_test -d ${{ matrix.type }} | |
fi | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Get project Flutter version 🏷️ | |
id: fvm-config | |
uses: kuhnroyal/flutter-fvm-config-action@v1.2.0 | |
- name: Setup Flutter 💻 | |
uses: subosito/flutter-action@v2.16.0 | |
with: | |
flutter-version: ${{ steps.fvm-config.outputs.FLUTTER_VERSION }} | |
cache: true | |
cache-key: ${{ runner.os }}-flutter-${{ steps.fvm-config.outputs.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} | |
- name: Cache Pub 💾 | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/.dart_tool | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pub- | |
- name: Run linting 🧪 | |
run: | | |
flutter pub get | |
flutter pub run build_runner build --delete-conflicting-outputs | |
dart format --output=none --set-exit-if-changed . | |
flutter analyze | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
needs: [test, integration-test, lint] | |
if: ${{ (github.ref == 'refs/heads/main') && (contains(fromJSON('["workflow_dispatch", "schedule"]'), github.event_name)) }} | |
strategy: | |
matrix: | |
type: [web, macos, windows, linux] | |
include: | |
- type: web | |
os: ubuntu-latest | |
build-path: build | |
build-output: web | |
- type: macos | |
os: macos-latest | |
build-path: build/macos/Build/Products/Release | |
build-output: appainter.app | |
- type: windows | |
os: windows-latest | |
build-path: build\windows\x64\runner | |
build-output: Release | |
- type: linux | |
os: ubuntu-latest | |
build-path: build/linux/x64/release | |
build-output: bundle | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Get project Flutter version 🏷️ | |
id: fvm-config | |
uses: kuhnroyal/flutter-fvm-config-action@v1.2.0 | |
- name: Setup Flutter 💻 | |
id: setup-flutter | |
uses: subosito/flutter-action@v2.16.0 | |
with: | |
flutter-version: ${{ steps.fvm-config.outputs.FLUTTER_VERSION }} | |
cache: true | |
cache-key: ${{ runner.os }}-flutter-${{ steps.fvm-config.outputs.FLUTTER_CHANNEL }} | |
- name: Cache Pub 💾 | |
uses: actions/cache@v4 | |
with: | |
path: | | |
**/.dart_tool | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pub- | |
- name: Setup Node 💻 | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: yarn | |
- name: Patch for Linux build 🩹 | |
if: ${{ matrix.type == 'linux' }} | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y ninja-build libgtk-3-dev | |
- name: Write Google service info file for MacOS 📝 | |
if: ${{ matrix.type == 'macos' }} | |
run: printf "${{ secrets.GOOGLE_SERVICE_INFO_MACOS }}" > macos/Runner/GoogleService-Info.plist | |
- name: Install dependencies 📦 | |
run: yarn | |
- name: Build artifacts 🏗️ | |
shell: bash | |
run: npx semantic-release --extends ./build.release.config.js | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
APP_TYPE: ${{ matrix.type }} | |
BUILD_PATH: ${{ matrix.build-path }} | |
BUILD_OUTPUT: ${{ matrix.build-output }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
- name: Upload artifacts ⬆️ | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-${{ matrix.type }} | |
path: "**/appainter_${{ matrix.type }}.tar.gz" | |
if-no-files-found: error | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Download artifacts ⬇️ | |
id: download-artifacts | |
uses: actions/download-artifact@v4 | |
- name: Decompress web artifacts 📂 | |
env: | |
WEB_OUTPUT: build | |
run: | | |
mkdir -p ${{ env.WEB_OUTPUT }} | |
tar -zxf ${{ steps.download-artifacts.outputs.download-path }}/artifact-web/build/appainter_web.tar.gz -C ${{ env.WEB_OUTPUT }} | |
- name: Setup Node 💻 | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: yarn | |
- name: Install dependencies 📦 | |
run: yarn | |
- name: Release 🚀 | |
run: npx semantic-release --extends ./publish.release.config.js | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} |