Skip to content

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

@macneko-ayu

Description

@macneko-ayu

現状

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-

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions