Skip to content

Commit ece5539

Browse files
committed
👷 add minimum Dart SDK reading and compatibility checks to CI workflow
1 parent dfd64b0 commit ece5539

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ env:
2424
PUB_ENVIRONMENT: bot.github
2525

2626
jobs:
27+
minimum_dart_meta:
28+
name: "Read minimum Dart SDK"
29+
runs-on: ubuntu-latest
30+
outputs:
31+
min_dart: ${{ steps.read_min_dart.outputs.min_dart }}
32+
steps:
33+
- id: checkout
34+
name: Checkout repository
35+
uses: actions/checkout@v6
36+
- id: read_min_dart
37+
name: Read minimum Dart SDK from pubspec.yaml
38+
run: |
39+
set -euo pipefail
40+
min_dart="$(yq -r '.environment.sdk | capture("(?<min>[0-9]+\.[0-9]+\.[0-9]+)").min' pubspec.yaml)"
41+
if [[ -z "${min_dart}" ]]; then
42+
echo 'failed to read minimum Dart SDK from pubspec.yaml' >&2
43+
exit 1
44+
fi
45+
echo "min_dart=${min_dart}" >> "$GITHUB_OUTPUT"
2746
analyze:
2847
name: "Analyze"
2948
runs-on: ubuntu-latest
@@ -52,6 +71,46 @@ jobs:
5271
run: dart format lib test --output=none --set-exit-if-changed .
5372
- name: Analyze the project's Dart code
5473
run: dart analyze lib test --fatal-infos
74+
minimum_dart:
75+
name: "Minimum Dart (${{ needs.minimum_dart_meta.outputs.min_dart }}, ${{ matrix.platform }})"
76+
needs: minimum_dart_meta
77+
runs-on: ubuntu-latest
78+
strategy:
79+
fail-fast: false
80+
matrix:
81+
include:
82+
- platform: chrome
83+
- platform: vm
84+
steps:
85+
- name: Cache Pub hosted dependencies
86+
uses: actions/cache@v5
87+
with:
88+
path: "~/.pub-cache/hosted"
89+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:${{ needs.minimum_dart_meta.outputs.min_dart }};packages:qs_dart;commands:codegen-test"
90+
restore-keys: |
91+
os:ubuntu-latest;pub-cache-hosted;sdk:${{ needs.minimum_dart_meta.outputs.min_dart }};packages:qs_dart
92+
os:ubuntu-latest;pub-cache-hosted;sdk:${{ needs.minimum_dart_meta.outputs.min_dart }}
93+
os:ubuntu-latest;pub-cache-hosted
94+
os:ubuntu-latest
95+
- name: Setup Dart SDK
96+
uses: dart-lang/setup-dart@v1
97+
with:
98+
sdk: ${{ needs.minimum_dart_meta.outputs.min_dart }}
99+
- id: checkout
100+
name: Checkout repository
101+
uses: actions/checkout@v6
102+
- id: install
103+
name: Install dependencies
104+
run: dart pub get
105+
- name: Analyze the project's Dart code
106+
if: ${{ matrix.platform == 'vm' }}
107+
run: dart analyze lib test
108+
- name: Run the project's tests in Chrome
109+
if: ${{ matrix.platform == 'chrome' }}
110+
run: dart test --platform chrome
111+
- name: Run the project's tests on the VM
112+
if: ${{ matrix.platform == 'vm' }}
113+
run: dart test --platform vm
55114
test:
56115
name: "Test"
57116
needs: analyze
@@ -168,11 +227,13 @@ jobs:
168227
if: ${{ always() }}
169228
needs:
170229
- analyze
230+
- minimum_dart
171231
- test
172232
- ensure_compatibility
173233
runs-on: ubuntu-latest
174234
env:
175235
ANALYZE_RESULT: ${{ needs.analyze.result }}
236+
MINIMUM_DART_RESULT: ${{ needs.minimum_dart.result }}
176237
TEST_RESULT: ${{ needs.test.result }}
177238
ENSURE_COMPATIBILITY_RESULT: ${{ needs.ensure_compatibility.result }}
178239
steps:
@@ -182,6 +243,7 @@ jobs:
182243
183244
results=(
184245
"analyze:${ANALYZE_RESULT}"
246+
"minimum_dart:${MINIMUM_DART_RESULT}"
185247
"test:${TEST_RESULT}"
186248
"ensure_compatibility:${ENSURE_COMPATIBILITY_RESULT}"
187249
)

0 commit comments

Comments
 (0)