TetsuFe / flutter_novel

Flutter製のノベルゲーム
https://tetsufe.github.io/flutter_novel/#/
3 stars 1 forks source link

Chat test #30

Closed TetsuFe closed 4 years ago

TetsuFe commented 4 years ago

what

TetsuFe commented 4 years ago

色々と工夫してみたものの、CIがうまく動かない

CIでエラー

Running "flutter pub get" in flutter_novel...                       4.4s
Analyzing flutter_novel...                                      
No issues found! (ran in 15.1s)
Downloading Web SDK...                                              0.9s
/opt/hostedtoolcache/flutter/1.20.0-0.0.pre-dev/x64/packages/_flutter_web_build_script/lib/build_script.dart:9:8: Error: Error when reading '/b/s/w/ir/k/archive/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.39.8/lib/dart/analysis/results.dart': No such file or directory
import 'package:analyzer/dart/analysis/results.dart';
       ^
/opt/hostedtoolcache/flutter/1.20.0-0.0.pre-dev/x64/packages/_flutter_web_build_script/lib/build_script.dart:10:8: Error: Error when reading '/b/s/w/ir/k/archive/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.39.8/lib/dart/analysis/utilities.dart': No such file or directory
import 'package:analyzer/dart/analysis/utilities.dart';
       ^

issueを漁ったものの、特にこれといったものはヒットせず

1.20.0-1.0.preをfvmから入れると、良い感じになった

fvm flutter doctor
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel dev, 1.20.0-1.0.pre, on Mac OS X 10.15.5 19F101, locale ja-JP) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 11.5) [✓] Chrome - develop for the web [✓] Android Studio (version 3.6) [✓] VS Code (version 1.46.1) [✓] Connected device (2 available)

• No issues found!

1.20.0-1.0.preはpodfileの変更があったらしい https://twitter.com/_mono/status/1274488289097965568

Podfile破壊的変更されたのに多分1.20.0-1.0.preがReleaseに載ってないせいでCI/CDで1.20.0-0.0.preしかsetupできなくてpod installで落ちちゃう https://twitter.com/nukotsuka/status/1276009649922162688

ローカルでは問題ない

ローカルではwarningは出るものの、テストはできた

ローカルでpubspec.lockを更新した後、ローカルと同じバージョン1.20.0-0.0.preでCIを回してみた

結局、バージョン違いのせいではなかった・・

Running "flutter pub get" in flutter_novel...                       4.4s
Analyzing flutter_novel...                                      
No issues found! (ran in 18.3s)
Downloading Web SDK...                                              1.3s
/opt/hostedtoolcache/flutter/1.20.0-0.0.pre-dev/x64/packages/_flutter_web_build_script/lib/build_script.dart:9:8: Error: Error when reading '/b/s/w/ir/k/archive/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.39.8/lib/dart/analysis/results.dart': No such file or directory
import 'package:analyzer/dart/analysis/results.dart';

イマイチ、どのライブラリが影響を与えているのかもわからない

TetsuFe commented 4 years ago

CIエラーに関連? https://github.com/flutter/flutter/pull/60127

packages/flutter_tools/test/general.shard/web/chrome_test.dart https://github.com/flutter/flutter/pull/60127/files#diff-16f5e22503f1879255d999cf11c0f2c0

もしこれで治るとしたら、

https://github.com/flutter/flutter/commits/dev

に #60127 が取り込まれた後のdevではテストが成功するようになるはず。

現状、flutter acitonでは masterを使うことができないので、devが更新されるのを待つことにする。

TetsuFe commented 4 years ago

https://github.com/flutter/flutter/issues/55437#issuecomment-618182072 この記述をみつけたので、通常の flutter test と platform=chrome を両方行うことにし、platform=chrome の方では coverageを出さないようにしてみた

TetsuFe commented 4 years ago

結局ダメ

(前略)

00:00 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:01 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:02 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:03 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:04 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:05 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:06 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:07 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:08 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:09 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:10 +0: loading /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart                                                                                                                   
00:10 +0: /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart: StoryStateNotifier test                                                                                                  
00:10 +1: /home/runner/work/flutter_novel/flutter_novel/test/story_test.dart: StoryStateNotifier test                                                                                                  
/opt/hostedtoolcache/flutter/1.20.0-2.0.pre-dev/x64/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.0/lib/src/top_level.dart:1:8: Error: Not found: 'dart:html'
import 'dart:html';
       ^
/opt/hostedtoolcache/flutter/1.20.0-2.0.pre-dev/x64/.pub-cache/hosted/pub.dartlang.org/js-0.6.2/lib/js.dart:8:1: Error: Not found: 'dart:js'
export 'dart:js' show allowInterop, allowInteropCaptureThis;

(中略)

