Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR の解析・テストを行うワークフロー追加 #37

Merged
merged 8 commits into from
Jan 10, 2024
52 changes: 52 additions & 0 deletions .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: check-pr

on:
pull_request:

jobs:
check:
runs-on: ubuntu-22.04

timeout-minutes: 10

steps:
# https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v4

# https://github.com/kuhnroyal/flutter-fvm-config-action
- name: Fetch flutter config
uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action

# https://github.com/subosito/flutter-action
- name: Setup flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}

- name: Setup melos
run: |
ln -s $FLUTTER_ROOT .fvm/flutter_sdk
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

melos.yaml で指定しているため必要

dart pub global activate melos
melos bootstrap

# https://github.com/invertase/github-action-dart-analyzer
- name: Report analyze
uses: invertase/github-action-dart-analyzer@v2.0.0
with:
fatal-infos: true
blendthink marked this conversation as resolved.
Show resolved Hide resolved

- name: Run test
run: melos run report_test --no-select
continue-on-error: true

# https://github.com/dorny/test-reporter
- name: Report test
uses: dorny/test-reporter@v1
with:
name: 'flutter test'
path: '(apps|packages/cores|packages/features)/*/test_report.log'
reporter: 'flutter-json'
fail-on-error: 'true'
11 changes: 11 additions & 0 deletions .idea/runConfigurations/melos_run_test.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions apps/app/build.yml → apps/app/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ targets:
# https://github.com/dart-lang/build/blob/master/docs/faq.md#how-do-i-avoid-running-builders-on-unnecessary-inputs
generate_for:
include:
- lib/model/*.dart
- lib/**/model/*.dart
- lib/{model,**/model}/**.dart
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/model などが必要かどうかは微妙?
マルチパッケージにするなら直下に生えることはあるかも、とは思った

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここどうするかは悩ましいですが、いったんこのままでいいかなと思いました、、!
(というか、このような中括弧をつかった書き方ができるのですね)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中で https://pub.dev/packages/glob を使ってるみたいで、このページ参考にしました!

# https://github.com/google/json_serializable.dart/tree/master/json_serializable#build-configuration
json_serializable:
generate_for:
include:
- lib/model/*.dart
- lib/**/model/*.dart
- lib/{model,**/model}/**.dart
options:
field_rename: snake
# json のデシリアライズ時に発生する Exception を CheckedFromJsonException にまとめる
checked: true
riverpod_generator:
generate_for:
include:
- lib/**/provider/*.dart
- lib/{provider,**/provider}/**.dart
# https://github.com/dart-lang/source_gen#ignore_for_file
source_gen:combining_builder:
options:
Expand Down
2 changes: 2 additions & 0 deletions apps/app/lib/data/provider/api/repository_api.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/app/lib/data/provider/dio.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/app/lib/data/provider/github_access_token.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions apps/app/lib/domain/model/github_repository.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ command:
dev_dependencies:
yumemi_lints: ^1.3.0

scripts:
report_test:
exec: flutter test --no-pub --machine > test_report.log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo-badge

--machine オプションで json 形式で標準出力する。

気になる点

flutter test --help で表示されるオプションに --machine オプションが記載されていない。
その一方で、 --reporter というオプションでテスト結果の出力形式を json に指定できる模様。
ただし、--machine--reporter オプションで出力される内容に差異がありそう。

-r, --reporter                                               Set how to print test results. If unset, value will default to either compact or expanded.

          [compact]                                          A single line that updates dynamically (The default reporter).
          [expanded]                                         A separate line for each update. May be preferred when logging to a file or in continuous integration.
          [github]                                           A custom reporter for GitHub Actions (the default reporter when running on GitHub Actions).
          [json]                                             A machine-readable format. See: https://dart.dev/go/test-docs/json_reporter.md

packageFilters:
flutter: true

ide:
intellij:
# Disabling IntelliJ's automatic configuration.
Expand Down
Loading