Skip to content

Commit 5a393fe

Browse files
Merge pull request #125 from martijn00/ci
Improve CI workflow and speed
2 parents da39169 + 91a6c45 commit 5a393fe

File tree

1 file changed

+73
-23
lines changed

1 file changed

+73
-23
lines changed

.github/workflows/base.yaml

Lines changed: 73 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Base
1+
name: CI & CD
22

33
on:
44
workflow_dispatch:
5-
5+
66
push:
77
branches: [main]
88
tags:
9-
- '[0-9]+.[0-9]+.[0-9]+*'
9+
- "[0-9]+.[0-9]+.[0-9]+*"
1010

1111
pull_request:
1212
branches: [main]
@@ -18,10 +18,14 @@ concurrency:
1818

1919
jobs:
2020
build:
21+
name: Build package & run tests
2122
runs-on: ubuntu-latest
2223

2324
steps:
24-
- uses: actions/checkout@v4
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 1 # Use shallow clone for faster checkout
2529

2630
- name: Check broken links
2731
uses: JustinBeckwith/linkinator-action@v1
@@ -32,13 +36,15 @@ jobs:
3236
uses: kuhnroyal/flutter-fvm-config-action@v2
3337
id: fvm-config-action
3438
with:
35-
path: '.fvmrc'
36-
flavor: 'stable'
39+
path: ".fvmrc"
40+
flavor: "stable"
3741

38-
- uses: subosito/flutter-action@v2
42+
- name: Set up Flutter
43+
uses: subosito/flutter-action@v2
3944
with:
4045
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
4146
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
47+
architecture: x64
4248
cache: true
4349

4450
- name: Install dependencies
@@ -48,9 +54,8 @@ jobs:
4854
run: flutter gen-l10n
4955

5056
- name: Run l10n on example
51-
run: |
52-
cd example
53-
flutter gen-l10n
57+
run: flutter gen-l10n
58+
working-directory: example
5459

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

6166
- name: Run tests
62-
run: flutter test --coverage
67+
run: flutter test --no-pub --coverage
6368

6469
- name: Check publish warnings
6570
run: dart pub publish --dry-run
6671

67-
- name: Build example
68-
run: |
69-
cd example
70-
flutter build appbundle --debug
71-
7272
- name: Upload coverage to Codecov
7373
uses: codecov/codecov-action@v4
7474
env:
@@ -78,23 +78,74 @@ jobs:
7878
flags: unittests
7979
name: form_builder_validators
8080

81+
example:
82+
name: Build example app
83+
runs-on: ubuntu-latest
84+
85+
steps:
86+
- name: Checkout repository
87+
uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 1 # Use shallow clone for faster checkout
90+
91+
- name: Get Flutter version by FVM
92+
uses: kuhnroyal/flutter-fvm-config-action@v2
93+
id: fvm-config-action
94+
with:
95+
path: ".fvmrc"
96+
flavor: "stable"
97+
98+
- name: Set up Flutter
99+
uses: subosito/flutter-action@v2
100+
with:
101+
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
102+
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
103+
architecture: x64
104+
cache: true
105+
106+
- name: Install dependencies
107+
run: dart pub get
108+
109+
- name: Run l10n
110+
run: flutter gen-l10n
111+
112+
- name: Run l10n on example
113+
run: flutter gen-l10n
114+
working-directory: example
115+
116+
- name: Build example
117+
run: flutter build appbundle --debug
118+
working-directory: example
119+
81120
deployment:
82121
if: ${{ github.ref_type == 'tag' }}
83-
needs: build
122+
needs: [build, example]
84123
name: Deploy package
85124
permissions:
86125
id-token: write
87126
runs-on: ubuntu-latest
88127
steps:
89-
- uses: actions/checkout@v4
128+
- name: Checkout repository
129+
uses: actions/checkout@v4
130+
with:
131+
fetch-depth: 1 # Use shallow clone for faster checkout
132+
133+
- name: Set up Dart
134+
uses: dart-lang/setup-dart@v1
90135

91-
- uses: dart-lang/setup-dart@v1
136+
- name: Get Flutter version by FVM
137+
uses: kuhnroyal/flutter-fvm-config-action@v2
138+
id: fvm-config-action
139+
with:
140+
path: ".fvmrc"
141+
flavor: "stable"
92142

93-
- name: Flutter action
143+
- name: Set up Flutter
94144
uses: subosito/flutter-action@v2
95145
with:
96-
channel: 'stable'
97-
# use the build-in cache from Subosito
146+
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
147+
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
148+
architecture: x64
98149
cache: true
99150

100151
- name: Install dependencies
@@ -105,4 +156,3 @@ jobs:
105156

106157
- name: Publish package
107158
run: dart pub publish -v -f
108-

0 commit comments

Comments
 (0)