11stages :
2- - analyze
2+ - code-analysis
33 - test
4+ - test-coverage
45
56variables :
6- # Note: use specific tags as docker images may not always be pulled due to "if-not-present" pull policy.
7- # Thus, do not use tags like latest/beta, but check https://hub.docker.com/_/dart?tab=tags for latest.
8- DART_VERSION : ' 3.5.2'
7+ # Test latest available and lowest supported SDK (see dev-doc/updating-dart-flutter-and-dependencies.md).
8+ # # Pick a concrete version instead of "latest" to avoid builds breaking due to changes in new
9+ # SDKs. For available versions see https://hub.docker.com/_/dart?tab=tags
10+ DART_VERSION_LATEST : ' 3.7.2'
11+ DART_VERSION_LOWEST : ' 2.18.6' # Use latest bugfix release to get tooling fixes
12+ DART_VERSION : $DART_VERSION_LATEST # Also used for caching, see .cache template
13+
14+ .common :
15+ image : dart:$DART_VERSION # Official Dart Docker image https://hub.docker.com/_/dart
16+ tags : [ x64, linux, docker ] # Jobs use shell commands and scripts, so only run on Linux
917
1018# Make PUB_CACHE cacheable in GitLab;
1119# see also https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77791/diffs and
1220# https://dikman.medium.com/optimising-flutter-ci-by-caching-packages-8a1d537e0b23
1321# Requires extending job to set DART_VERSION variable.
1422.cache :
23+ extends : .common
1524 before_script :
1625 - export PUB_CACHE="$CI_PROJECT_DIR/.pub-cache" # https://dart.dev/tools/pub/environment-variables
1726 - export PATH="$PATH":"$PUB_CACHE/bin"
@@ -23,11 +32,9 @@ variables:
2332 key : " linux-x64-dart-$DART_VERSION-pub-cache"
2433
2534# Analyze (only) Dart packages, check formatting in Dart and Flutter packages.
26- analyze :
35+ analyze-and-format :
2736 extends : .cache
28- stage : analyze
29- tags : [ x64, linux, docker ]
30- image : dart:$DART_VERSION
37+ stage : code-analysis
3138 script :
3239 # Get dependencies
3340 - dart pub get --directory=benchmark
@@ -49,23 +56,29 @@ analyze:
4956 - dart analyze objectbox
5057 - dart analyze objectbox_test
5158 - dart analyze objectbox/example/dart-native/vectorsearch_cities
52- # Check formatting of all packages
53- - dart format --set-exit-if-changed --fix .
59+ # Since Dart 3.7, dart format needs pub get to run before formatting,
60+ # so can no longer check formatting of Flutter packages (would require Flutter SDK):
61+ # Check formatting only for Dart packages
62+ - dart format --set-exit-if-changed benchmark
63+ - dart format --set-exit-if-changed generator
64+ - dart format --set-exit-if-changed objectbox
65+ - dart format --set-exit-if-changed objectbox_test
66+ - dart format --set-exit-if-changed objectbox/example/dart-native
5467
5568# Runs generator integration tests, e.g. ensures generator works as expected.
56- test-generator:linux:x64 :
69+ # Note: no need to test oldest SDK here, generator package is also built as part of unit-tests job.
70+ generator-integ-tests :
5771 extends : .cache
5872 stage : test
59- tags : [ x64, linux, docker ]
60- image : dart:$DART_VERSION
6173 script :
6274 - ./install.sh --install # Install globally for generator integration tests
6375 - ./generator/test.sh
6476
6577# Runs generator and objectbox unit tests.
66- .test :
78+ .unit-tests-template :
6779 extends : .cache
6880 stage : test
81+ needs : ["generator-integ-tests"] # Wait for generator integration tests
6982 script :
7083 # Generator tests
7184 - cd generator
@@ -84,28 +97,33 @@ test-generator:linux:x64:
8497 - export OBX_IN_MEMORY=true
8598 - dart test --concurrency=1 --reporter expanded
8699
87- test-lib:linux:x64 :
88- extends : .test
89- tags : [ x64, linux, docker ]
90- image : dart:$DART_VERSION
91- needs : ["test-generator:linux:x64"] # Wait for generator test
100+ unit-tests :
101+ extends : .unit-tests-template
92102 parallel :
93103 matrix :
94- # Note: use specific versions instead of latest/beta tags as Docker images may not always be
95- # pulled due to "if-not-present" pull policy. Check https://hub.docker.com/_/dart?tab=tags.
96- # Always include lowest supported version (see sdk key in objectbox and generator
97- # pubspec.yaml, but may be higher due to dependencies).
98- - DART_VERSION : [ '2.18.6', '3.4.4', '3.5.2' ]
104+ - DART_VERSION : [ $DART_VERSION_LOWEST, $DART_VERSION_LATEST ]
105+
106+ # For the Dart Native example compiles and runs the executable (analysis and code formatting is
107+ # checked by analyze job).
108+ vectorsearch-example :
109+ extends : .cache
110+ stage : test
111+ needs : ["generator-integ-tests"] # Wait for generator integration tests
112+ script :
113+ - cd objectbox/example/dart-native/vectorsearch_cities
114+ - dart pub get
115+ - dart run build_runner build
116+ - ../../../../install.sh
117+ - dart compile exe bin/vectorsearch_cities.dart
118+ - ./bin/vectorsearch_cities.exe
99119
100120# Runs tests with coverage on the objectbox package.
101121# Note: As this requires to run tests, make sure this does not block the actual test jobs so test
102122# issues can be seen.
103- coverage :
123+ test- coverage :
104124 extends : .cache
105- stage : test
106- needs : ["test-lib:linux:x64"] # Get test results first
107- tags : [ x64, linux, docker ]
108- image : dart:$DART_VERSION
125+ stage : test-coverage
126+ needs : ["unit-tests"] # Get test results first
109127 script :
110128 # Install coverage tools
111129 - apt-get update
@@ -124,18 +142,3 @@ coverage:
124142 artifacts :
125143 paths :
126144 - objectbox/coverage/html/
127-
128- # For the Dart Native example compiles and runs the executable (analysis and code formatting is
129- # checked by analyze job).
130- dart-examples-test :
131- extends : .cache
132- stage : test
133- tags : [ x64, linux, docker ]
134- image : dart:$DART_VERSION
135- script :
136- - cd objectbox/example/dart-native/vectorsearch_cities
137- - dart pub get
138- - dart run build_runner build
139- - ../../../../install.sh
140- - dart compile exe bin/vectorsearch_cities.dart
141- - ./bin/vectorsearch_cities.exe
0 commit comments