github actionsのCIを追加 #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: flutter_test | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
push: | |
branches: | |
- main | |
jobs: | |
flutter_test: | |
runs-on: ubuntu-latest | |
# timeout-minutesのデフォルト値は6時間 | |
# タイムアウトを設定しないと処理が終わらないまま放置され、莫大な請求額になるため短めに設定する | |
timeout-minutes: 10 | |
steps: | |
# ソースコードをチェックアウト | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# fvm のバージョンとチャネルを環境変数に設定する | |
- name: Check fvm | |
uses: kuhnroyal/flutter-fvm-config-action@v1 | |
# Flutter SDK の設定 | |
- name: Setup Flutter SDK | |
uses: subosito/flutter-action@v2 | |
with: | |
# バージョンとチャネルは fvm の値を使う | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
channel: ${{ env.FLUTTER_CHANNEL }} | |
# 次回以降起動を速くするためにキャッシュしておく | |
cache: true | |
cache-key: flutter | |
cache-path: ${{ runner.tool_cache }}/flutter | |
# /opt/hostedtoolcache/flutter | |
# melosの設定 | |
# デフォルトでmelos bootstrapコマンドが実行される | |
- name: Setup melos | |
uses: bluefireteam/melos-action@v1 | |
with: | |
run-bootstrap: false | |
# melos bootstrap | |
- name: melos bootstrap | |
run: melos bootstrap --sdk-path=${{ runner.tool_cache }}/flutter | |
# 依存関係を解決 | |
- name: Install Flutter dependencies by melos | |
run: melos pg --sdk-path=${{ runner.tool_cache }}/flutter | |
# テストを実行 | |
- name: Run Flutter Test by melos | |
run: melos exec --sdk-path=${{ runner.tool_cache }}/flutter -- "flutter test --machine --coverage > test-report.log" | |
# file path 確認用コマンド | |
- name: pwd | |
run: pwd | |
# fileが存在するか確認 | |
- name: ls -a | |
run: ls -a | |
# # flutter pub get を実行 | |
# - name: Install Flutter dependencies | |
# run: flutter pub get | |
# # テストを実行 | |
# # あとでテスト結果を GitHub Actions 上に表示するので log に出力する | |
# # あとでカバレッジ結果をCodecovに送信するのでカバレッジありで実行する | |
# - name: Run Flutter Test | |
# run: flutter test --machine --coverage > test-report.log | |
# テスト結果を GitHub Actions に表示する | |
- name: Report Test | |
uses: dorny/test-reporter@v1 | |
# テスト結果を表示するのでテストが失敗しても実行する | |
if: always() | |
with: | |
name: Flutter Test Report | |
path: /home/runner/work/mottai-flutter-app/mottai-flutter-app/test-report.log | |
reporter: flutter-json | |
# Codecov に結果を送信 | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v2 | |
with: | |
token: ${{secrets.CODECOV_TOKEN}} | |
file: coverage/lcov.info | |
fail_ci_if_error: true | |
flags: unittests | |
verbose: true |