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

Add optional "precache" flag #276

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,69 @@ jobs:
shell: bash
- run: flutter --version
shell: bash
test_precache_disabled:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
channel: stable
flutter-version: 3.19.0
cache: false
precache: false
- run: dart --version
shell: bash
- run: flutter --version
shell: bash
- name: Run first test
run: |
cd $FLUTTER_ROOT/bin/cache/artifacts
ls -lah .
test ! -e material_fonts
shell: bash
- name: Run more tests
run: |
cd $FLUTTER_ROOT/bin/cache/artifacts/engine
test ! -e android-arm
test ! -e android-arm-profile
test ! -e android-arm-release
test ! -e android-arm64
test ! -e android-arm64-profile
test ! -e android-arm64-release
test ! -e linux-x64
test ! -e linux-x64-profile
test ! -e linux-x64-release
test_precache_enabled:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
channel: stable
flutter-version: 3.19.0
cache: false
precache: true
- run: dart --version
shell: bash
- run: flutter --version
shell: bash
- name: Run first test
run: |
cd $FLUTTER_ROOT/bin/cache/artifacts
test -d material_fonts
shell: bash
- name: Run more tests
run: |
cd $FLUTTER_ROOT/bin/cache/artifacts/engine
test -d android-arm
test -d android-arm-profile
test -d android-arm-release
test -d android-arm64
test -d android-arm64-profile
test -d android-arm64-release
test -d linux-x64
test -d linux-x64-profile
test -d linux-x64-release
test_print_output:
runs-on: macos-latest
steps:
Expand Down
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@ inputs:
description: 'The architecture of Flutter SDK executable (x64 or arm64)'
required: false
default: '${{ runner.arch }}'
precache:
description: 'Whether to call flutter precache after download'
required: false
default: 'false'
outputs:
CACHE-PATH:
value: '${{ steps.flutter-action.outputs.CACHE-PATH }}'
CACHE-KEY:
value: '${{ steps.flutter-action.outputs.CACHE-KEY }}'
CHANNEL:
value: '${{ steps.flutter-action.outputs.CHANNEL }}'
description: 'The Flutter build release channel'
VERSION:
value: '${{ steps.flutter-action.outputs.VERSION }}'
ARCHITECTURE:
Expand All @@ -58,7 +63,7 @@ runs:
- run: chmod +x $GITHUB_ACTION_PATH/setup.sh
shell: bash
- id: flutter-action
run: $GITHUB_ACTION_PATH/setup.sh -p -c '${{ inputs.cache-path }}' -k '${{ inputs.cache-key }}' -d '${{ inputs.pub-cache-path }}' -l '${{ inputs.pub-cache-key }}' -n '${{ inputs.flutter-version }}' -a '${{ inputs.architecture }}' ${{ inputs.channel }}
run: $GITHUB_ACTION_PATH/setup.sh -p -c '${{ inputs.cache-path }}' -k '${{ inputs.cache-key }}' -d '${{ inputs.pub-cache-path }}' -l '${{ inputs.pub-cache-key }}' -n '${{ inputs.flutter-version }}' -x '${{ inputs.precache }}' -a '${{ inputs.architecture }}' ${{ inputs.channel }}
shell: bash
- if: ${{ inputs.cache == 'true' }}
uses: actions/cache@v4
Expand Down
53 changes: 34 additions & 19 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ PRINT_ONLY=""
TEST_MODE=false
ARCH=""
VERSION=""
PRECACHE=""

while getopts 'tc:k:d:l:pa:n:' flag; do
while getopts 'tc:k:d:l:pa:x:n:' flag; do
case "$flag" in
c) CACHE_PATH="$OPTARG" ;;
k) CACHE_KEY="$OPTARG" ;;
Expand All @@ -83,6 +84,7 @@ while getopts 'tc:k:d:l:pa:n:' flag; do
p) PRINT_ONLY=true ;;
t) TEST_MODE=true ;;
a) ARCH="$(echo "$OPTARG" | awk '{print tolower($0)}')" ;;
x) PRECACHE="$OPTARG" ;;
n) VERSION="$OPTARG" ;;
?) exit 2 ;;
esac
Expand All @@ -96,6 +98,7 @@ CHANNEL="${ARR_CHANNEL[0]}"
[[ -z $CHANNEL ]] && CHANNEL=stable
[[ -z $VERSION ]] && VERSION=any
[[ -z $ARCH ]] && ARCH=x64
[[ -z $PRECACHE ]] && PRECACHE=false
[[ -z $CACHE_PATH ]] && CACHE_PATH="$RUNNER_TEMP/flutter/:channel:-:version:-:arch:"
[[ -z $CACHE_KEY ]] && CACHE_KEY="flutter-:os:-:channel:-:version:-:arch:-:hash:"
[[ -z $PUB_CACHE_KEY ]] && PUB_CACHE_KEY="flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
Expand Down Expand Up @@ -166,22 +169,25 @@ if [[ "$PRINT_ONLY" == true ]]; then
echo "CHANNEL=$info_channel"
echo "VERSION=$info_version"
echo "ARCHITECTURE=$info_architecture"
echo "PRECACHE=$PRECACHE"
echo "CACHE-KEY=$CACHE_KEY"
echo "CACHE-PATH=$CACHE_PATH"
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
echo "PUB-CACHE-PATH=$PUB_CACHE"
exit 0
fi

{
echo "CHANNEL=$info_channel"
echo "VERSION=$info_version"
echo "ARCHITECTURE=$info_architecture"
echo "CACHE-KEY=$CACHE_KEY"
echo "CACHE-PATH=$CACHE_PATH"
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
echo "PUB-CACHE-PATH=$PUB_CACHE"
} >>"$GITHUB_OUTPUT"
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
{
echo "CHANNEL=$info_channel"
echo "VERSION=$info_version"
echo "ARCHITECTURE=$info_architecture"
echo "CACHE-KEY=$CACHE_KEY"
echo "CACHE-PATH=$CACHE_PATH"
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
echo "PUB-CACHE-PATH=$PUB_CACHE"
} >>"$GITHUB_OUTPUT"
fi

exit 0
fi
Expand All @@ -199,13 +205,22 @@ if [[ ! -x "$CACHE_PATH/bin/flutter" ]]; then
fi
fi

{
echo "FLUTTER_ROOT=$CACHE_PATH"
echo "PUB_CACHE=$PUB_CACHE"
} >>"$GITHUB_ENV"
if [ -n "${GITHUB_ENV:-}" ]; then
{
echo "FLUTTER_ROOT=$CACHE_PATH"
echo "PUB_CACHE=$PUB_CACHE"
} >>"$GITHUB_ENV"
fi

{
echo "$CACHE_PATH/bin"
echo "$CACHE_PATH/bin/cache/dart-sdk/bin"
echo "$PUB_CACHE/bin"
} >>"$GITHUB_PATH"
if [ -n "${GITHUB_PATH:-}" ]; then
{
echo "$CACHE_PATH/bin"
echo "$CACHE_PATH/bin/cache/dart-sdk/bin"
echo "$PUB_CACHE/bin"
} >>"$GITHUB_PATH"
fi

if [ "$PRECACHE" = true ]; then
echo "Will run precache..."
flutter precache
fi
Loading