Skip to content

Commit 94a630b

Browse files
committed
Added improvements to the Github workflow.
1 parent 9738157 commit 94a630b

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ name: CI
22

33
on:
44
pull_request:
5-
paths-ignore:
6-
- '**.md'
7-
push:
8-
branches:
9-
- master
5+
types: [opened, synchronize, reopened]
106
paths-ignore:
117
- '**.md'
128
workflow_dispatch:
@@ -15,24 +11,56 @@ concurrency:
1511
group: ${{ github.workflow }}-${{ github.ref }}
1612
cancel-in-progress: true
1713

14+
env:
15+
# Define global environment variables for the workflow
16+
# The version of Flutter to use should use the minimum Dart SDK version supported by the package,
17+
# refer to https://docs.flutter.dev/development/tools/sdk/releases.
18+
# Note: The version below should be manually updated to the latest second most recent version
19+
# after a new stable version comes out.
20+
# Current minimum is set to Flutter 3.29. Make this the new minimum once the next
21+
# stable version is released
22+
FLUTTER_VERSION_MINIMUM_DEFAULT: "3.29.3"
23+
FLUTTER_VERSION_LATEST_STABLE_CHANNEL_DEFAULT: "3.x"
24+
1825
jobs:
26+
setup_matrix:
27+
name: Determine Flutter Test Versions # Name for the setup_matrix job
28+
runs-on: ubuntu-latest
29+
outputs:
30+
flutter_versions_json: ${{ steps.set_versions.outputs.versions_json }}
31+
flutter_version_minimum: ${{ steps.set_versions.outputs.version_min }}
32+
steps:
33+
- name: Determine Flutter versions
34+
id: set_versions
35+
run: |
36+
MIN_VERSION_VALUE="${{ env.FLUTTER_VERSION_MINIMUM_DEFAULT }}"
37+
LATEST_VERSION_VALUE="${{ env.FLUTTER_VERSION_LATEST_STABLE_CHANNEL_DEFAULT }}"
38+
39+
echo "version_min=$MIN_VERSION_VALUE" >> $GITHUB_OUTPUT
40+
echo "version_latest=$LATEST_VERSION_VALUE" >> $GITHUB_OUTPUT
41+
42+
VERSIONS_JSON=$(jq -c --null-input '$ARGS.positional' --args "$MIN_VERSION_VALUE" "$LATEST_VERSION_VALUE")
43+
echo "versions_json=$VERSIONS_JSON" >> $GITHUB_OUTPUT
44+
45+
echo "Determined Min Version: $MIN_VERSION_VALUE"
46+
echo "Determined Latest Version: $LATEST_VERSION_VALUE"
47+
echo "Determined JSON: $VERSIONS_JSON"
48+
1949
# Does a sanity check that packages at least pass analysis on the N-1
2050
# versions of Flutter stable if the package claims to support that version.
2151
# This is to minimize accidentally making changes that break old versions
2252
# (which we don't commit to supporting, but don't want to actively break)
2353
# without updating the constraints.
2454
lint_and_build:
2555
name: Flutter Version ${{ matrix.flutter-version }} Lint and Build.
56+
needs: setup_matrix # Ensures this job runs after setup_matrix completes
2657
runs-on: ubuntu-latest
58+
env:
59+
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
60+
FLUTTER_VERSION_MINIMUM: ${{ needs.setup_matrix.outputs.flutter_version_minimum }}
2761
strategy:
2862
matrix:
29-
flutter-version:
30-
# The version of Flutter to use should use the minimum Dart SDK version supported by the package,
31-
# refer to https://docs.flutter.dev/development/tools/sdk/releases.
32-
# Note: The version below should be manually updated to the latest second most recent version
33-
# after a new stable version comes out.
34-
- "3.29.3"
35-
- "3.x"
63+
flutter-version: ${{ fromJSON(needs.setup_matrix.outputs.flutter_versions_json) }}
3664
fail-fast: false
3765
steps:
3866
- name: 📚 Git Checkout
@@ -51,6 +79,10 @@ jobs:
5179

5280
- name: ✨ Check Formatting
5381
run: dart format --set-exit-if-changed lib
82+
# Only continue on error if this is the job for the MINIMUM Flutter version
83+
# This allows formatting issues to be warnings on older supported versions
84+
# but enforces them on the latest stable or primary development version.
85+
continue-on-error: ${{ matrix.flutter-version == env.FLUTTER_VERSION_MINIMUM }}
5486

5587
- name: 🕵️ Analyze
5688
run: flutter analyze lib

0 commit comments

Comments
 (0)