From 1014b1eb076c61d44d31ea574525775bd2cf326b Mon Sep 17 00:00:00 2001 From: Quoc Huynh Date: Tue, 26 Nov 2024 12:14:29 +0100 Subject: [PATCH] Optimize workflows --- .github/workflows/native_image_cropper.yaml | 32 ++++++++++------- .../native_image_cropper_android.yaml | 34 ++++++++++++------- .../workflows/native_image_cropper_ios.yaml | 34 ++++++++++++------- .../workflows/native_image_cropper_macos.yaml | 34 ++++++++++++------- ...tive_image_cropper_platform_interface.yaml | 34 ++++++++++++------- .../workflows/native_image_cropper_web.yaml | 31 +++++++++++------ 6 files changed, 129 insertions(+), 70 deletions(-) diff --git a/.github/workflows/native_image_cropper.yaml b/.github/workflows/native_image_cropper.yaml index 175ea16..af629ea 100644 --- a/.github/workflows/native_image_cropper.yaml +++ b/.github/workflows/native_image_cropper.yaml @@ -17,18 +17,23 @@ jobs: - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: - path: native_image_cropper/.dart_tool/ - key: ${{ runner.os }}-${{ hashFiles('**/pubspec.lock') }} + path: | + ~/.pub-cache + native_image_cropper/.dart_tool/ + key: ${{ runner.os }}-flutter-${{ hashFiles('example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter- - name: Install dependencies run: flutter pub get @@ -40,8 +45,6 @@ jobs: run: dart run dart_code_linter:metrics analyze . --set-exit-on-violation-level=warning - name: Run tests run: flutter test - - name: Debug - run: ls -la pana: defaults: @@ -56,8 +59,12 @@ jobs: id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Install WebP run: | @@ -68,9 +75,10 @@ jobs: id: flutter_cache with: path: | - native_image_cropper/.dart_tool/ ~/.pub-cache/ - key: ${{ runner.os }}-${{ hashFiles('**/pubspec.lock') }} + native_image_cropper/.dart_tool/ + key: ${{ runner.os }}-flutter-${{ hashFiles('example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter- - name: Install Dependencies run: | flutter pub get diff --git a/.github/workflows/native_image_cropper_android.yaml b/.github/workflows/native_image_cropper_android.yaml index e6f7531..8cf93d1 100644 --- a/.github/workflows/native_image_cropper_android.yaml +++ b/.github/workflows/native_image_cropper_android.yaml @@ -14,20 +14,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: - path: native_image_cropper_android/.dart_tool/ - key: ${{ runner.os }}-android-${{ hashFiles('**/pubspec.lock') }} + path: | + ~/.pub-cache + native_image_cropper_android/.dart_tool/ + key: ${{ runner.os }}-flutter-android-${{ hashFiles('native_image_cropper_android/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-android- - name: Install dependencies run: flutter pub get @@ -47,22 +53,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: path: | + ~/.pub-cache native_image_cropper_android/.dart_tool/ - ~/.pub-cache/ - key: ${{ runner.os }}-android-${{ hashFiles('**/pubspec.lock') }} + key: ${{ runner.os }}-flutter-android-${{ hashFiles('native_image_cropper_android/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-android- - name: Install Dependencies run: | flutter pub get diff --git a/.github/workflows/native_image_cropper_ios.yaml b/.github/workflows/native_image_cropper_ios.yaml index de986b2..e1b6032 100644 --- a/.github/workflows/native_image_cropper_ios.yaml +++ b/.github/workflows/native_image_cropper_ios.yaml @@ -14,20 +14,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: - path: native_image_cropper_ios/.dart_tool/ - key: ${{ runner.os }}-ios-${{ hashFiles('**/pubspec.lock') }} + path: | + ~/.pub-cache + native_image_cropper_ios/.dart_tool/ + key: ${{ runner.os }}-flutter-ios-${{ hashFiles('native_image_cropper_ios/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-ios- - name: Install dependencies run: flutter pub get @@ -47,22 +53,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: path: | + ~/.pub-cache native_image_cropper_ios/.dart_tool/ - ~/.pub-cache/ - key: ${{ runner.os }}-ios-${{ hashFiles('**/pubspec.lock') }} + key: ${{ runner.os }}-flutter-ios-${{ hashFiles('native_image_cropper_ios/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-ios- - name: Install Dependencies run: | flutter pub get diff --git a/.github/workflows/native_image_cropper_macos.yaml b/.github/workflows/native_image_cropper_macos.yaml index 1887f4c..0cab714 100644 --- a/.github/workflows/native_image_cropper_macos.yaml +++ b/.github/workflows/native_image_cropper_macos.yaml @@ -14,20 +14,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: - path: native_image_cropper_macos/.dart_tool/ - key: ${{ runner.os }}-macos-${{ hashFiles('**/pubspec.lock') }} + path: | + ~/.pub-cache + native_image_cropper_macos/.dart_tool/ + key: ${{ runner.os }}-flutter-macos-${{ hashFiles('native_image_cropper_macos/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-macos- - name: Install dependencies run: flutter pub get @@ -47,22 +53,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: path: | + ~/.pub-cache native_image_cropper_macos/.dart_tool/ - ~/.pub-cache/ - key: ${{ runner.os }}-macos-${{ hashFiles('**/pubspec.lock') }} + key: ${{ runner.os }}-flutter-macos-${{ hashFiles('native_image_cropper_macos/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-macos- - name: Install Dependencies run: | flutter pub get diff --git a/.github/workflows/native_image_cropper_platform_interface.yaml b/.github/workflows/native_image_cropper_platform_interface.yaml index b622ca5..86b7d08 100644 --- a/.github/workflows/native_image_cropper_platform_interface.yaml +++ b/.github/workflows/native_image_cropper_platform_interface.yaml @@ -14,20 +14,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: - path: native_image_cropper_platform_interface/.dart_tool/ - key: ${{ runner.os }}-platform-interface-${{ hashFiles('**/pubspec.lock') }} + path: | + ~/.pub-cache + native_image_cropper_platform_interface/.dart_tool/ + key: ${{ runner.os }}-flutter-platform-interface-${{ hashFiles('native_image_cropper_platform_interface/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-platform-interface- - name: Install dependencies run: flutter pub get @@ -45,22 +51,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: path: | + ~/.pub-cache native_image_cropper_platform_interface/.dart_tool/ - ~/.pub-cache/ - key: ${{ runner.os }}-platform-interface-${{ hashFiles('**/pubspec.lock') }} + key: ${{ runner.os }}-flutter-platform-interface-${{ hashFiles('native_image_cropper_platform_interface/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-platform-interface- - name: Install Dependencies run: | flutter pub get diff --git a/.github/workflows/native_image_cropper_web.yaml b/.github/workflows/native_image_cropper_web.yaml index c93fa40..da90f8c 100644 --- a/.github/workflows/native_image_cropper_web.yaml +++ b/.github/workflows/native_image_cropper_web.yaml @@ -14,20 +14,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 - id: flutter_cache with: - path: native_image_cropper_web/.dart_tool/ - key: ${{ runner.os }}-web-${{ hashFiles('**/pubspec.lock') }} + path: | + ~/.pub-cache + native_image_cropper/.dart_tool/ + key: ${{ runner.os }}-flutter-web${{ hashFiles('native_image_cropper_web/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-web- - name: Install dependencies run: flutter pub get @@ -45,13 +51,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache asdf uses: actions/cache@v4 - id: asdf_cache with: path: ~/.asdf/ - key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }} - - uses: asdf-vm/actions/install@v3 + key: ${{ runner.os }}-asdf-${{ hashFiles('.tool-versions') }} + restore-keys: ${{ runner.os }}-asdf- + - name: Install asdf + uses: asdf-vm/actions/install@v3 + # See https://github.com/asdf-vm/actions/issues/445 + if: steps.cache-asdf.outputs.cache-hit != 'true' - name: Cache flutter dependencies uses: actions/cache@v4 @@ -60,7 +70,8 @@ jobs: path: | native_image_cropper_web/.dart_tool/ ~/.pub-cache/ - key: ${{ runner.os }}-web-${{ hashFiles('**/pubspec.lock') }} + key: ${{ runner.os }}-flutter-web${{ hashFiles('native_image_cropper_web/example/pubspec.lock') }} + restore-keys: ${{ runner.os }}-flutter-web- - name: Install Dependencies run: | flutter pub get