-
Notifications
You must be signed in to change notification settings - Fork 58
212 lines (180 loc) · 7.07 KB
/
dart_ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Dart CI
on:
push:
branches:
- 'master'
- 'test_consume_**'
tags:
- "**"
pull_request:
branches:
- '**'
permissions:
contents: write
id-token: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [ 2.19.6, 3.4.4, main ]
steps:
- uses: actions/checkout@v4
- id: setup-dart
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.sdk }}
- name: Print Dart SDK version
run: dart --version
- name: Delete Dart-2-only files when running on Dart 3
run: |
DART_VERSION="${{ steps.setup-dart.outputs.dart-version }}"
if [[ "$DART_VERSION" =~ ^3 ]]; then
./tool/delete_dart_2_only_files.sh
fi
- id: install
name: Install dependencies
run: dart pub get
- name: Validate dependencies
run: dart run dependency_validator
if: always() && steps.install.outcome == 'success'
- name: Verify formatting
run: dart run dart_dev format --check
# Only run on one sdk version in case there are conflicts
if: always() && matrix.sdk == '2.19.6' && steps.install.outcome == 'success'
# Analyze before generated files are created to verify that component boilerplate analysis is "clean" without the need for building
- name: Analyze example source (pre-build)
run: |
# Analyze lib to ensure public APIs don't depend on build-to-cache files,
# which could cause analysis issues for consumers who haven't run a build yet.
dart analyze lib
dart analyze example/boilerplate_versions
if: always() && steps.install.outcome == 'success'
- id: build
timeout-minutes: 6
name: Build generated files / precompile DDC assets
run: |
dart run build_runner build --delete-conflicting-outputs -o ddc_precompiled
if: always() && steps.install.outcome == 'success'
- name: Verify that generated files are up-to-date
run: |
if [ ${{ matrix.sdk }} = '2.19.6' ]; then
git diff --exit-code
else
# Don't check these generated files for other SDKs, since they may generate differently
# due to different resolved dependencies.
git diff --exit-code -- ":(exclude)test/over_react/component_declaration/redux_component_test/test_reducer.g.dart"
fi
if: always() && steps.install.outcome == 'success' && steps.install.build == 'success'
# Analyze again after generated files are created to verify that those generated classes don't cause analysis errors
- name: Analyze project source (post-build)
run: dart analyze
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'
- name: Run tests (VM)
# Can't use build_runner (which dart_dev uses if you depend on it) to run VM tests, since we get the error:
# Unable to spawn isolate: /…/build_runner_testRU6M77/.packages: Error: Problem in packages configuration file: Unexpected character
run: |
DART_VERSION="${{ steps.setup-dart.outputs.dart-version }}"
TEST_ARGS=""
if [[ "$DART_VERSION" =~ ^3 ]]; then
TEST_ARGS="--preset=no-dart-2"
fi
dart test --preset vm $TEST_ARGS
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'
- name: Run tests (DDC)
run: dart test --precompiled ddc_precompiled -P dartdevc
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'
- name: Run tests (dart2js)
run: dart run dart_dev test --build-args="-r" -P dart2js
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'
- uses: anchore/sbom-action@v0
with:
path: ./
format: cyclonedx-json
validate_analyzer:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [ 2.19.6, 3.4.4, main ]
analyzer:
# We only have one version currently, but we'll leave this CI step in place
# for the next time we need to support multiple analyzer versions.
- ^5.1.0
steps:
- uses: actions/checkout@v4
- id: setup-dart
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.sdk }}
- name: Print Dart SDK version
run: dart --version
- name: Delete Dart-2-only files when running on Dart 3
run: |
DART_VERSION="${{ steps.setup-dart.outputs.dart-version }}"
if [[ "$DART_VERSION" =~ ^3 ]]; then
./tool/delete_dart_2_only_files.sh
fi
- name: Update analyzer constraint to ${{ matrix.analyzer }} and validate `dart pub get` can resolve
id: resolve
run: |
dart tool/set_analyzer_constraint.dart "${{ matrix.analyzer }}"
# Show the updated version constraint
git diff pubspec.yaml
dart pub get
- name: Analyze package source
run: dart analyze .
- name: Verify builder runs without errors
run: dart run build_runner build --build-filter='**.dart' --delete-conflicting-outputs
- name: Run builder tests
run: |
DART_VERSION="${{ steps.setup-dart.outputs.dart-version }}"
TEST_ARGS=""
if [[ "$DART_VERSION" =~ ^3 ]]; then
TEST_ARGS="--preset=no-dart-2"
fi
dart test --preset vm $TEST_ARGS -- test/vm_tests/builder
analyzer_plugin:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tools/analyzer_plugin
strategy:
fail-fast: false
matrix:
sdk: [ 2.19.6, 3.4.4, main ]
steps:
- uses: actions/checkout@v4
- id: setup-dart
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.sdk }}
- name: Print Dart SDK version
run: dart --version
- name: Delete Dart-2-only files when running on Dart 3
run: |
DART_VERSION="${{ steps.setup-dart.outputs.dart-version }}"
if [[ "$DART_VERSION" =~ ^3 ]]; then
(cd ../.. && ./tool/delete_dart_2_only_files.sh)
fi
- id: link
name: Override over_react dependency with local path
run: cd ../.. && dart pub get && dart tool/travis_link_plugin_deps.dart
- id: install
name: Install dependencies
run: dart pub get
if: always() && steps.link.outcome == 'success'
- name: Validate dependencies
run: dart run dependency_validator
if: always() && steps.install.outcome == 'success'
- name: Analyze
run: dart run dart_dev analyze
if: always() && steps.install.outcome == 'success'
- name: Verify formatting
run: dart run dart_dev format --check
if: always() && matrix.sdk == '2.7.2' && steps.install.outcome == 'success'
- name: Run tests
run: dart run dart_dev test
if: always() && steps.install.outcome == 'success'