Skip to content

Commit 422d320

Browse files
authored
feat!: Add exception to onVerificationFailed callback, improve error handling, add API Guard to CI
2 parents 60f0d7c + 3ac6be8 commit 422d320

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+348
-229
lines changed

.github/workflows/build_dev.yaml

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,13 @@ on:
66
- dev
77

88
jobs:
9-
version:
10-
name: Version & Build
9+
validate:
10+
name: Validate Package
1111
runs-on: macos-latest
12-
environment: release
13-
permissions:
14-
contents: write
15-
16-
outputs:
17-
version: ${{ steps.get_new_version.outputs.result}}
1812

1913
steps:
2014
- name: Checkout code
2115
uses: actions/checkout@v4
22-
with:
23-
token: ${{secrets.ELEVATED_TOKEN}}
24-
25-
- name: 📇 Configure git
26-
run: |
27-
git fetch --prune --unshallow
28-
git config --global user.name "GitHub Actions"
29-
git config --global user.email "gh-actions@merckgroup.com"
30-
shell: bash
31-
32-
# Retrieve the new version
33-
- name: 🔂 Run standard-version
34-
uses: actions/github-script@v7
35-
with:
36-
script: |
37-
const {execSync} = require('child_process');
38-
execSync('npx standard-version --skip.tag --prerelease', {stdio: 'inherit'});
39-
40-
# Retrieve the new version
41-
- name: ⏎ Get new version
42-
uses: actions/github-script@v7
43-
id: get_new_version
44-
with:
45-
result-encoding: string
46-
script: |
47-
const fs = require('fs');
48-
const package = JSON.parse(fs.readFileSync('package.json', 'utf8'));
49-
return package.version;
50-
51-
- name: Print new version
52-
run: echo ${{ steps.get_new_version.outputs.result}}
53-
54-
# Bump the pubspec.yaml file
55-
- name: ⬆️ Bump pubspec.yaml
56-
uses: emdgroup/mtrust-urp/.github/shared_actions/update-pubspec@dev
57-
with:
58-
version: ${{ steps.get_new_version.outputs.result }}
59-
directory: .
60-
61-
- name: 📝 Update version in readme
62-
uses: emdgroup/mtrust-urp/.github/shared_actions/update-pubspec-readme-version@dev
63-
with:
64-
directory: .
6516

6617
- name: Setup Dart
6718
uses: dart-lang/setup-dart@v1
@@ -82,17 +33,11 @@ jobs:
8233
with:
8334
directory: "."
8435

85-
# We first commit with proper message and add an empty commit to keep the files history clean
86-
- name: Update repo versions
87-
run: |
88-
git add .
89-
git commit -m "chore(release): ${{ steps.get_new_version.outputs.result }}"
90-
git commit --allow-empty -m "chore(release): ${{ steps.get_new_version.outputs.result }} [skip ci]"
91-
git push origin dev
92-
93-
# For this part it is important to not push a commit with [skip ci] before the tag release
94-
- name: Push tag for pub.dev
95-
run: |
96-
git commit --allow-empty -m "chore(release): ${{ steps.get_new_version.outputs.result }}"
97-
git tag -a v${{ steps.get_new_version.outputs.result }} -m "Pub.dev version ${{ steps.get_new_version.outputs.result }}"
98-
git push origin v${{ steps.get_new_version.outputs.result }}
36+
api-guard:
37+
needs: validate
38+
uses: emdgroup/mtrust-api-guard/.github/workflows/publish_workflow.yaml@main
39+
with:
40+
git_push_branch: dev
41+
git_push: true
42+
pre_release: true
43+
secrets: inherit

.github/workflows/build_main.yaml

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,13 @@ on:
66
- main
77

88
jobs:
9-
version:
10-
name: Version & Build
9+
validate:
10+
name: Validate Package
1111
runs-on: macos-latest
12-
environment: release
13-
permissions:
14-
contents: write
15-
16-
outputs:
17-
version: ${{ steps.get_new_version.outputs.result}}
1812

1913
steps:
2014
- name: Checkout code
2115
uses: actions/checkout@v4
22-
with:
23-
token: ${{secrets.ELEVATED_TOKEN}}
24-
25-
- name: 📇 Configure git
26-
run: |
27-
git fetch --prune --unshallow
28-
git config --global user.name "GitHub Actions"
29-
git config --global user.email "gh-actions@merckgroup.com"
30-
shell: bash
31-
32-
# Retrieve the new version
33-
- name: 🔂 Run standard-version
34-
uses: actions/github-script@v7
35-
with:
36-
script: |
37-
const {execSync} = require('child_process');
38-
execSync('npx standard-version --skip.tag', {stdio: 'inherit'});
39-
40-
# Retrieve the new version
41-
- name: ⏎ Get new version
42-
uses: actions/github-script@v7
43-
id: get_new_version
44-
with:
45-
result-encoding: string
46-
script: |
47-
const fs = require('fs');
48-
const package = JSON.parse(fs.readFileSync('package.json', 'utf8'));
49-
return package.version;
50-
51-
- name: Print new version
52-
run: echo ${{ steps.get_new_version.outputs.result}}
53-
54-
# Bump the pubspec.yaml file
55-
- name: ⬆️ Bump pubspec.yaml
56-
uses: emdgroup/mtrust-urp/.github/shared_actions/update-pubspec@main
57-
with:
58-
version: ${{ steps.get_new_version.outputs.result }}
59-
directory: .
60-
61-
- name: 📝 Update version in readme
62-
uses: emdgroup/mtrust-urp/.github/shared_actions/update-pubspec-readme-version@main
63-
with:
64-
directory: .
6516

