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

[Template]: check-pr.yaml の pub-cache のキャッシュ処理を flutter-action に移行する #76

Open
macneko-ayu opened this issue Nov 7, 2024 · 0 comments

Comments

@macneko-ayu
Copy link
Contributor

macneko-ayu commented Nov 7, 2024

現状

pub-cache のキャッシュ処理を Cache dependencies step で実行しているが、${{ env.PUB_CACHE }} に相当する値が指定されていないように見受けられる`

https://github.com/yumemi-inc/flutter-training-template/blob/main/.github/templates/.github/workflows-templates/check-pr.yaml#L34-L45

      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: |
            ${{ env.PUB_CACHE }} # この行のenvが指定されていない
            ${{ github.workspace }}/.packages
            ${{ github.workspace }}/.flutter-plugins
            ${{ github.workspace }}/.flutter-plugin-dependencies
            ${{ github.workspace }}/.dart_tool/package_config.json
          key: build-pubspec-${{ hashFiles(format('{0}{1}', github.workspace, '/pubspec.lock')) }}
          restore-keys: |
            build-pubspec-

動機

flutter-action で pub-cache のキャッシュを行うようにして、Cache dependencies step の env の行を削除したい。

参考
https://github.com/subosito/flutter-action?tab=readme-ov-file#caching

提案

Setup flutter step に pub-cache-key を追加して、Cache dependencies step から

以下、参考。Action のバージョンは異なりますが、大きく影響はないはずです。
https://github.com/macneko-ayu/flutter-app-ci-cd-sample/blob/main/.github/workflows/check-pr.yaml#L24-L45

      # https://github.com/subosito/flutter-action
      - name: Setup flutter
        uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2.16.0
        with:
          flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
          channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
          cache: true
          cache-key: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}-${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
          pub-cache-key: "flutter-pub:os:-:channel:-:version:-:arch:-:hash:"

      # https://github.com/actions/cache
      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ${{ github.workspace }}/.packages
            ${{ github.workspace }}/.flutter-plugins
            ${{ github.workspace }}/.flutter-plugin-dependencies
            ${{ github.workspace }}/.dart_tool/package_config.json
          key: build-pubspec-${{ hashFiles(format('{0}{1}', github.workspace, '/pubspec.lock')) }}
          restore-keys: |
            build-pubspec-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant