Skip to content

Commit

Permalink
fix: ci actions, docs and issues with requestTimeout configs
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingAleCR committed Jul 7, 2024
1 parent e098bfd commit ea4d546
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 95 deletions.
27 changes: 27 additions & 0 deletions .github/actions/setup-flutter/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Init Flutter"
description: "Initializes Flutter repo"
runs:
using: "composite"
steps:
- name: 📚 Checkout repository
uses: actions/checkout@v4

- name: 🐦 Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.2'
cache: true

- name: 📦 Get dependencies
shell: bash
run: cd packages/data && flutter pub get && cd ../.. && cd packages/domain && flutter pub get && cd ../.. && cd packages/environment && flutter pub get && cd ../.. && flutter pub get

- name: ☕️ Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: '17'
distribution: 'temurin'

- name: 🔎 Check Flutter environment
shell: bash
run: flutter doctor -v
9 changes: 6 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ name: Publish to pub.dev
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
workflow_dispatch:
- "[0-9]+.[0-9]+.[0-9]+*"

jobs:
publish:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_pub_publish.yml@v1
permissions:
id-token: write # Required for authentication using OIDC
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
# with:
# working-directory: path/to/package/within/repository
29 changes: 29 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: validate

on:
workflow_dispatch:
pull_request:
branches:
- main

jobs:
analyze:
runs-on: ubuntu-latest
steps:
- name: 📚 Checkout repository
uses: actions/checkout@v4

- name: 📦 Setup Flutter & Deps
uses: ./.github/actions/setup-flutter

- name: 📝 Format
run: dart format . --set-exit-if-changed

- name: 📊 Analyze
run: flutter analyze

- name: 🧪 Test
run: flutter test --coverage

- name: 🔎 Check Publish Warnings
run: pub publish --dry-run
161 changes: 84 additions & 77 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78

PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.11.3
COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 2 additions & 0 deletions example/lib/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class LoggerInterceptor extends InterceptorContract {
log('----- Request -----');
log(request.toString());
log(request.headers.toString());
log('Request type: ${request.runtimeType}');
return request;
}

Expand All @@ -19,6 +20,7 @@ class LoggerInterceptor extends InterceptorContract {
}) async {
log('----- Response -----');
log('Code: ${response.statusCode}');
log('Response type: ${response.runtimeType}');
if (response is Response) {
log((response).body);
}
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ dependencies:
sdk: flutter
http_interceptor:
path: ../
image_picker: ^0.8.9
shared_preferences: ^2.2.2
image_picker: ^1.1.2
shared_preferences: ^2.2.3

dev_dependencies:
flutter_lints: ^3.0.1
flutter_lints: ^4.0.0
flutter_test:
sdk: flutter

Expand Down
8 changes: 4 additions & 4 deletions guides/migration_guide_2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ v2.0.0 and up
```dart
class WeatherApiInterceptor extends InterceptorContract {
@override
Future<BaseRequest> interceptRequest({required BaseRequest request}) async {
FutureOr<BaseRequest> interceptRequest({required BaseRequest request}) async {
final cache = await SharedPreferences.getInstance();
final Map<String, String>? headers = Map.from(request.headers);
Expand All @@ -55,7 +55,7 @@ class WeatherApiInterceptor extends InterceptorContract {
}
@override
Future<BaseResponse> interceptResponse(
FutureOr<BaseResponse> interceptResponse(
{required BaseResponse response}) async =>
response;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ v2.0.0 and up
class ExpiredTokenRetryPolicy extends RetryPolicy {
@override
Future<bool> shouldAttemptRetryOnResponse(BaseResponse response) async {
FutureOr<bool> shouldAttemptRetryOnResponse(BaseResponse response) async {
if (response.statusCode == 401) {
log("Retrying request...");
final cache = await SharedPreferences.getInstance();
Expand All @@ -111,7 +111,7 @@ If you are using `shouldAttemptRetryOnException` then you will also have to conv

```dart
@override
Future<bool> shouldAttemptRetryOnException(
FutureOr<bool> shouldAttemptRetryOnException(
Exception reason,
BaseRequest request,
) async {
Expand Down
2 changes: 1 addition & 1 deletion lib/http/intercepted_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class InterceptedClient extends BaseClient {
final List<InterceptorContract> interceptors;

/// Maximum duration of a request.
final Duration? requestTimeout;
Duration? requestTimeout;

/// Request timeout handler
TimeoutCallback? onRequestTimeout;
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ environment:
sdk: ">=3.0.3 <4.0.0"

dependencies:
http: ^1.1.0
http: ^1.2.1

dev_dependencies:
lints: ^3.0.0
test: ^1.25.2
lints: ^4.0.0
test: ^1.25.8

0 comments on commit ea4d546

Please sign in to comment.