Skip to content

Commit 0c034b7

Browse files
authored
chore: enable integration tests (#122)
- Enable integration tests for Android - Add GitHub workflow for the `question` label - Update integration tests - Enable Codecov
1 parent c1d2b68 commit 0c034b7

File tree

5 files changed

+153
-56
lines changed

5 files changed

+153
-56
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
file_glob: "!**/*.g.*"
4949
fail_on_error: true
5050
# integration-test-ios:
51-
# name: "Integration Tests on iOS"
51+
# name: "[iOS] Integration tests"
5252
# runs-on: macOS-latest
5353
# defaults:
5454
# run:
@@ -63,47 +63,62 @@ jobs:
6363
# cache: true
6464
# - run: flutter pub get
6565
# - run: flutter test integration_test --no-pub -r expanded
66-
# integration-test-android:
67-
# name: "Integration Tests on Android"
68-
# runs-on: ubuntu-latest
69-
# strategy:
70-
# fail-fast: false
71-
# matrix:
72-
# api-level: [ 23 ] # TODO add 34
73-
# timeout-minutes: 30
74-
# defaults:
75-
# run:
76-
# working-directory: example
77-
# steps:
78-
# - uses: actions/checkout@v4
79-
# - name: Setup Flutter SDK
80-
# uses: subosito/flutter-action@v2
81-
# with:
82-
# cache: true
83-
# - uses: actions/setup-java@v4
84-
# with:
85-
# java-version: '17'
86-
# distribution: 'temurin'
87-
# cache: 'gradle'
88-
# - name: "Get Flutter dependencies"
89-
# run: flutter pub get
90-
# - name: Run integration tests
91-
# uses: reactivecircus/android-emulator-runner@v2
92-
# with:
93-
# api-level: ${{ matrix.api-level }}
94-
# arch: x86_64
95-
# emulator-boot-timeout: 1800 # 30 minutes
96-
# script: cd example && flutter test integration_test -r expanded --timeout=none
66+
integration-test-android:
67+
name: "[Android] Integration tests"
68+
runs-on: ubuntu-latest
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
api-level: [ 23, 34 ] # TODO: add 21
73+
timeout-minutes: 30
74+
defaults:
75+
run:
76+
working-directory: example
77+
steps:
78+
- uses: actions/checkout@v4
79+
- name: "Setup Flutter SDK"
80+
uses: subosito/flutter-action@v2
81+
with:
82+
cache: true
83+
- uses: actions/setup-java@v4
84+
with:
85+
java-version: '17'
86+
distribution: 'temurin'
87+
cache: 'gradle'
88+
- name: "Get Flutter dependencies"
89+
run: flutter pub get
90+
# https://github.com/marketplace/actions/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-runners
91+
- name: "Enable KVM group perms"
92+
run: |
93+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
94+
sudo udevadm control --reload-rules
95+
sudo udevadm trigger --name-match=kvm
96+
- name: "Run integration tests"
97+
uses: reactivecircus/android-emulator-runner@v2
98+
with:
99+
api-level: ${{ matrix.api-level }}
100+
arch: x86_64
101+
emulator-boot-timeout: 1800 # 30 minutes
102+
script: cd example && flutter test integration_test -r expanded --timeout=none --coverage --coverage-package maplibre
103+
- name: "Install coverde"
104+
run: dart pub global activate coverde
105+
- name: "Prepare coverage data"
106+
run: coverde value -i coverage/lcov.info > coverage/result.txt
107+
- name: "Run Codecov"
108+
uses: codecov/codecov-action@v4
109+
if: ${{ matrix.api-level == '34' }}
110+
env:
111+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
97112
# integration-test-web:
98-
# name: "Integration Tests on Web"
113+
# name: "[Web] Integration tests"
99114
# runs-on: ubuntu-latest
100115
# timeout-minutes: 30
101116
# defaults:
102117
# run:
103118
# working-directory: example
104119
# steps:
105120
# - uses: actions/checkout@v4
106-
# - name: Setup Flutter SDK
121+
# - name: "Setup Flutter SDK"
107122
# uses: subosito/flutter-action@v2
108123
# with:
109124
# cache: true
@@ -135,7 +150,7 @@ jobs:
135150
- name: Check package score
136151
run: pana --exit-code-threshold 0 --no-dartdoc .
137152
build-android:
138-
name: "Build Android APK"
153+
name: "[Android] Build APK"
139154
runs-on: ubuntu-latest
140155
defaults:
141156
run:
@@ -166,7 +181,7 @@ jobs:
166181
name: maplibre-flutter-demo.apk
167182
path: example/build/app/outputs/flutter-apk/app-release.apk
168183
# build-iOS:
169-
# name: Build iOS package
184+
# name: [iOS] Build package
170185
# runs-on: macos-latest
171186
# timeout-minutes: 30
172187
# defaults:
@@ -196,7 +211,7 @@ jobs:
196211
# name: maplibre-flutter-demo.app
197212
# path: example/build/ios/iphonesimulator
198213
build-web:
199-
name: "Build Web"
214+
name: "[Web] Build"
200215
runs-on: ubuntu-latest
201216
defaults:
202217
run:
@@ -216,7 +231,7 @@ jobs:
216231
- name: Build web
217232
run: flutter build web
218233
build-web-wasm:
219-
name: "Build Web WASM"
234+
name: "[Web] Build WASM"
220235
runs-on: ubuntu-latest
221236
defaults:
222237
run:

.github/workflows/daily.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Daily Maintenance"
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
6+
jobs:
7+
close-issues:
8+
name: "Close Issues"
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
pull-requests: write
13+
steps:
14+
- uses: actions/stale@v9
15+
with:
16+
days-before-issue-stale: 7
17+
days-before-issue-close: 7
18+
stale-issue-label: "stale"
19+
stale-issue-message: "This issue requires additional information in order to be resolved. However, there hasn't been any response within one week.\nThis issue will be automatically closed in one week if there is no response."
20+
close-issue-message: "This issue was closed because it has been inactive for 2 weeks but requires information in order to be resolved."
21+
days-before-pr-stale: -1
22+
days-before-pr-close: -1
23+
remove-stale-when-updated: true
24+
any-of-labels: "question"
25+
labels-to-remove-when-unstale: "question,stale"
26+
repo-token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "Issue Comment"
2+
on:
3+
issue_comment:
4+
types: [ created ]
5+
6+
jobs:
7+
remove-question-flag:
8+
name: "Remove `question` Label"
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
pull-requests: write
13+
steps:
14+
- name: "Check issue labels"
15+
id: check_labels
16+
uses: actions/github-script@v7
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
script: |
20+
const { data: issue } = await github.rest.issues.get({
21+
owner: context.repo.owner,
22+
repo: context.repo.repo,
23+
issue_number: context.issue.number
24+
});
25+
26+
const isStale = issue.labels.some(label => label.name === 'stale');
27+
console.log("isStale: " + isStale);
28+
if (isStale) return false;
29+
30+
const { data: events } = await github.rest.issues.listEvents({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
issue_number: context.issue.number
34+
});
35+
const labelAddedEvent = events.findLast(event => event.event === 'labeled' && event.label.name === 'question');
36+
if (!labelAddedEvent) return false;
37+
const labelAddedDate = new Date(labelAddedEvent.created_at);
38+
const now = new Date();
39+
const secondsSinceLabelAdded = (now - labelAddedDate) / 1000;
40+
console.log(secondsSinceLabelAdded + "s")
41+
return secondsSinceLabelAdded > 30;
42+
# only remove the label if the issue is not stale, this prevents that this
43+
# action removes the label when the automatic reminder message gets sent.
44+
- name: "Remove `question` label if exists"
45+
if: steps.check_labels.outputs.result == 'true'
46+
uses: actions/github-script@v7
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
script: |
50+
await github.rest.issues.removeLabel({
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
issue_number: context.issue.number,
54+
name: ["question"]
55+
});

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# MapLibre for Flutter
22

33
[![Pub Version](https://img.shields.io/pub/v/maplibre)](https://pub.dev/packages/maplibre)
4+
[![stars](https://badgen.net/github/stars/josxha/flutter-maplibre?label=stars&color=green&icon=github)](https://github.com/josxha/flutter-maplibre/stargazers)
45
[![likes](https://img.shields.io/pub/likes/maplibre?logo=flutter)](https://pub.dev/packages/maplibre)
56
[![Pub Points](https://img.shields.io/pub/points/maplibre)](https://pub.dev/packages/maplibre/score)
67
[![Pub Popularity](https://img.shields.io/pub/popularity/maplibre)](https://pub.dev/packages/maplibre)
7-
[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)
88

9-
[![GitHub last commit](https://img.shields.io/github/last-commit/josxha/flutter-maplibre)](https://github.com/josxha/flutter-maplibre)
10-
[![stars](https://badgen.net/github/stars/josxha/flutter-maplibre?label=stars&color=green&icon=github)](https://github.com/josxha/flutter-maplibre/stargazers)
11-
[![GitHub issues](https://img.shields.io/github/issues/josxha/flutter-maplibre)](https://github.com/josxha/flutter-maplibre/issues)
9+
[![codecov](https://codecov.io/gh/josxha/flutter-maplibre/graph/badge.svg?token=3LK7EQMSUM)](https://codecov.io/gh/josxha/flutter-maplibre)
10+
[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)
1211

1312
This package provides unofficial Flutter bindings for MapLibre SDKs.
1413

example/integration_test/smoke_test.dart renamed to example/integration_test/controller_test.dart

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:async';
2+
13
import 'package:flutter_test/flutter_test.dart';
24
import 'package:integration_test/integration_test.dart';
35
import 'package:maplibre/maplibre.dart';
@@ -19,13 +21,13 @@ void main() {
1921
testWidgets(
2022
'getCamera',
2123
(tester) async {
22-
late final MapController ctrl;
24+
final ctrlCompleter = Completer<MapController>();
2325
final app = App(
24-
onMapCreated: (controller) => ctrl = controller,
26+
onMapCreated: ctrlCompleter.complete,
2527
options: MapOptions(initCenter: Position(1, 2)),
2628
);
2729
await tester.pumpWidget(app);
28-
await tester.pumpAndSettle();
30+
final ctrl = await ctrlCompleter.future;
2931
await ctrl.moveCamera(
3032
center: Position(1, 1),
3133
bearing: 1,
@@ -42,12 +44,12 @@ void main() {
4244
},
4345
);
4446
testWidgets(
45-
'jumpTo',
47+
'moveCamera',
4648
(tester) async {
47-
late final MapController ctrl;
48-
final app = App(onMapCreated: (controller) => ctrl = controller);
49+
final ctrlCompleter = Completer<MapController>();
50+
final app = App(onMapCreated: ctrlCompleter.complete);
4951
await tester.pumpWidget(app);
50-
await tester.pumpAndSettle();
52+
final ctrl = await ctrlCompleter.future;
5153
await ctrl.moveCamera(
5254
center: Position(1, 2),
5355
bearing: 1,
@@ -63,13 +65,13 @@ void main() {
6365
expect(camera.pitch, closeTo(1, 0.00001));
6466
},
6567
);
66-
testWidgets(
67-
'flyTo',
68+
/*testWidgets(
69+
'animateCamera',
6870
(tester) async {
69-
late final MapController ctrl;
70-
final app = App(onMapCreated: (controller) => ctrl = controller);
71+
final ctrlCompleter = Completer<MapController>();
72+
final app = App(onMapCreated: ctrlCompleter.complete);
7173
await tester.pumpWidget(app);
72-
await tester.pumpAndSettle();
74+
final ctrl = await ctrlCompleter.future;
7375
await ctrl.animateCamera(
7476
center: Position(2, 1),
7577
bearing: 2,
@@ -86,9 +88,9 @@ void main() {
8688
expect(camera.bearing, closeTo(2, 0.00001));
8789
expect(camera.pitch, closeTo(2, 0.00001));
8890
},
89-
);
91+
);*/
9092
/*testWidgets(
91-
'flyTo cancel',
93+
'animateCamera cancel',
9294
(tester) async {
9395
late final MapController ctrl;
9496
final app = App(onMapCreated: (controller) => ctrl = controller);

0 commit comments

Comments
 (0)