diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..29645bd --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,108 @@ +name: CI & CD + +on: + workflow_dispatch: + + push: + branches: [develop, main] + tags: + - "v[0-9]+.[0-9]+.[0-9]+*" + + pull_request: + branches: [develop, main] + +# This ensures that previous jobs for the PR are canceled when PR is updated +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build package & run tests + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 # Use shallow clone for faster checkout + + - name: Check broken links + uses: JustinBeckwith/linkinator-action@v1 + with: + paths: "**/*.md" + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + architecture: x64 + cache: true + + - name: Install dependencies + run: dart pub get + + - name: Format code + run: dart format --set-exit-if-changed . + + - name: Analyze static code + run: dart analyze + + - name: Run tests + run: flutter test --no-pub --coverage + + - name: Check publish warnings + run: dart pub publish --dry-run + + example: + name: Build example app + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 # Use shallow clone for faster checkout + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + architecture: x64 + cache: true + + - name: Install dependencies + run: dart pub get + + - name: Build example + run: flutter build appbundle --debug + working-directory: example + + deployment: + if: ${{ github.ref_type == 'tag' }} + needs: [build, example] + name: Deploy package + permissions: + id-token: write + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 # Use shallow clone for faster checkout + + - name: Set up Dart + uses: dart-lang/setup-dart@v1 + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + architecture: x64 + cache: true + + - name: Install dependencies + run: dart pub get + + - name: Publish package + run: dart pub publish -v -f diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 0d29021..914b0ca 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -1,28 +1,15 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. include: package:flutter_lints/flutter.yaml +analyzer: + errors: + missing_required_param: error + missing_return: error + todo: ignore linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at https://dart.dev/lints. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options + one_member_abstracts: false + prefer_relative_imports: true + always_use_package_imports: false + omit_local_variable_types: false + directives_ordering: true + \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 4b1a9c6..47d2c62 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,9 +1,10 @@ import 'dart:typed_data'; -import 'package:example/sample_animation.dart'; import 'package:flutter/material.dart'; import 'package:screen_recorder/screen_recorder.dart'; +import 'sample_animation.dart'; + void main() { runApp(const MyApp()); } diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index a19dabb..f3c1285 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -5,11 +5,10 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. +import 'package:example/main.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:example/main.dart'; - void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame.