-
Notifications
You must be signed in to change notification settings - Fork 120
/
.gitlab-ci.yml
141 lines (133 loc) · 4.74 KB
/
.gitlab-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
stages:
- analyze
- test
variables:
# Note: use specific tags as docker images may not always be pulled due to "if-not-present" pull policy.
# Thus, do not use tags like latest/beta, but check https://hub.docker.com/_/dart?tab=tags for latest.
DART_VERSION: '3.5.2'
# 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:
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.
analyze:
extends: .cache
stage: analyze
tags: [ x64, linux, docker ]
image: dart:$DART_VERSION
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
# 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
# Check formatting of all packages
- dart format --set-exit-if-changed --fix .
# Runs generator integration tests, e.g. ensures generator works as expected.
test-generator:linux:x64:
extends: .cache
stage: test
tags: [ x64, linux, docker ]
image: dart:$DART_VERSION
script:
- ./install.sh --install # Install globally for generator integration tests
- ./generator/test.sh
# Runs generator and objectbox unit tests.
.test:
extends: .cache
stage: test
script:
# Generator tests
- cd generator
- dart pub get
- dart test
# ObjectBox tests
- cd ../objectbox_test
- ../install.sh
- 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
test-lib:linux:x64:
extends: .test
tags: [ x64, linux, docker ]
image: dart:$DART_VERSION
needs: ["test-generator:linux:x64"] # Wait for generator test
parallel:
matrix:
# Note: use specific versions instead of latest/beta tags as Docker images may not always be
# pulled due to "if-not-present" pull policy. Check https://hub.docker.com/_/dart?tab=tags.
# Always include lowest supported version (see sdk key in objectbox and generator
# pubspec.yaml, but may be higher due to dependencies).
- DART_VERSION: [ '2.18.6', '3.4.4', '3.5.2' ]
# 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.
coverage:
extends: .cache
stage: test
needs: ["test-lib:linux:x64"] # Get test results first
tags: [ x64, linux, docker ]
image: dart:$DART_VERSION
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/
# For the Dart Native example compiles and runs the executable (analysis and code formatting is
# checked by analyze job).
dart-examples-test:
extends: .cache
stage: test
tags: [ x64, linux, docker ]
image: dart:$DART_VERSION
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