-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
149 lines (140 loc) · 5.62 KB
/
.gitlab-ci.yml
File metadata and controls
149 lines (140 loc) · 5.62 KB
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
stages:
- code-analysis
- test
- test-coverage
variables:
# Test latest available and lowest supported SDK (see dev-doc/updating-dart-flutter-and-dependencies.md).
# # Pick a concrete version instead of "latest" to avoid builds breaking due to changes in new
# SDKs.
# For available versions see https://hub.docker.com/_/dart/tags and https://dart.dev/get-dart/archive
DART_VERSION_LATEST: '3.10.4'
DART_VERSION_LOWEST: '3.7.3' # Use latest bugfix release to get tooling fixes
DART_VERSION: $DART_VERSION_LATEST # Also used for caching, see .cache template
.common:
image: dart:$DART_VERSION # Official Dart Docker image https://hub.docker.com/_/dart
tags: [ x64, linux, docker ] # Jobs use shell commands and scripts, so only run on Linux
# Make PUB_CACHE cacheable in GitLab;
# see also https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77791/diffs and
# https://dikman.medium.com/optimising-flutter-ci-by-caching-packages-8a1d537e0b23
# Requires extending job to set DART_VERSION variable.
.cache:
extends: .common
before_script:
- export PUB_CACHE="$CI_PROJECT_DIR/.pub-cache" # https://dart.dev/tools/pub/environment-variables
- export PATH="$PATH":"$PUB_CACHE/bin"
cache:
paths:
- $CI_PROJECT_DIR/.pub-cache/bin/
- $CI_PROJECT_DIR/.pub-cache/global_packages/
- $CI_PROJECT_DIR/.pub-cache/hosted/
key: "linux-x64-dart-$DART_VERSION-pub-cache"
# Analyze (only) Dart packages, check formatting in Dart and Flutter packages.
format-and-analyze:
extends: .cache
stage: code-analysis
script:
# Get dependencies
- dart pub get --directory=benchmark
- dart pub get --directory=generator
- dart pub get --directory=objectbox
- dart pub get --directory=objectbox_test
- dart pub get --directory=objectbox/example/dart-native/vectorsearch_cities
# Since Dart 3.7, dart format needs pub get to run before formatting,
# so can no longer check formatting of Flutter packages (would require Flutter SDK):
# Check formatting only for Dart packages (run before generating code to exclude generated code)
- dart format --set-exit-if-changed benchmark
- dart format --set-exit-if-changed generator
- dart format --set-exit-if-changed objectbox
- dart format --set-exit-if-changed objectbox_test
- dart format --set-exit-if-changed objectbox/example/dart-native
# Generate code
- cd benchmark
- dart run build_runner build
- cd ../objectbox_test
- dart run build_runner build
- cd ../objectbox/example/dart-native/vectorsearch_cities
- dart run build_runner build
- cd ../../../.. # back to repo root
# Analyze Dart packages
- dart analyze benchmark
- dart analyze generator
- dart analyze objectbox
- dart analyze objectbox_test
- dart analyze objectbox/example/dart-native/vectorsearch_cities
# Runs generator integration tests, e.g. ensures generator works as expected.
# Note: no need to test oldest SDK here, generator package is also built as part of unit-tests job.
generator-integ-tests:
extends: .cache
stage: test
script:
- ./install.sh --install # Install globally for generator integration tests
- ./generator/test.sh
# Runs generator and objectbox unit tests.
.unit-tests-template:
extends: .cache
stage: test
needs: ["generator-integ-tests"] # Wait for generator integration tests
script:
# Generator tests
- cd generator
- dart pub get
# generator test suites must not run in parallel (see notes on GeneratorTestEnv):
# Set concurrency=1 to run only one test suite (== test file) at a time.
# Set --reporter expanded to print log for every completed test.
- dart test --concurrency=1 --reporter expanded
# ObjectBox tests
- cd ../objectbox_test
# Use Sync-enabled library to at least partially run sync_test.dart
- ../install.sh --sync
- dart pub get
- dart run build_runner build
# Set concurrency=1 to run only one test suite (== test file) at a time.
# Set --reporter expanded to print log for every completed test.
# Together, this will produce sequential log output, making it easier to attribute native logs.
- dart test --concurrency=1 --reporter expanded
# Run again using in-memory database
- export OBX_IN_MEMORY=true
- dart test --concurrency=1 --reporter expanded
unit-tests:
extends: .unit-tests-template
parallel:
matrix:
- DART_VERSION: [ $DART_VERSION_LOWEST, $DART_VERSION_LATEST ]
# For the Dart Native example compiles and runs the executable (analysis and code formatting is
# checked by analyze job).
vectorsearch-example:
extends: .cache
stage: test
needs: ["generator-integ-tests"] # Wait for generator integration tests
script:
- cd objectbox/example/dart-native/vectorsearch_cities
- dart pub get
- dart run build_runner build
- ../../../../install.sh
- dart compile exe bin/vectorsearch_cities.dart
- ./bin/vectorsearch_cities.exe
# Runs tests with coverage on the objectbox package.
# Note: As this requires to run tests, make sure this does not block the actual test jobs so test
# issues can be seen.
test-coverage:
extends: .cache
stage: test-coverage
needs: ["unit-tests"] # Get test results first
script:
# Install coverage tools
- apt-get update
- apt-get install --yes --no-install-recommends lcov
- dart pub global activate coverage
# Prepare objectbox_test
- cd objectbox_test
- dart pub get
- dart run build_runner build
# Generate test coverage
- cd ../objectbox
- ../install.sh
- dart pub get
- ./tool/coverage.sh
coverage: /^\s*lines......:\s*\d+.\d+\%/
artifacts:
paths:
- objectbox/coverage/html/