From 27e7984179d376140ceab564ce85fbcd7da0c1ed Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Sat, 17 Jun 2023 14:17:03 -0400 Subject: [PATCH] feat: add shorebird_code_push package (#30) * feat: add shorebird_code_push package * remove example and extra code * update github workflow * fix gha --- .github/actions/dart_package/action.yaml | 79 +++++++++++++++++++ .github/workflows/main.yaml | 38 ++++++++- shorebird_code_push/.gitignore | 7 ++ shorebird_code_push/README.md | 9 +++ shorebird_code_push/analysis_options.yaml | 1 + shorebird_code_push/coverage_badge.svg | 20 +++++ .../lib/shorebird_code_push.dart | 4 + .../lib/src/shorebird_code_push.dart | 7 ++ shorebird_code_push/pubspec.yaml | 13 +++ .../test/src/shorebird_code_push_test.dart | 11 +++ 10 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 .github/actions/dart_package/action.yaml create mode 100644 shorebird_code_push/.gitignore create mode 100644 shorebird_code_push/README.md create mode 100644 shorebird_code_push/analysis_options.yaml create mode 100644 shorebird_code_push/coverage_badge.svg create mode 100644 shorebird_code_push/lib/shorebird_code_push.dart create mode 100644 shorebird_code_push/lib/src/shorebird_code_push.dart create mode 100644 shorebird_code_push/pubspec.yaml create mode 100644 shorebird_code_push/test/src/shorebird_code_push_test.dart diff --git a/.github/actions/dart_package/action.yaml b/.github/actions/dart_package/action.yaml new file mode 100644 index 0000000..459b1f0 --- /dev/null +++ b/.github/actions/dart_package/action.yaml @@ -0,0 +1,79 @@ +name: Dart Package Workflow +description: Build and test your Dart packages. + +inputs: + codecov_token: + required: true + description: The Codecov token used to upload coverage + concurrency: + required: false + default: "4" + description: The value of the concurrency flag (-j) used when running tests + coverage_excludes: + required: false + default: "" + description: Globs to exclude from coverage + dart_sdk: + required: false + default: "stable" + description: "The dart sdk version to use" + working_directory: + required: false + default: "." + description: The working directory for this workflow + min_coverage: + required: false + default: "100" + description: The minimum coverage percentage value + analyze_directories: + required: false + default: "lib test" + description: Directories to analyze + report_on: + required: false + default: "lib" + description: Directories to report on when collecting coverage + platform: + required: false + default: "vm" + description: Platform to use when running tests + +runs: + using: "composite" + steps: + - uses: dart-lang/setup-dart@v1 + with: + sdk: ${{inputs.dart_sdk}} + + - name: Install Dependencies + working-directory: ${{ inputs.working_directory }} + shell: ${{ inputs.shell }} + run: dart pub get + + - name: Format + working-directory: ${{ inputs.working_directory }} + shell: ${{ inputs.shell }} + run: dart format --set-exit-if-changed . + + - name: Analyze + working-directory: ${{ inputs.working_directory }} + shell: ${{ inputs.shell }} + run: dart analyze --fatal-warnings ${{inputs.analyze_directories}} + + - name: Test + working-directory: ${{ inputs.working_directory }} + shell: ${{ inputs.shell }} + run: | + dart pub global activate coverage + dart test -j ${{inputs.concurrency}} --coverage=coverage --platform=${{inputs.platform}} && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=${{inputs.report_on}} --check-ignore + + - name: Upload Coverage + uses: codecov/codecov-action@v3 + with: + token: ${{ inputs.codecov_token }} + + - uses: VeryGoodOpenSource/very_good_coverage@v2 + with: + path: ${{inputs.working_directory}}/coverage/lcov.info + exclude: ${{inputs.coverage_excludes}} + min_coverage: ${{inputs.min_coverage}} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4c36e8d..e1dbc9d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -18,6 +18,7 @@ jobs: pull-requests: read outputs: + needs_dart_build: ${{ steps.needs_dart_build.outputs.changes }} needs_rust_build: ${{ steps.needs_rust_build.outputs.changes }} name: 👀 Detect Changes @@ -26,6 +27,16 @@ jobs: - name: 📚 Git Checkout uses: actions/checkout@v3 + - uses: dorny/paths-filter@v2 + name: Build Detection + id: needs_dart_build + with: + filters: | + shorebird_code_push: + - ./.github/workflows/main.yaml + - ./.github/actions/dart_package/action.yaml + - shorebird_code_push/** + - uses: dorny/paths-filter@v2 name: Build Detection id: needs_rust_build @@ -60,8 +71,33 @@ jobs: codecov_token: ${{ secrets.CODECOV_TOKEN }} working_directory: ${{ matrix.crate }} + build_dart_packages: + needs: changes + if: ${{ needs.changes.outputs.needs_dart_build != '[]' }} + + strategy: + matrix: + package: ${{ fromJSON(needs.changes.outputs.needs_dart_build) }} + + runs-on: ubuntu-latest + + name: 🎯 Build ${{ matrix.package }} + + steps: + - name: 📚 Git Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: 🎯 Build ${{ matrix.package }} + uses: ./.github/actions/dart_package + with: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + coverage_excludes: "**/*.g.dart" + working_directory: ${{ matrix.package }} + ci: - needs: [semantic_pull_request, build_rust_crates] + needs: [semantic_pull_request, build_dart_packages, build_rust_crates] if: ${{ always() }} runs-on: ubuntu-latest diff --git a/shorebird_code_push/.gitignore b/shorebird_code_push/.gitignore new file mode 100644 index 0000000..526da15 --- /dev/null +++ b/shorebird_code_push/.gitignore @@ -0,0 +1,7 @@ +# See https://www.dartlang.org/guides/libraries/private-files + +# Files and directories created by pub +.dart_tool/ +.packages +build/ +pubspec.lock \ No newline at end of file diff --git a/shorebird_code_push/README.md b/shorebird_code_push/README.md new file mode 100644 index 0000000..2f75384 --- /dev/null +++ b/shorebird_code_push/README.md @@ -0,0 +1,9 @@ +# Shorebird Code Push + +[![License: MIT][license_badge]][license_link] + +A Dart library that allows Flutter apps to get information about code push updates. + +[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg +[license_link]: https://opensource.org/licenses/MIT + diff --git a/shorebird_code_push/analysis_options.yaml b/shorebird_code_push/analysis_options.yaml new file mode 100644 index 0000000..b388541 --- /dev/null +++ b/shorebird_code_push/analysis_options.yaml @@ -0,0 +1 @@ +include: package:very_good_analysis/analysis_options.5.0.0.yaml diff --git a/shorebird_code_push/coverage_badge.svg b/shorebird_code_push/coverage_badge.svg new file mode 100644 index 0000000..499e98c --- /dev/null +++ b/shorebird_code_push/coverage_badge.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + coverage + coverage + 100% + 100% + + diff --git a/shorebird_code_push/lib/shorebird_code_push.dart b/shorebird_code_push/lib/shorebird_code_push.dart new file mode 100644 index 0000000..6c84264 --- /dev/null +++ b/shorebird_code_push/lib/shorebird_code_push.dart @@ -0,0 +1,4 @@ +/// Get info about your Shorebird code push app +library shorebird_code_push; + +export 'src/shorebird_code_push.dart'; diff --git a/shorebird_code_push/lib/src/shorebird_code_push.dart b/shorebird_code_push/lib/src/shorebird_code_push.dart new file mode 100644 index 0000000..c63f09c --- /dev/null +++ b/shorebird_code_push/lib/src/shorebird_code_push.dart @@ -0,0 +1,7 @@ +/// {@template shorebird_code_push} +/// Get info about your Shorebird code push app +/// {@endtemplate} +class ShorebirdCodePush { + /// {@macro shorebird_code_push} + const ShorebirdCodePush(); +} diff --git a/shorebird_code_push/pubspec.yaml b/shorebird_code_push/pubspec.yaml new file mode 100644 index 0000000..4fb43b9 --- /dev/null +++ b/shorebird_code_push/pubspec.yaml @@ -0,0 +1,13 @@ +name: shorebird_code_push +description: Get info about your Shorebird code push app +version: 0.1.0+1 + +environment: + sdk: ">=3.0.0 <4.0.0" + +dev_dependencies: + ffigen: ^8.0.2 + mocktail: ^0.3.0 + test: ^1.19.2 + very_good_analysis: ^5.0.0 + diff --git a/shorebird_code_push/test/src/shorebird_code_push_test.dart b/shorebird_code_push/test/src/shorebird_code_push_test.dart new file mode 100644 index 0000000..6df0afb --- /dev/null +++ b/shorebird_code_push/test/src/shorebird_code_push_test.dart @@ -0,0 +1,11 @@ +// ignore_for_file: prefer_const_constructors +import 'package:test/test.dart'; +import 'package:shorebird_code_push/shorebird_code_push.dart'; + +void main() { + group('ShorebirdCodePush', () { + test('can be instantiated', () { + expect(ShorebirdCodePush(), isNotNull); + }); + }); +}