Skip to content

Commit

Permalink
Enable GitHub action (#216)
Browse files Browse the repository at this point in the history
* github acions with mono_repo

* fail test

* cleanup

* badge

* regenerate

* regenerate

* format

* fix analyzer

* fix analyzer

* fix test

* regenerate

* cleanup badge

* Naming fix

* remove dev chanel

* ignore vscode

* revert readme change

* remove travis

* format

* fix

* fix

* format

* fix tests

Co-authored-by: Ivan Terekhin <[email protected]>
  • Loading branch information
lejard-h and JEuler authored Mar 22, 2021
1 parent 84d1892 commit 6309368
Show file tree
Hide file tree
Showing 21 changed files with 380 additions and 176 deletions.
160 changes: 160 additions & 0 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Created with package:mono_repo v3.4.7
name: Dart CI
on:
push:
branches:
- master
- develop
- github-action
pull_request:
branches:
- master
- develop
defaults:
run:
shell: bash
env:
PUB_ENVIRONMENT: bot.github

jobs:
job_001:
name: mono_repo self validate
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@v2
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;dart:stable"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- uses: dart-lang/[email protected]
with:
sdk: stable
- id: checkout
uses: actions/checkout@v2
- name: mono_repo self validate
run: pub global activate mono_repo 3.4.7
- name: mono_repo self validate
run: pub global run mono_repo generate --validate
job_002:
name: "analyzer_and_format; PKGS: chopper, chopper_built_value, chopper_generator; `dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos .`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@v2
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;dart:stable;packages:chopper-chopper_built_value-chopper_generator;commands:dartfmt-dartanalyzer"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;dart:stable;packages:chopper-chopper_built_value-chopper_generator
os:ubuntu-latest;pub-cache-hosted;dart:stable
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- uses: dart-lang/[email protected]
with:
sdk: stable
- id: checkout
uses: actions/checkout@v2
- id: chopper_pub_upgrade
name: "chopper; pub upgrade --no-precompile"
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper
run: pub upgrade --no-precompile
- name: "chopper; dartfmt -n --set-exit-if-changed ."
if: "always() && steps.chopper_pub_upgrade.conclusion == 'success'"
working-directory: chopper
run: dartfmt -n --set-exit-if-changed .
- name: "chopper; dartanalyzer --fatal-infos ."
if: "always() && steps.chopper_pub_upgrade.conclusion == 'success'"
working-directory: chopper
run: dartanalyzer --fatal-infos .
- id: chopper_built_value_pub_upgrade
name: "chopper_built_value; pub upgrade --no-precompile"
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper_built_value
run: pub upgrade --no-precompile
- name: "chopper_built_value; dartfmt -n --set-exit-if-changed ."
if: "always() && steps.chopper_built_value_pub_upgrade.conclusion == 'success'"
working-directory: chopper_built_value
run: dartfmt -n --set-exit-if-changed .
- name: "chopper_built_value; dartanalyzer --fatal-infos ."
if: "always() && steps.chopper_built_value_pub_upgrade.conclusion == 'success'"
working-directory: chopper_built_value
run: dartanalyzer --fatal-infos .
- id: chopper_generator_pub_upgrade
name: "chopper_generator; pub upgrade --no-precompile"
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper_generator
run: pub upgrade --no-precompile
- name: "chopper_generator; dartfmt -n --set-exit-if-changed ."
if: "always() && steps.chopper_generator_pub_upgrade.conclusion == 'success'"
working-directory: chopper_generator
run: dartfmt -n --set-exit-if-changed .
- name: "chopper_generator; dartanalyzer --fatal-infos ."
if: "always() && steps.chopper_generator_pub_upgrade.conclusion == 'success'"
working-directory: chopper_generator
run: dartanalyzer --fatal-infos .
job_003:
name: "unit_test; PKG: chopper; `pub run test`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@v2
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;dart:stable;packages:chopper;commands:test_0"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;dart:stable;packages:chopper
os:ubuntu-latest;pub-cache-hosted;dart:stable
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- uses: dart-lang/[email protected]
with:
sdk: stable
- id: checkout
uses: actions/checkout@v2
- id: chopper_pub_upgrade
name: "chopper; pub upgrade --no-precompile"
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper
run: pub upgrade --no-precompile
- name: chopper; pub run test
if: "always() && steps.chopper_pub_upgrade.conclusion == 'success'"
working-directory: chopper
run: pub run test
needs:
- job_001
- job_002
job_004:
name: "unit_test; PKG: chopper; `pub run test -p chrome`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@v2
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;dart:stable;packages:chopper;commands:test_1"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;dart:stable;packages:chopper
os:ubuntu-latest;pub-cache-hosted;dart:stable
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- uses: dart-lang/[email protected]
with:
sdk: stable
- id: checkout
uses: actions/checkout@v2
- id: chopper_pub_upgrade
name: "chopper; pub upgrade --no-precompile"
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: chopper
run: pub upgrade --no-precompile
- name: "chopper; pub run test -p chrome"
if: "always() && steps.chopper_pub_upgrade.conclusion == 'success'"
working-directory: chopper
run: pub run test -p chrome
needs:
- job_001
- job_002
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ doc/api/
.idea/
.test_coverage.dart
coverage
chopper/doc/
chopper/doc/
.vscode/
62 changes: 0 additions & 62 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

# Chopper

[![pub package](https://img.shields.io/pub/v/chopper.svg)](https://pub.dartlang.org/packages/chopper) [![Build Status](https://travis-ci.com/lejard-h/chopper.svg?branch=master)](https://travis-ci.com/lejard-h/chopper.svg?branch=master) [![codecov](https://codecov.io/gh/lejard-h/chopper/branch/master/graph/badge.svg)](https://codecov.io/gh/lejard-h/chopper)
[![pub package](https://img.shields.io/pub/v/chopper.svg)](https://pub.dartlang.org/packages/chopper)
[![Dart CI](https://github.com/lejard-h/chopper/workflows/Dart%20CI/badge.svg)](https://github.com/lejard-h/chopper/actions?query=workflow%3A%22Dart+CI%22)
[![codecov](https://codecov.io/gh/lejard-h/chopper/branch/master/graph/badge.svg)](https://codecov.io/gh/lejard-h/chopper)

Chopper is an http client generator for Dart and Flutter using source_gen and inspired by Retrofit.

Expand All @@ -25,4 +27,3 @@ Please refer to the installation guide at [pub.dev](https://pub.dev/packages/cho
* [Angular](https://github.com/lejard-h/chopper/blob/master/example/web/main.dart)

## [Issue Tracker](https://github.com/lejard-h/chopper/issues)

5 changes: 4 additions & 1 deletion chopper/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Chopper

[![pub package](https://img.shields.io/pub/v/chopper.svg)](https://pub.dartlang.org/packages/chopper) [![Build Status](https://travis-ci.com/lejard-h/chopper.svg?branch=master)](https://travis-ci.org/lejard-h/chopper) [![codecov](https://codecov.io/gh/lejard-h/chopper/branch/master/graph/badge.svg)](https://codecov.io/gh/lejard-h/chopper)
[![pub package](https://img.shields.io/pub/v/chopper.svg)](https://pub.dartlang.org/packages/chopper)
[![Dart CI](https://github.com/lejard-h/chopper/workflows/Dart%20CI/badge.svg)](https://github.com/lejard-h/chopper/actions?query=workflow%3A%22Dart+CI%22)
[![codecov](https://codecov.io/gh/lejard-h/chopper/branch/master/graph/badge.svg)](https://codecov.io/gh/lejard-h/chopper)


Chopper is an http client generator for Dart and Flutter using source_gen and inspired by Retrofit.

Expand Down
2 changes: 1 addition & 1 deletion chopper/lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class ChopperClient {
Map<String, String> headers = const {},
Map<String, dynamic>? parameters,
String? baseUrl,
dynamic? body
dynamic? body,
}) =>
send<BodyType, InnerType>(
Request(
Expand Down
2 changes: 0 additions & 2 deletions chopper/lib/src/interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ abstract class RequestInterceptor {
/// See [JsonConverter] and [FormUrlEncodedConverter] for example implementations.
@immutable
abstract class Converter {

/// Converts the received [Request] to a [Request] which has a body with the
/// HTTP representation of the original body.
FutureOr<Request> convertRequest(Request request);
Expand All @@ -96,7 +95,6 @@ abstract class Converter {
/// An `ErrorConverter` is called only on error responses
/// (statusCode < 200 || statusCode >= 300) and before any [ResponseInterceptor]s.
abstract class ErrorConverter {

/// Converts the received [Response] to a [Response] which has a body with the
/// HTTP representation of the original body.
FutureOr<Response> convertError<BodyType, InnerType>(Response response);
Expand Down
15 changes: 15 additions & 0 deletions chopper/mono_pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dart:
- stable

stages:
- analyzer_and_format:
- group:
- dartfmt
- dartanalyzer: --fatal-infos .
- unit_test:
- test:
- test: -p chrome

cache:
directories:
- .dart_tool/build
3 changes: 1 addition & 2 deletions chopper/test/base_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ void main() {
final chopper = buildClient(httpClient);
final service = chopper.getService<HttpTestService>();

final response =
await service.getBody('get body');
final response = await service.getBody('get body');

expect(response.body, equals('get response'));
expect(response.statusCode, equals(200));
Expand Down
6 changes: 3 additions & 3 deletions chopper/test/converter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ void main() {
test('base decode', () async {
final converter = TestConverter();

final decoded = await converter
.convertResponse<_Converted<String>, _Converted<String>>(
final decoded =
converter.convertResponse<_Converted<String>, _Converted<String>>(
Response<String>(http.Response('', 200), 'foo'),
);

Expand All @@ -32,7 +32,7 @@ void main() {
test('base encode', () async {
final converter = TestConverter();

final encoded = await converter.convertRequest(
final encoded = converter.convertRequest(
Request('GET', '/', baseUrl, body: _Converted<String>('foo')),
);

Expand Down
2 changes: 1 addition & 1 deletion chopper/test/interceptors_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void main() {
expect(
log,
equals(
"curl -v -X POST -H 'foo: bar' -H 'content-type: text/plain; charset=utf-8' -d 'test' base/",
"curl -v -X POST -H 'foo: bar' -H 'content-type: text/plain; charset=utf-8' -d 'test' \"base/\"",
),
);
});
Expand Down
12 changes: 12 additions & 0 deletions chopper_built_value/mono_pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dart:
- stable

stages:
- analyzer_and_format:
- group:
- dartfmt
- dartanalyzer: --fatal-infos .

cache:
directories:
- .dart_tool/build
1 change: 1 addition & 0 deletions chopper_built_value/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ dev_dependencies:

dependency_overrides:
analyzer: 1.1.0
#Comment before publish
chopper:
path: ../chopper
Loading

0 comments on commit 6309368

Please sign in to comment.