-
Notifications
You must be signed in to change notification settings - Fork 6
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
[GH-224] GitHub Actions でキャッシュを利用するよう改善 #239
Conversation
Visit the preview URL for this PR (updated for commit 96db918): https://flutter-mobile-project-template-catalog--pr239-feature-es9trved.web.app (expires Wed, 12 Jun 2024 10:04:29 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 9ea56735a63d07a7cfe62eb204b0528284c37c23 |
.github/workflows/wc-changes.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
変更箇所の検出で check-pr が肥大化しそうだったので workflow_call で分割しています.(この内容だったら job を並列で走らせたりしていないので action でも良かったかもです…)
今後 push イベントなど他のものでも使いやすいようになったかなと思います
cache-dependencies: | ||
runs-on: ubuntu-22.04 | ||
needs: changes | ||
if: ${{ needs.changes.outputs.dependencies == 'true' }} | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
# https://github.com/marketplace/actions/checkout | ||
- name: Checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
|
||
- name: Setup Application Runtime | ||
uses: ./.github/actions/setup-application-runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
キャッシュがない場合を考慮して,一旦ここで一通りのセットアップ処理を実行します.
これにより,後続の処理では必ずキャッシュが復元されて高速化されます.
@@ -8,51 +8,45 @@ concurrency: | |||
cancel-in-progress: true | |||
|
|||
jobs: | |||
pre-check: | |||
changes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
わかりやすそうな名前に変更しています
# https://github.com/actions/cache | ||
- name: cache pub | ||
id: cache | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
env: | ||
cache-name: pub | ||
with: | ||
# pub-cache files are stored in `~/.pub-cache` on Linux/macOS | ||
path: ~/.pub-cache | ||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pubspec.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pubspec.lock') }} | ||
${{ runner.os }}-${{ env.cache-name }}- | ||
${{ runner.os }}- | ||
|
||
- name: Path pub-cache | ||
shell: bash | ||
run: echo "$HOME/.pub-cache/bin" >> "$GITHUB_PATH" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subosito/flutter-action が同等のキャッシュをしていることに気づいたため,独自のキャッシュ処理を削除しています.
ワークフロー実行時のログ
https://github.com/yumemi-inc/flutter-mobile-project-template/actions/runs/9378814404/job/25822833262#step:3:70
Ready for review 🚀 |
.github/workflows/wc-check-diff.yaml
Outdated
# https://github.com/actions/cache | ||
- name: Cache build runner | ||
id: cache-build-runner | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
env: | ||
cache-name: build-runner | ||
with: | ||
path: | | ||
**/.dart_tool/build | ||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/asset_graph.json') }}-${{ hashFiles('**/pubspec.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/asset_graph.json') }}-${{ hashFiles('**/pubspec.lock') }} | ||
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/pubspec.lock') }} | ||
${{ runner.os }}-${{ env.cache-name }}- | ||
${{ runner.os }}- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#240 の内容を近しい場所で記載しています
Ready for review 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
コード生成のところちょっと不安だったので失敗する場合を試しましたが、大丈夫そうでした 👍
https://github.com/yumemi-inc/flutter-mobile-project-template/actions/runs/9393478411
概要
GitHub Actions でキャッシュを利用するよう改善します.
レビュー観点
レビューレベル
レビュー優先度
画像 / 動画
改善前
https://github.com/yumemi-inc/flutter-mobile-project-template/actions/runs/9378775404
改善後
独自で actions/cache を併用した場合
改善後( cache-dependencies で初回キャッシュ有り)
https://github.com/yumemi-inc/flutter-mobile-project-template/actions/runs/9378814404/attempts/1
改善後( cache-dependencies でキャッシュ復元)
https://github.com/yumemi-inc/flutter-mobile-project-template/actions/runs/9378814404
動作確認手順
備考