From fd55f4c5af5b953cc57a2be44cb082c8f6635e8e Mon Sep 17 00:00:00 2001 From: Nicholas Beninato Date: Tue, 24 Jun 2025 14:50:48 -0700 Subject: [PATCH] Support dynamic values for PUB-CACHE-PATH (#363) * use expand_key for PUB_CACHE_PATH * add tests * add dash * use PUB_CACHE --- .github/workflows/workflow.yaml | 8 ++++++++ README.md | 2 +- setup.sh | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 86113d7..296f8fe 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -207,6 +207,10 @@ jobs: shell: bash - run: ./setup.sh -t -p -c '/tmp/flutter/:channel:-:version:-:hash:' | grep '/tmp/flutter/stable-3.7.7-2ad6cd72c040113b47ee9055e722606a490ef0da' shell: bash + - run: ./setup.sh -t -p -d '/tmp/flutter/:channel:-:version:-:hash:-pub-cache-path' | grep '/tmp/flutter/stable-3.7.7-2ad6cd72c040113b47ee9055e722606a490ef0da-pub-cache-path' + shell: bash + - run: ./setup.sh -t -p -l '/tmp/flutter/:channel:-:version:-:hash:-pub-cache-key' | grep '/tmp/flutter/stable-3.7.7-2ad6cd72c040113b47ee9055e722606a490ef0da-pub-cache-key' + shell: bash test_print_output_arm64: @@ -276,3 +280,7 @@ jobs: shell: bash - run: ./setup.sh -t -p -c '/tmp/flutter/:channel:-:version:-:hash:' | grep '/tmp/flutter/stable-3.7.7-2ad6cd72c040113b47ee9055e722606a490ef0da' shell: bash + - run: ./setup.sh -t -p -d '/tmp/flutter/:channel:-:version:-:hash:-pub-cache-path' | grep '/tmp/flutter/stable-3.7.7-2ad6cd72c040113b47ee9055e722606a490ef0da-pub-cache-path' + shell: bash + - run: ./setup.sh -t -p -l '/tmp/flutter/:channel:-:version:-:hash:-pub-cache-key' | grep '/tmp/flutter/stable-3.7.7-2ad6cd72c040113b47ee9055e722606a490ef0da-pub-cache-key' + shell: bash diff --git a/README.md b/README.md index bd1bdbe..f8936ae 100644 --- a/README.md +++ b/README.md @@ -320,7 +320,7 @@ steps: # optional parameters follow cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" # optional, change this to specify the cache path - pub-cache-key: "flutter-pub:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache of dart pub get dependencies + pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache of dart pub get dependencies pub-cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" # optional, change this to specify the cache path - run: flutter --version ``` diff --git a/setup.sh b/setup.sh index c30a22b..6100d42 100755 --- a/setup.sh +++ b/setup.sh @@ -97,7 +97,7 @@ while getopts 'tc:k:d:l:pa:n:f:g:' flag; do exit 1 fi ;; - g) GIT_SOURCE="$OPTARG" ;; + g) GIT_SOURCE="$OPTARG" ;; ?) exit 2 ;; esac done @@ -180,6 +180,7 @@ expand_key() { CACHE_KEY=$(expand_key "$CACHE_KEY") PUB_CACHE_KEY=$(expand_key "$PUB_CACHE_KEY") CACHE_PATH=$(expand_key "$(transform_path "$CACHE_PATH")") +PUB_CACHE=$(expand_key "$(transform_path "$PUB_CACHE")") if [ "$PRINT_ONLY" = true ]; then version_info=$(echo "$VERSION_MANIFEST" | jq -j '.channel,":",.version,":",.dart_sdk_arch // "x64"')