00:10 +1: loading /home/runner/work/flutter_novel/flutter_novel/test/chat_test.dart                                                                                                                    
00:11 +1: loading /home/runner/work/flutter_novel/flutter_novel/test/chat_test.dart                                                                                                                    
00:11 +1 -1: loading /home/runner/work/flutter_novel/flutter_novel/test/chat_test.dart [E]                                                                                                             
  Failed to load "/home/runner/work/flutter_novel/flutter_novel/test/chat_test.dart":
  Compilation failed
  Test: /home/runner/work/flutter_novel/flutter_novel/test/chat_test.dart
  Shell: /opt/hostedtoolcache/flutter/1.20.0-2.0.pre-dev/x64/bin/cache/artifacts/engine/linux-x64/flutter_tester

00:11 +1 -1: Some tests failed.                                                                                                                                                                        
##[error]Process completed with exit code 1.
TetsuFe commented 4 years ago

どうやら、今のところLinux系でのfirebaseライブラリは使えないっぽい https://github.com/FirebaseExtended/firebase-dart/issues/280

macOSではテストが実行できているので、macOSのCIを作れば良い?

TetsuFe commented 4 years ago

どうやら、今のところLinux系でのfirebaseライブラリは使えないっぽい FirebaseExtended/firebase-dart#280

macOSではテストが実行できているので、macOSのCIを作れば良い?

なぜかCIでは同じエラーが出てダメだった

TetsuFe commented 4 years ago

とりあえず、原因がわからないのでCIでのFirebase関連のテストはやらないことにする

TetsuFe commented 4 years ago

似たようなPRがFlutter公式pluginsリポジトリにもあったので、試してみた https://github.com/TetsuFe/flutter_novel/pull/30/commits/bc5ade472b8b39c466fa48eecdd8f7936c9b5043

https://github.com/flutter/plugins/pull/2307

追記: github actionのubuntuなどの環境ではもともとインストールされているので、やらなくていいらしい

TetsuFe commented 4 years ago

firebaseなどをpubspec.yamlに書いてmobile版をビルドする際に、dart:html系のエラーが出るらしい https://medium.com/multiverse-software/firebase-on-flutter-mobile-and-web-284812056c5c

TetsuFe commented 4 years ago

results.dartなどが見つからないエラーが出た。こちらによると、`flutter update-packages"を実行すると動くらしい? https://github.com/Dart-Code/Dart-Code/issues/2012

別のエラーがでた Downloading Web SDK... 1.1s

Unable to find modules for some sources, this is usually the result of either a bad import, a missing dependency in a package (or possibly a dev_dependency needs to move to a real dependency), or a build failure (if importing a generated file).

Please check the following imports:

import 'generated_plugin_registrant.dart'; from flutter_novel|lib/main_web_entrypoint.dart at 5:1

Failed after 45.5s Failed to compile tests

[error]Process completed with exit code 1.

TetsuFe commented 4 years ago

GitHub Actions でmacを使う https://docs.github.com/ja/actions/reference/virtual-environments-for-github-hosted-runners

手元のmacだとうまくいったので、これをもう一回試してみる(他の問題がある程度解決したため)

TetsuFe commented 4 years ago

web_entrypoint関連のエラーについては現在も対応中とのこと

https://github.com/flutter/flutter/issues/43538

TetsuFe commented 4 years ago

ちなみに、github actionsのmacOS、ubuntuイメージには、chromeはインストールされているらしい。 https://github.com/actions/virtual-environments/blob/ffa2110464ecda1cc62b477f29609525de24e570/images/macos/macos-10.15-Readme.md

TetsuFe commented 4 years ago

エラーの原因となっている lib/generated_plugin_registrant.dart は、自動生成されるらしい

//
// Generated file. Do not edit.
//

// ignore: unused_import
import 'dart:ui';

import 'package:url_launcher_web/url_launcher_web.dart';

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

// ignore: public_member_api_docs
void registerPlugins(PluginRegistry registry) {
  UrlLauncherPlugin.registerWith(registry.registrarFor(UrlLauncherPlugin));
  registry.registerMessageHandler();
}

どうやら、なんらかの理由で、このファイルの中身が手元のmac bookでビルドした場合とCIでビルドした場合で異なるらしい。

ちなみに、デフォルトの.gitignore では ignore対象となっている

# Web related
lib/generated_plugin_registrant.dart

手元のmac bookでビルドした場合とCIでビルドした場合で異ならないように、これを ignore対象としなければどうなるのか?試してみる。

c510009

結局これで解決した! 同じファイルをCIでも使うことで手元のPCと同じ環境になり、コンパイルが通ったみたい

codecov[bot] commented 4 years ago

Codecov Report

Merging #30 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #30   +/-   ##
=======================================
  Coverage   35.06%   35.06%           
=======================================
  Files           4        4           
  Lines          77       77           
=======================================
  Hits           27       27           
  Misses         50       50           
Impacted Files Coverage Δ
lib/story/models/story_state_notifier.dart 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0b31f68...b0e2af4. Read the comment docs.

TetsuFe commented 4 years ago

TODO: 別ブランチでコミットをまとめる

追記: #34 作成&マージ