Skip to content

Commit

Permalink
Merge pull request #125 from martijn00/ci
Browse files Browse the repository at this point in the history
Improve CI workflow and speed
  • Loading branch information
deandreamatias authored Jul 30, 2024
2 parents da39169 + 91a6c45 commit 5a393fe
Showing 1 changed file with 73 additions and 23 deletions.
96 changes: 73 additions & 23 deletions .github/workflows/base.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Base
name: CI & CD

on:
workflow_dispatch:

push:
branches: [main]
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
- "[0-9]+.[0-9]+.[0-9]+*"

pull_request:
branches: [main]
Expand All @@ -18,10 +18,14 @@ concurrency:

jobs:
build:
name: Build package & run tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Use shallow clone for faster checkout

- name: Check broken links
uses: JustinBeckwith/linkinator-action@v1
Expand All @@ -32,13 +36,15 @@ jobs:
uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
with:
path: '.fvmrc'
flavor: 'stable'
path: ".fvmrc"
flavor: "stable"

- uses: subosito/flutter-action@v2
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
architecture: x64
cache: true

- name: Install dependencies
Expand All @@ -48,9 +54,8 @@ jobs:
run: flutter gen-l10n

- name: Run l10n on example
run: |
cd example
flutter gen-l10n
run: flutter gen-l10n
working-directory: example

- name: Format code
run: dart format --set-exit-if-changed $(find . -name "*.dart" ! \( -wholename "./lib/localization/intl/*" -or -wholename "./example/lib/localization/intl/*" \))
Expand All @@ -59,16 +64,11 @@ jobs:
run: dart analyze

- name: Run tests
run: flutter test --coverage
run: flutter test --no-pub --coverage

- name: Check publish warnings
run: dart pub publish --dry-run

- name: Build example
run: |
cd example
flutter build appbundle --debug
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
Expand All @@ -78,23 +78,74 @@ jobs:
flags: unittests
name: form_builder_validators

example:
name: Build example app
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Use shallow clone for faster checkout

- name: Get Flutter version by FVM
uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
with:
path: ".fvmrc"
flavor: "stable"

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
architecture: x64
cache: true

- name: Install dependencies
run: dart pub get

- name: Run l10n
run: flutter gen-l10n

- name: Run l10n on example
run: flutter gen-l10n
working-directory: example

- name: Build example
run: flutter build appbundle --debug
working-directory: example

deployment:
if: ${{ github.ref_type == 'tag' }}
needs: build
needs: [build, example]
name: Deploy package
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Use shallow clone for faster checkout

- name: Set up Dart
uses: dart-lang/setup-dart@v1

- uses: dart-lang/setup-dart@v1
- name: Get Flutter version by FVM
uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
with:
path: ".fvmrc"
flavor: "stable"

- name: Flutter action
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
# use the build-in cache from Subosito
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
architecture: x64
cache: true

- name: Install dependencies
Expand All @@ -105,4 +156,3 @@ jobs:

- name: Publish package
run: dart pub publish -v -f

0 comments on commit 5a393fe

Please sign in to comment.