Skip to content

Commit

Permalink
ci: setup checks and tests workflows (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoEllet authored Dec 14, 2024
1 parent 5df2e0d commit 7753b20
Show file tree
Hide file tree
Showing 62 changed files with 1,472 additions and 1,093 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: ✅ Code Quality Checks

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
checks:
name: 🔍 Code Quality and Formatting Verification
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4

- name: 🛠️ Setup Flutter (Stable)
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true

- name: 📦 Install All Package Dependencies
run: dart ./scripts/pub_get.dart

- name: 📦 Install Example Project Dependencies
run: flutter pub get -C quill_native_bridge/example

- name: 🎨 Perform Flutter Analysis
run: flutter analyze --write=flutter_analyze.log

- if: ${{ !cancelled() }}
uses: yorifuji/flutter-analyze-commenter@v1
with:
analyze-log: flutter_analyze.log
verbose: false

- name: 🔎 Validate Dart Code Formatting
run: dart format --set-exit-if-changed .

- name: 🔄 Preview Potential Dart Fixes
run: dart fix --dry-run

- name: 📦 Verify Package Readiness for Publishing
run: dart ./scripts/publish_dry_run.dart

# Ktlint: https://github.com/pinterest/ktlint
- name: 🎨 Verify Kotlin Code Style with Ktlint
uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
fail_on_error: true
89 changes: 0 additions & 89 deletions .github/workflows/main.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/swift-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: ✅ Swift Formatting Check

# Separated from checks.yml since it takes longer to build swift-format from source
on:
push:
branches: [main]
paths:
- quill_native_bridge_ios/ios/quill_native_bridge_ios/**/*.swift
- quill_native_bridge_macos/macos/quill_native_bridge_macos/**/*.swift
- .github/workflows/swift-format-check.yml
pull_request:
paths:
- quill_native_bridge_ios/ios/quill_native_bridge_ios/**/*.swift
- quill_native_bridge_macos/macos/quill_native_bridge_macos/**/*.swift
- .github/workflows/swift-format-check.yml

jobs:
format-check:
runs-on: ubuntu-latest
timeout-minutes: 10

env:
SWIFT_FORMAT_VERSION: 600.0.0

steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4

- name: 🛠️ Setup Swift
uses: swift-actions/setup-swift@v2

- name: 📦 Install Swift Format
run: |
git clone --branch $SWIFT_FORMAT_VERSION --depth 1 https://github.com/swiftlang/swift-format.git
cd swift-format
swift build -c release
sudo mv .build/release/swift-format /usr/local/bin/
- name: 🔍 Verify Swift Format installation
run: swift-format --version

- name: ℹ️ Print the default configuration
run: swift-format dump-configuration

- name: 🔎 Validate Swift Code Formatting
run: |
swift-format lint -r quill_native_bridge_ios/ios/quill_native_bridge_ios --strict
swift-format lint -r quill_native_bridge_macos/macos/quill_native_bridge_macos --strict
# SwiftLint: https://github.com/realm/SwiftLint
# - name: 🎨 Verify Swift Code Style with SwiftLint
# uses: norio-nomura/[email protected]
58 changes: 58 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 🧪 Run Tests

on:
pull_request:
branches: [main]

jobs:
desktop-tests:
name: 🖥️ Desktop Tests (${{ matrix.os }} Latest)
strategy:
# This prevents one failure from stopping the entire run.
fail-fast: false
# TODO: Restore windows, run Android and iOS unit tests, cache swift-format
matrix:
os: [ubuntu, macos]
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 30

steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4

- name: 🛠️ Setup Flutter (Stable)
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true

- name: 📦 Install all package dependencies
run: dart ./scripts/pub_get.dart

- name: 📦 Install example dependencies
run: flutter pub get -C quill_native_bridge/example

- name: 🧩 Run Flutter unit tests
run: dart ./scripts/test.dart
timeout-minutes: 5

- name: 📦 Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev
# For more details: https://docs.flutter.dev/testing/integration-tests#test-on-a-desktop-platform

- name: 🧪 Run Flutter integration tests on Linux
if: runner.os == 'Linux'
uses: smithki/[email protected]
with:
run: flutter test integration_test -d linux -r github
working-directory: quill_native_bridge/example

- name: 🧪 Run Flutter integration tests on Non-Linux platforms
if: runner.os != 'Linux'
run: flutter test integration_test -d ${{ runner.os }}
working-directory: quill_native_bridge/example
26 changes: 26 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include: package:flutter_lints/flutter.yaml

analyzer:
exclude:
# Ignore generated files
- '**/*.g.dart'
- '**/*.mocks.dart' # Mockito @GenerateMocks (https://pub.dev/packages/mockito)

linter:
rules:
- always_declare_return_types
- avoid_escaping_inner_quotes
- avoid_print
- avoid_void_async
- directives_ordering
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
- prefer_relative_imports
- prefer_single_quotes
- unnecessary_parenthesis
- avoid_web_libraries_in_flutter
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- avoid_slow_async_io
10 changes: 10 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: quill_native_bridge_workspace
publish_to: 'none'

environment:
sdk: '>=3.0.0 <4.0.0'

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
31 changes: 0 additions & 31 deletions quill_native_bridge/analysis_options.yaml

This file was deleted.

29 changes: 0 additions & 29 deletions quill_native_bridge/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
include: package:flutter_lints/flutter.yaml

linter:
rules:
always_declare_return_types: true
always_put_required_named_parameters_first: true
annotate_overrides: true
avoid_empty_else: true
avoid_escaping_inner_quotes: true
avoid_print: true
avoid_types_on_closure_parameters: true
avoid_void_async: true
directives_ordering: true
omit_local_variable_types: true
prefer_const_constructors: true
prefer_const_constructors_in_immutables: true
prefer_const_declarations: true
prefer_final_fields: true
prefer_final_in_for_each: true
prefer_final_locals: true
prefer_initializing_formals: true
prefer_int_literals: true
prefer_interpolation_to_compose_strings: true
prefer_relative_imports: true
prefer_single_quotes: true
sort_constructors_first: true
sort_unnamed_constructors_first: true
unnecessary_lambdas: true
unnecessary_parenthesis: true
unnecessary_string_interpolations: true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package dev.flutterquill.quill_native_bridge_example

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity()
class MainActivity : FlutterActivity()
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

// TODO: Write tests for copying other image formats (jpeg, webp, png etc...)
// TODO: Improve the integration tests

// TODO: Fix the integration tests failing on Windows: https://github.com/FlutterQuill/quill-native-bridge/actions/runs/12323723239/job/34399916127?pr=10
if (defaultTargetPlatform == TargetPlatform.windows) {
test('no op', () {});
return;
}

group('getClipboardImage and copyImageToClipboard', () {
test('copying images to the clipboard should make them accessible',
() async {
Expand Down
Loading

0 comments on commit 7753b20

Please sign in to comment.