Skip to content

Commit e039805

Browse files
authored
Large scale refactoring (#14)
* Update CI * Add example * Update launch.json and Makefile * Update Spinify implementation and deprecate old version * Refactor deprecated transport files * Refactor nested exception visitor in SpinifyException * Refactor health check and connection timers * Change transport * Refactor transport implementation and WebSocket connection - Refactor the transport implementation in Spinify to use the WebSocket interface. - Add a new method `_webSocketConnect` to handle WebSocket connection. - Remove the deprecated `web_socket_stub.dart` file. Closes #123 * Refactor transport implementation and WebSocket connection * Update version and dependencies in pubspec.yaml.g.dart * Add mockito * Refactor WebSocket connection and transport implementation * Refactor WebSocket connection and transport implementation * Add codec test * Refactor encoding benchmarks for protobuf commands * Refactor _doOnReady method to handle different Spinify connection states * Refactor _setState method to handle different Spinify connection states * Refactor SpinifyReplyException constructor to include error parameter * Add configuration file for issue templates * Refactor WebSocket$JS to use synchronous StreamController * Refactor SpinifyMetrics class to include getters for messagesSent and messagesReceived * Refactor SpinifyMetrics class to include getters for messagesSent and messagesReceived * Refactor SpinifyMetrics class to remove unused import * Refactor SpinifyMetrics class to remove unused import and include getters for messagesSent and messagesReceived Refactor WebSocket$JS to use synchronous StreamController * Refactor SpinifyMetrics class to include handleDone method for handling WebSocket disconnection * Add close codes * Added missing literal * Refactor SpinifyMetrics class to include handleDone method for handling WebSocket disconnection * Normalize disconnect code and reason in SpinifyDisconnectCode * Refactor error handling in Spinify connect method * Update tests * Normalize disconnect code and reason in SpinifyDisconnectCode * Add test for server subscriptions * Refactor SpinifyReplyResult mixin and add test for server subscriptions * Refactor Spinify connect method error handling * Refactor Makefile to generate coverage report for unit tests only * Refactor Spinify connect method to enforce channel validation * Refactor Spinify presence and presenceStats methods to handle subscription not found * Refactor Spinify.dart to use synchronous broadcasting for state and event controllers * Refactor Spinify.dart to remove unused code and add internal annotation * Refactor codec_test.dart to remove unused import * Refactor Pubspec.dart to update timestamp * Refactor Spinify.dart to use synchronous broadcasting for state and event controllers * Check ping - pong * Refactor Spinify.dart to start refresh connection timer and expect ping messages * Refactor exception.dart to add SpinifyRPCException * Refactor Spinify_test.dart to update exception types in client.send and client.rpc * Refactor Spinify.dart to handle subscription errors and prevent duplicate subscriptions * Refactor Spinify.dart to handle subscription removal and error handling * Refactor Spinify.dart to handle subscription removal and error handling * Refactor SpinifyProtobufReplyDecoder to handle error messages in Spinify.dart * Cover protobuf codec * Refactor SpinifyServerSubscription test to use a fake WebSocket and handle server subscription * Refactor SpinifyServerSubscription test to include additional assertions * Refactor Spinify.dart to handle subscription removal and error handling * Refactor Spinify.dart to handle subscription removal and error handling * Refactor Spinify.dart to handle subscription removal, error handling, and token refresh * Refactor Spinify.dart to handle invalid ping interval * Refactor WebSocket$Fake and Spinify to improve null safety and connection handling * Update .gitignore to exclude reports and .reports directories * Refactor Makefile to simplify build pipeline and add CI support * Refactor Spinify.dart to improve null safety, connection handling, and error handling * Refactor Spinify_test.dart to handle disconnection during connection * Refactor Spinify_test.dart to remove skipped test case * Refactor Spinify_test.dart to remove redundant try-catch block and improve disconnection handling * Refactor asyncGuarded function to add optional error ignoring capability * Refactor Spinify.dart to improve null safety, connection handling, and error handling * Refactor Spinify.dart to improve null safety, connection handling, and error handling * Refactor Spinify.dart to improve error handling and connection handling * Refactor unit tests and improve asyncGuarded error handling * Add utility functions for map and list equality checks; enhance equality and hashCode implementations in model classes * Add hasId property to SpinifyReply subclasses to indicate ID presence; enhance unit tests for reply instances * Implement Comparable for SpinifyStateBase and add comprehensive unit tests for state instances * Enhance unit tests for SpinifyState by adding comprehensive mapping checks for all state types * Add unit tests for SpinifyStatesStream to validate stream behavior for all state types * Add metric test * Add subscription test * Refactor guarded functions to remove debugger calls and add unit tests for utility functions * Add mutex benchmark for measuring performance of different mutex implementations * Refactor mutex benchmark to use different mutex implementations * Refactor mutex benchmark to use different mutex implementations * Refactor mutex benchmark to use different mutex implementations and add a new mutex implementation called _MutexEncapsulated * Refactor mutex benchmark to include new mutex implementation and remove commented code * Refactor mutex benchmark to use different mutex implementations and add new mutex implementation * Refactor mutex implementation to introduce _Mutex$Request class and update locking mechanisms * Add mutex lock for all spinify interactives methods * Add tests for multiple connections and closure behavior in spinify client * Refactor Spinify interface and exception handling; remove deprecated transport and enhance mutex release logic * Enhance mutex handling in Spinify close and removeSubscription methods; improve error handling and clean up test cases * Refactor mutex test cases to improve value handling and ensure correct locking behavior * Refactor value handling in util test cases to ensure correct order of operations during locking * Enhance disconnect method in Spinify to support forced disconnection; improve mutex handling and ensure all operations complete before disconnecting * Update tests * Enhance Spinify error handling during connection retries; improve test cases for temporary and permanent connection errors * Update Spinify tests to verify connection retry behavior and state transitions; adjust expected retry and disconnect metrics * Refactor Spinify subscriptions: remove unused server subscription test and update test imports; enhance ping timer management in spinify_test * Update test * Check server subscriptions * Enhance SpinifyChannelEvent: add copyWith method for channel modification; update event handling in _SpinifyClientSubscriptionImpl * Refactor Spinify subscription states: add toString methods for better debugging; enhance unsubscribe logic in Spinify and _SpinifyClientSubscriptionImpl * Disable echo server and smoke test at CI * Update GitHub Actions workflow: modify pub-cache environment variable and improve caching logic for dependencies * Update smoke tests
1 parent f91ea04 commit e039805

61 files changed

Lines changed: 10805 additions & 3613 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Questions & Help
4+
url: https://t.me/ru_dart
5+
about: Ask a question about Spinify

.github/workflows/checkout.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ name: Checkout
33
on:
44
workflow_dispatch:
55
push:
6+
branches:
7+
- "main"
8+
- "master"
9+
#- "dev"
10+
#- "develop"
11+
#- "feature/**"
12+
#- "bugfix/**"
13+
#- "hotfix/**"
14+
#- "support/**"
15+
paths:
16+
- "lib/**.dart"
17+
- "test/**.dart"
18+
- "example/**.dart"
19+
- ".github/workflows/*.yml"
20+
- "pubspec.yaml"
21+
- "analysis_options.yaml"
22+
pull_request:
623
branches:
724
- "main"
825
- "master"
@@ -16,8 +33,18 @@ on:
1633
- "lib/**.dart"
1734
- "test/**.dart"
1835
- "example/**.dart"
19-
- .github/workflows/*.yml
36+
- ".github/workflows/*.yml"
2037
- "pubspec.yaml"
38+
- "analysis_options.yaml"
39+
40+
permissions:
41+
contents: read
42+
actions: read
43+
checks: write
44+
45+
concurrency:
46+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
47+
cancel-in-progress: true
2148

2249
jobs:
2350
checkout:
@@ -29,7 +56,7 @@ jobs:
2956
container:
3057
image: dart:stable
3158
env:
32-
pub-cache-name: pub
59+
pub-cache: pub
3360
PUB_CACHE: /github/home/.pub-cache
3461
timeout-minutes: 10
3562
steps:
@@ -51,8 +78,8 @@ jobs:
5178
uses: actions/cache/restore@v4
5279
with:
5380
path: |
54-
${{ env.PUB_CACHE }}
55-
key: ${{ runner.os }}-spinify-${{ env.pub-cache-name }}-${{ hashFiles('pubspec.yaml') }}
81+
/home/runner/.pub-cache
82+
key: ${{ runner.os }}-pub-${{ env.pub-cache }}-${{ hashFiles('pubspec.yaml') }}
5683

5784
- name: 👷 Install Dependencies
5885
id: install-dependencies
@@ -63,16 +90,18 @@ jobs:
6390
6491
- name: 📥 Save Pub modules
6592
id: cache-pub-save
93+
if: steps.cache-pub-restore.outputs.cache-hit != 'true'
6694
uses: actions/cache/save@v4
6795
with:
6896
path: |
69-
${{ env.PUB_CACHE }}
70-
key: ${{ runner.os }}-spinify-${{ env.pub-cache-name }}-${{ hashFiles('pubspec.yaml') }}
97+
/home/runner/.pub-cache
98+
key: ${{ steps.cache-pub-restore.outputs.cache-primary-key }}
7199

72-
- name: 🔎 Check format
100+
- name: 🚦 Check code format
73101
id: check-format
74102
timeout-minutes: 1
75-
run: dart format --set-exit-if-changed -l 80 -o none lib/ test/
103+
run: |
104+
find lib test -name "*.dart" ! -name "*.*.dart" -print0 | xargs -0 dart format --set-exit-if-changed --line-length 80 -o none lib/ test/
76105
77106
- name: 📈 Check analyzer
78107
id: check-analyzer
@@ -99,5 +128,5 @@ jobs:
99128
timeout-minutes: 2
100129
run: |
101130
dart test --color --platform=vm --concurrency=12 \
102-
--timeout=60s --reporter=github --file-reporter=json:coverage/tests.json \
131+
--timeout=60s --reporter=github --file-reporter=json:reports/tests.json \
103132
--coverage=coverage -- test/unit_test.dart

.github/workflows/tests-report.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Tests Report"
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Tests"] # runs after "Tests" workflow
6+
types:
7+
- completed
8+
9+
permissions:
10+
contents: read
11+
actions: read
12+
checks: write
13+
14+
jobs:
15+
report:
16+
name: "🚛 Tests report"
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
steps:
20+
- name: Test report
21+
uses: dorny/test-reporter@v1
22+
with:
23+
artifact: test-results
24+
name: Test Report
25+
path: "**/tests.json"
26+
reporter: flutter-json
27+
fail-on-error: false

0 commit comments

Comments
 (0)