6617
- name: Setup Dart
6718
uses: dart-lang/setup-dart@v1
@@ -82,24 +33,17 @@ jobs:
8233
with:
8334
directory: "."
8435

85-
# We first commit with proper message and add an empty commit to keep the files history clean
86-
- name: Update repo versions
87-
run: |
88-
git add .
89-
git commit -m "chore(release): ${{ steps.get_new_version.outputs.result }}"
90-
git commit --allow-empty -m "chore(release): ${{ steps.get_new_version.outputs.result }} [skip ci]"
91-
git push origin main
92-
93-
# For this part it is important to not push a commit with [skip ci] before the tag release
94-
- name: Push tag for pub.dev
95-
run: |
96-
git commit --allow-empty -m "chore(release): ${{ steps.get_new_version.outputs.result }}"
97-
git tag -a v${{ steps.get_new_version.outputs.result }} -m "Pub.dev version ${{ steps.get_new_version.outputs.result }}"
98-
git push origin v${{ steps.get_new_version.outputs.result }}
36+
api-guard:
37+
needs: validate
38+
uses: emdgroup/mtrust-api-guard/.github/workflows/publish_workflow.yaml@main
39+
with:
40+
git_push_branch: main
41+
git_push: true
42+
secrets: inherit
9943

10044
rebase_dev:
10145
name: Write changes to dev branch
102-
needs: [version]
46+
needs: [api-guard]
10347
runs-on: ubuntu-latest
10448
permissions:
10549
contents: write

.github/workflows/pr_dev.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,8 @@ jobs:
6666
uses: emdgroup/mtrust-urp/.github/shared_actions/check-dart-licenses@dev
6767
with:
6868
directory: .
69+
70+
api-guard:
71+
uses: emdgroup/mtrust-api-guard/.github/workflows/pr_workflow.yaml@main
72+
with:
73+
pre_release: true

.github/workflows/pr_main.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ jobs:
6666
uses: emdgroup/mtrust-urp/.github/shared_actions/check-dart-licenses@main
6767
with:
6868
directory: .
69+
70+
api-guard:
71+
uses: emdgroup/mtrust-api-guard/.github/workflows/pr_workflow.yaml@main

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ test/failures
3535
**/GeneratedPluginRegistrant.swift
3636
**/generated_plugin_registrant.cc
3737
**/generated_plugin_registrant.h
38-
**/generated_plugins.cmake
38+
**/generated_plugins.cmake

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ To display the SEC Modal, utilize the `SecModalBuilder` widget. It requires a co
9595
strategy: _connectionStrategy,
9696
payload: // Payload,
9797
onVerificationDone: (mesurement) {},
98-
onVerificationFailed: () {},
98+
onVerificationFailed: (exception) {
99+
// Handle verification failure. The exception provides details about the cause.
100+
},
99101
onDismiss: (){ } // Optionally
100102
canDismiss: true, // Define whether the user can dismiss the modal
101103
builder: (context, openModal) {

analysis_options.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ analyzer:
66
exclude:
77
- "lib/src/**/*.g.dart"
88
- "lib/src/**/*.freezed.dart"
9-
- "lib/src/ui/l10n/*.dart"
9+
- "lib/src/ui/l10n/*.dart"
10+
11+
api_guard:
12+
exclude:
13+
- "example/**"

example/lib/main.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import 'package:example/virtual_strategy.dart';
22
import 'package:flutter/foundation.dart';
33
import 'package:flutter/material.dart';
4-
import 'package:mtrust_sec_kit/mtrust_sec_kit.dart';
5-
64
import 'package:liquid_flutter/liquid_flutter.dart';
5+
import 'package:mtrust_sec_kit/mtrust_sec_kit.dart';
76
import 'package:mtrust_urp_ble_strategy/mtrust_urp_ble_strategy.dart';
87

98
void main() {
@@ -102,8 +101,8 @@ class _MainAppState extends State<MainApp> {
102101
onVerificationDone: (measurement) {
103102
debugPrint("Verification done ${measurement.measurement}");
104103
},
105-
onVerificationFailed: () {
106-
debugPrint("Verification failed");
104+
onVerificationFailed: (exception) {
105+
debugPrint("Verification failed: $exception");
107106
},
108107
builder: (context, openModal) {
109108
return LdButton(

0 commit comments

Comments
 (0)