Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: move package into a monorepo #519

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 130 additions & 61 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@ version: 2.1

orbs:
android: circleci/[email protected]
flutter: circleci/[email protected].2
flutter: circleci/[email protected].4
node: circleci/[email protected]
advanced-checkout: vsco/[email protected]

executors:
flutter-executor:
docker:
- image: cimg/base:stable


commands:
setup_flutter:
parameters:
version:
type: string
default: 3.24.3
use_melos:
type: boolean
default: true
working_dir:
type: string
default: "~/project"
steps:
- flutter/install_sdk_and_pub:
version: 3.10.5
- run:
name: Generate Pigeons
command: sh ./scripts/pigeon.sh
version: <<parameters.version>>
app-dir: <<parameters.working_dir>>
- install_flutter_and_dart_packages:
generate_pigeons: true
use_melos: <<parameters.use_melos>>
working_dir: <<parameters.working_dir>>
setup_ios:
steps:
# Flutter doesn't support Apple Silicon yet, so we need to install Rosetta use Flutter on M1 machines.
Expand All @@ -26,7 +44,7 @@ commands:
command: sudo gem install cocoapods
- run:
name: Install Pods
working_directory: example/ios
working_directory: packages/instabug_flutter/example/ios
command: pod install --repo-update
setup_captain:
parameters:
Expand Down Expand Up @@ -77,32 +95,71 @@ commands:
name: Configure Captain Platform
command: echo 'export CAPTAIN_PLATFORM=<<parameters.platform>>' >> $BASH_ENV
# This runs `flutter pub get` and `dart pub get` if we pass parameter `generate_pigeons` to the job it also runs the following:
# - `sh ./scripts/pigeon.sh`
# - `dart run build_runner build --delete-conflicting-outputs`
# - `melos pigeon`
# - `melos generate`
install_flutter_and_dart_packages:
parameters:
generate_pigeons:
type: boolean
use_melos:
type: boolean
default: true
working_dir:
type: string
steps:
- run:
name: Install Flutter Packages
command: flutter pub get
- run:
name: Install Dart Packages
command: dart pub get
description: Install Dart Packages (for dart explicit packages)
- when:
condition:
equal:
- <<parameters.generate_pigeons>>
- <<parameters.use_melos>>
- true
steps:
- run:
name: Generate Pigeons
command: sh ./scripts/pigeon.sh
name: Install melos
command: dart pub global activate melos && echo 'export PATH="$PATH:$HOME/.pub-cache/bin"' >> $BASH_ENV
- run:
name: Install Flutter Packages
command: melos bootstrap
- run:
name: Build Pigeons
command: dart run build_runner build --delete-conflicting-outputs
name: Install Dart Packages
command: melos dart_bootstrap
description: Install Dart Packages (for dart explicit packages)
- when:
condition:
equal:
- <<parameters.generate_pigeons>>
- true
steps:
- run:
name: Generate Pigeons
command: melos pigeon
- run:
name: Build Pigeons
command: melos generate
- when:
condition:
equal:
- <<parameters.use_melos>>
- false
steps:
- run:
name: Install Flutter Packages
command: flutter pub get
- run:
name: Install Dart Packages
command: dart pub get
description: Install Dart Packages (for dart explicit packages)
- when:
condition:
equal:
- <<parameters.generate_pigeons>>
- true
steps:
- run:
name: Generate Pigeons
command: sh scripts/pigeon.sh
- run:
name: Build Pigeons
command: dart run build_runner build --delete-conflicting-outputs

jobs:
danger:
Expand All @@ -114,7 +171,7 @@ jobs:
pkg-manager: yarn
override-ci-command: yarn install --frozen-lockfile --network-concurrency 1
- attach_workspace:
at: coverage
at: ~/project
- run:
name: Run Danger
command: yarn danger ci
Expand All @@ -123,20 +180,38 @@ jobs:
parameters:
version:
type: string
docker:
- image: cirrusci/flutter:<<parameters.version>>
default: "3.24.3"
executor: flutter-executor
steps:
- advanced-checkout/shallow-checkout
- install_flutter_and_dart_packages:
generate_pigeons: true
- run: flutter test --coverage
- run:
working_directory: coverage
command: lcov --remove lcov.info '*.g.dart' '*.mocks.dart' -o lcov.info
- run: sudo apt-get update&& sudo apt-get -y install lcov
- setup_flutter:
version: <<parameters.version>>
use_melos: true
- run: melos test-coverage
- persist_to_workspace:
root: coverage
root: ~/project
paths:
- lcov.info
- coverage


