Skip to content

Commit

Permalink
RDART-971: Prepare ejson packages (#1555)
Browse files Browse the repository at this point in the history
* Simplify melos.yaml

* Handle fail-fast correctly in build.dart

* Refactor build.dart into separate project.

* Use cli_launcher

* Add scripts to version packages

* Link up separate CHANGELOG and README for ejson package

* Update ejson version to 0.2.0-pre.1

* Don't require strict-raw-types

* Fix analyzer warning

* Change how pubspecs are updated

* Remove debug output

* Fix coverage regression on CI
  • Loading branch information
nielsenko authored Mar 14, 2024
1 parent e36c0f4 commit 689d824
Show file tree
Hide file tree
Showing 33 changed files with 178 additions and 112 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ jobs:
version: ${{ inputs.version }}
version-suffix: ''

- name: Update pubspec.yaml
uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0
- name : Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
find: 'version: .*'
replace: 'version: ${{ steps.update-changelog.outputs.new-version }}'
include: '**pubspec.yaml'
sdk: stable
architecture: 'x64'

- name: Setup Melos
run: dart pub global activate melos

- name: Update pubspec.yaml files
run: REALM_VERSION=${{ inputs.version}} melos run update:version:realm

- name: Update realm.podspec
uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0
Expand Down
29 changes: 1 addition & 28 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,9 @@ jobs:
working-directory: packages/realm_dart
shell: bash

- name: Update realm_* path dependencies (Production)
uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0
if: ${{ github.event.inputs.environment == 'Production' }}
with:
find: " realm_(common|generator|dart):(\\n|\\r\\n) path:.*"
replace: " realm_$1: ${{ steps.get-version.outputs.version }}"
include: "**pubspec.yaml"

- name: Update realm_* path dependencies (Staging)
uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0
if: ${{ github.event.inputs.environment != 'Production' }}
with:
find: " realm_(common|generator|dart):(\\n|\\r\\n) path:.*"
replace: " realm_$1:\n path: ../realm_$1"
include: "**pubspec.yaml"

- name: Update pubspec.yaml version (Staging)
uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0
if: ${{ github.event.inputs.environment != 'Production' }}
with:
find: 'version: .*'
replace: 'version: ${{ steps.get-version.outputs.version }}'
include: '**pubspec.yaml'

- name: Remove pubspec.yaml/publish_to:none
uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0
with:
find: "publish_to: none(\\n|\\r\\n)"
replace: " "
include: "**pubspec.yaml"
run: REALM_VERSION=${{ steps.get-version.outputs.version }} melos run update:version:realm

- name: Package realm_common
run: |
Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ analyzer:
language:
strict-casts: true # see https://github.com/dart-lang/language/blob/main/resources/type-system/strict-casts.md
strict-inference: true # see https://github.com/dart-lang/language/blob/main/resources/type-system/strict-inference.md
strict-raw-types: true # see https://github.com/dart-lang/language/blob/main/resources/type-system/strict-raw-types.md
# strict-raw-types: true # see https://github.com/dart-lang/language/blob/main/resources/type-system/strict-raw-types.md

plugins:
- custom_lint
Expand Down
45 changes: 35 additions & 10 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ scripts:
dart pub global activate dependency_validator &&
dart pub global activate ffigen &&
dart pub global activate melos &&
dart pub global activate pana
dart pub global activate pana &&
dart pub global activate --source path $MELOS_ROOT_PATH/packages/realm_dart/dev/
build:
run: >-
Expand All @@ -41,7 +42,7 @@ scripts:
melos run build:dart
build:native:
exec: dart run tool/build.dart native
exec: dev build
packageFilters:
dirExists: src # by convention

Expand All @@ -53,10 +54,10 @@ scripts:
dependsOn: build_runner

build:binding:
exec: dart pub global run ffigen --config ffigen.yaml
exec: dart run ffigen --config ffigen.yaml
packageFilters:
fileExists: ffigen.yaml # by convention

dependsOn: ffigen
test:
description: Run all tests.
run: >-
Expand Down Expand Up @@ -143,7 +144,7 @@ scripts:
concurrency: 1 # only one project at a time to keep output sane

lint:pana:
run: dart pub global run pana --no-warning --exit-code-threshold 40 .
run: pana --no-warning --exit-code-threshold 40 .
exec:
concurrency: 1 # only one project at a time to keep output sane
packageFilters:
Expand All @@ -159,7 +160,7 @@ scripts:
exec: dart analyze . --fatal-infos

analyze:deps:
exec: dart pub global run dependency_validator
exec: dependency_validator

coverage:
description: Generate, check and render coverage.
Expand All @@ -171,14 +172,14 @@ scripts:
melos run coverage:check
coverage:check: # TODO: Increase to 90 eventually
run: dart pub global run coverde check 80
run: coverde check 80
exec:
concurrency: 1 # only one project at a time to keep output sane
packageFilters:
fileExists: coverage/lcov.info # by convention

coverage:convert:
run: dart pub global run coverage:format_coverage --report-on=lib/ --in=coverage/test/ --lcov --out=coverage/lcov.info
run: format_coverage --packages=.dart_tool/package_config.json --report-on=lib/ --in=coverage/test/ --lcov --out=coverage/lcov.info
exec:
concurrency: 1 # only one project at a time to keep output sane
packageFilters:
Expand All @@ -189,15 +190,39 @@ scripts:
coverage:gather:
run: |
rm -rf $MELOS_ROOT_PATH/coverage
dart pub global run combine_coverage --repo-path=$MELOS_ROOT_PATH
combine_coverage --repo-path=$MELOS_ROOT_PATH
coverage:groom:
run: |
lcov --remove coverage/lcov.info '*/lib/src/cli/*' -o coverage/lcov.info
lcov --remove coverage/lcov.info '*/realm_bindings.dart' -o coverage/lcov.info
coverage:report:
run: dart pub global run coverde report
run: coverde report

update:version:
run: >-
melos run update:version:ejson &&
melos run update:version:realm
update:version:ejson:
description: Update version of all ejson packages collectively
run: >-
melos version --no-git-commit-version --no-changelog --no-dependent-versions --yes
-V ejson_analyzer:$EJSON_VERSION
-V ejson_annotation:$EJSON_VERSION
-V ejson_generator:$EJSON_VERSION
-V ejson_lint:$EJSON_VERSION
-V ejson:$EJSON_VERSION
update:version:realm:
description: Update version of all realm packages collectively
run: >-
melos version --no-git-commit-version --no-changelog --no-dependent-versions --yes
-V realm_common:$REALM_VERSION
-V realm_dart:$REALM_VERSION
-V realm_generator:$REALM_VERSION
-V realm:$REALM_VERSION
# TODO: This is actually stricter than on CI, but we should aim for this
ci:
Expand Down
7 changes: 7 additions & 0 deletions packages/CHANGELOG.ejson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 0.2.0-pre.1

- First published version.

## 0.1.0

- Initial version.
1 change: 1 addition & 0 deletions packages/README.ejson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO!
3 changes: 0 additions & 3 deletions packages/ejson/CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions packages/ejson/CHANGELOG.md
2 changes: 1 addition & 1 deletion packages/ejson/README.md
2 changes: 1 addition & 1 deletion packages/ejson/lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class Undefined<T> extends UndefinedOr<T> {
String toString() => 'Undefined<$T>()';
}

const undefined = Undefined();
const undefined = Undefined<dynamic>();

final class Defined<T> extends UndefinedOr<T> {
final T value;
Expand Down
6 changes: 3 additions & 3 deletions packages/ejson/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ topics:
- build-runner
- codegen

version: 0.1.0
version: 0.2.0-pre.1
repository: https://github.com/realm/realm-dart/ejson/packages/ejson

environment:
sdk: ^3.0.0

dependencies:
collection: ^1.17.0
ejson_annotation: ^0.1.0
ejson_annotation: ^0.2.0-pre.1
objectid: ^3.0.0
sane_uuid: ^1.0.0-alpha.5
type_plus: ^2.0.0

dev_dependencies:
build_runner: ^2.0.0
ejson_generator: ^0.1.0
ejson_generator: ^0.2.0-pre.1
lints: ^3.0.0
test: ^1.21.0
3 changes: 0 additions & 3 deletions packages/ejson_analyzer/CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions packages/ejson_analyzer/CHANGELOG.md
2 changes: 1 addition & 1 deletion packages/ejson_analyzer/README.md
4 changes: 2 additions & 2 deletions packages/ejson_analyzer/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: ejson_analyzer
description: A starting point for Dart libraries or applications.

version: 0.1.0
version: 0.2.0-pre.1
repository: https://github.com/realm/realm-dart/ejson/packages/ejson_analyzer

environment:
sdk: ^3.0.0

dependencies:
analyzer: ^6.0.0
ejson_annotation: ^0.1.0
ejson_annotation: ^0.2.0-pre.1
source_gen: ^1.3.2

dev_dependencies:
Expand Down
3 changes: 0 additions & 3 deletions packages/ejson_annotation/CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions packages/ejson_annotation/CHANGELOG.md
2 changes: 1 addition & 1 deletion packages/ejson_annotation/README.md
2 changes: 1 addition & 1 deletion packages/ejson_annotation/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: >-
BSON is a binary format used to store JSON-like documents efficiently.
EJSON extends JSON defining how all BSON types should be represented in JSON.
version: 0.1.0
version: 0.2.0-pre.1
repository: https://github.com/realm/realm-dart/ejson/packages/ejson_annotation

environment:
Expand Down
3 changes: 0 additions & 3 deletions packages/ejson_generator/CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions packages/ejson_generator/CHANGELOG.md
2 changes: 1 addition & 1 deletion packages/ejson_generator/README.md
8 changes: 4 additions & 4 deletions packages/ejson_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ topics:
- build-runner
- codegen

version: 0.1.0
version: 0.2.0-pre.1
repository: https://github.com/realm/realm-dart/ejson/packages/ejson_generator

environment:
Expand All @@ -21,15 +21,15 @@ environment:
dependencies:
analyzer: ^6.0.0
build: ^2.4.0
ejson_analyzer: ^0.1.0
ejson_analyzer: ^0.2.0-pre.1
source_gen: ^1.3.2

dev_dependencies:
build_runner: ^2.4.4
build_test: ^2.1.7
dart_style: ^2.3.1
ejson: ^0.1.0
ejson_annotation: ^0.1.0
ejson: ^0.2.0-pre.1
ejson_annotation: ^0.2.0-pre.1
lints: ^3.0.0
meta: ^1.9.1
test: ^1.21.0
3 changes: 0 additions & 3 deletions packages/ejson_lint/CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions packages/ejson_lint/CHANGELOG.md
2 changes: 1 addition & 1 deletion packages/ejson_lint/README.md
4 changes: 2 additions & 2 deletions packages/ejson_lint/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ environment:
sdk: ^3.0.0

dependencies:
ejson_annotation: ^0.1.0
ejson_annotation: ^0.2.0-pre.1

dev_dependencies:
custom_lint: ^0.6.2
ejson_lint: ^0.1.0
ejson_lint: ^0.2.0-pre.1
lints: ^3.0.0


4 changes: 2 additions & 2 deletions packages/ejson_lint/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ejson_lint
description: A starting point for Dart libraries or applications.

version: 0.1.0
version: 0.2.0-pre.1
repository: https://github.com/realm/realm-dart/ejson/packages/ejson_lint

environment:
Expand All @@ -10,7 +10,7 @@ environment:
dependencies:
analyzer: ^6.0.0
custom_lint_builder: ^0.6.2
ejson_analyzer: ^0.1.0
ejson_analyzer: ^0.2.0-pre.1

dev_dependencies:
lints: ^3.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/realm/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
realm: ^1.8.0
realm: ^2.0.0-alpha.2
characters: ^1.1.0

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion packages/realm/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ environment:
dependencies:
flutter:
sdk: flutter
realm_dart: ^1.8.0
realm_dart: ^2.0.0-alpha.2

flutter:
plugin:
Expand Down
3 changes: 3 additions & 0 deletions packages/realm_dart/dev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version.
Loading

0 comments on commit 689d824

Please sign in to comment.