test_flutter_without_melos:
parameters:
version:
type: string
default: "2.10.0"
app-dir:
type: string
executor: flutter-executor
working_directory: <<parameters.app-dir>>
steps:
- advanced-checkout/shallow-checkout:
path: ~/project
- setup_flutter:
version: <<parameters.version>>
use_melos: false
working_dir: <<parameters.app-dir>>
- run: flutter test

test_android:
executor:
Expand All @@ -147,7 +222,7 @@ jobs:
- advanced-checkout/shallow-checkout
- setup_flutter
- android/run-tests:
working-directory: example/android
working-directory: packages/instabug_flutter/example/android
test-command: ./gradlew test

e2e_android_captain:
Expand All @@ -164,7 +239,7 @@ jobs:
run-tests-working-directory: e2e
additional-avd-args: --device 3
system-image: system-images;android-33;default;x86_64
post-emulator-launch-assemble-command: cd example && flutter build apk --debug
post-emulator-launch-assemble-command: cd packages/instabug_flutter/example && flutter build apk --debug
test-command: dotnet test

test_ios:
Expand All @@ -178,7 +253,7 @@ jobs:
- setup_ios
- run:
name: Build and run tests
working_directory: ~/project/example/ios
working_directory: ~/project/packages/instabug_flutter/example/ios
command: |
xcodebuild -allowProvisioningUpdates \
-workspace Runner.xcworkspace \
Expand All @@ -199,7 +274,7 @@ jobs:
- setup_ios
- run:
name: Build Example App
working_directory: example
working_directory: packages/instabug_flutter/example
command: flutter build ios --simulator
- run:
name: Run E2E Tests
Expand All @@ -208,44 +283,38 @@ jobs:
command: dotnet test

format_flutter:
docker:
- image: cirrusci/flutter
executor: flutter-executor
steps:
- advanced-checkout/shallow-checkout
- install_flutter_and_dart_packages:
generate_pigeons: false
- setup_flutter
- run:
name: Check Format
command: dart format . --set-exit-if-changed
command: melos format

lint_flutter:
docker:
- image: cirrusci/flutter
executor: flutter-executor
steps:
- advanced-checkout/shallow-checkout
- install_flutter_and_dart_packages:
generate_pigeons: true
- setup_flutter
- run:
name: Perform Static Analysis
command: flutter analyze
command: melos analyze

verify_pub:
docker:
- image: cirrusci/flutter
executor: flutter-executor
steps:
- advanced-checkout/shallow-checkout
- install_flutter_and_dart_packages:
generate_pigeons: true
- setup_flutter
- run:
name: Check Package Score
command: dart run pana --no-warning --exit-code-threshold 0
- run: flutter pub publish --dry-run
command: melos score
- run: melos dryPublish

release:
release_instabug_flutter:
macos:
xcode: 15.2.0
resource_class: macos.m1.medium.gen1
working_directory: "~"
working_directory: "~/project"
steps:
- advanced-checkout/shallow-checkout:
path: ~/project
Expand All @@ -254,7 +323,7 @@ jobs:
name: Install Rosetta
command: softwareupdate --install-rosetta --agree-to-license
- flutter/install_sdk_and_pub:
version: 3.3.6
version: 3.10.5
app-dir: project
- run:
name: Install pub packages
Expand All @@ -263,7 +332,7 @@ jobs:
- run:
name: Generate Pigeons
working_directory: project
command: sh ./scripts/pigeon.sh
command: melos pigeon
- run:
name: Clone Escape
command: git clone [email protected]:Instabug/Escape.git
Expand All @@ -288,10 +357,10 @@ workflows:
- test_flutter-stable
- test_flutter:
name: test_flutter-stable
version: stable
- test_flutter:
- test_flutter_without_melos:
name: test_flutter-2.10.5
version: 2.10.5
app-dir: "~/project/packages/instabug_flutter/"
- e2e_android_captain
- test_ios
- e2e_ios_captain
Expand All @@ -302,7 +371,7 @@ workflows:
- verify_pub:
requires:
- lint_flutter
- hold_release:
- hold_release_instabug_flutter:
type: approval
requires:
- danger
Expand All @@ -319,9 +388,9 @@ workflows:
filters:
branches:
only: master
- release:
- release_instabug_flutter:
requires:
- hold_release
- hold_release_instabug_flutter
filters:
branches:
only: master
only: master
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated files
*.mocks.dart
*.g.dart
android/**/generated/
ios/**/Generated/
packages/**/android/**/generated/
packages/**/ios/**/Generated/

# Miscellaneous
*.class
Expand Down Expand Up @@ -84,3 +84,4 @@ android/gradlew.bat
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
/packages/**/lib/src/generated/
Loading