1
0
Fork 0
mirror of https://github.com/subosito/flutter-action.git synced 2024-08-16 10:19:50 +02:00
This commit is contained in:
Bartek Pacia 2024-03-31 16:55:03 +00:00 committed by GitHub
commit 63f6494293
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 103 additions and 20 deletions

View file

@ -61,6 +61,69 @@ jobs:
shell: bash shell: bash
- run: flutter --version - run: flutter --version
shell: bash 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: test_print_output:
runs-on: macos-latest runs-on: macos-latest
steps: steps:

View file

@ -37,6 +37,10 @@ inputs:
description: 'The architecture of Flutter SDK executable (x64 or arm64)' description: 'The architecture of Flutter SDK executable (x64 or arm64)'
required: false required: false
default: '${{ runner.arch }}' default: '${{ runner.arch }}'
precache:
description: 'Whether to call flutter precache after download'
required: false
default: 'false'
outputs: outputs:
CACHE-PATH: CACHE-PATH:
value: '${{ steps.flutter-action.outputs.CACHE-PATH }}' value: '${{ steps.flutter-action.outputs.CACHE-PATH }}'
@ -44,6 +48,7 @@ outputs:
value: '${{ steps.flutter-action.outputs.CACHE-KEY }}' value: '${{ steps.flutter-action.outputs.CACHE-KEY }}'
CHANNEL: CHANNEL:
value: '${{ steps.flutter-action.outputs.CHANNEL }}' value: '${{ steps.flutter-action.outputs.CHANNEL }}'
description: 'The Flutter build release channel'
VERSION: VERSION:
value: '${{ steps.flutter-action.outputs.VERSION }}' value: '${{ steps.flutter-action.outputs.VERSION }}'
ARCHITECTURE: ARCHITECTURE:
@ -58,7 +63,7 @@ runs:
- run: chmod +x $GITHUB_ACTION_PATH/setup.sh - run: chmod +x $GITHUB_ACTION_PATH/setup.sh
shell: bash shell: bash
- id: flutter-action - 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 shell: bash
- if: ${{ inputs.cache == 'true' }} - if: ${{ inputs.cache == 'true' }}
uses: actions/cache@v4 uses: actions/cache@v4

View file

@ -73,8 +73,9 @@ PRINT_ONLY=""
TEST_MODE=false TEST_MODE=false
ARCH="" ARCH=""
VERSION="" 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 case "$flag" in
c) CACHE_PATH="$OPTARG" ;; c) CACHE_PATH="$OPTARG" ;;
k) CACHE_KEY="$OPTARG" ;; k) CACHE_KEY="$OPTARG" ;;
@ -83,6 +84,7 @@ while getopts 'tc:k:d:l:pa:n:' flag; do
p) PRINT_ONLY=true ;; p) PRINT_ONLY=true ;;
t) TEST_MODE=true ;; t) TEST_MODE=true ;;
a) ARCH="$(echo "$OPTARG" | awk '{print tolower($0)}')" ;; a) ARCH="$(echo "$OPTARG" | awk '{print tolower($0)}')" ;;
x) PRECACHE="$OPTARG" ;;
n) VERSION="$OPTARG" ;; n) VERSION="$OPTARG" ;;
?) exit 2 ;; ?) exit 2 ;;
esac esac
@ -96,6 +98,7 @@ CHANNEL="${ARR_CHANNEL[0]}"
[[ -z $CHANNEL ]] && CHANNEL=stable [[ -z $CHANNEL ]] && CHANNEL=stable
[[ -z $VERSION ]] && VERSION=any [[ -z $VERSION ]] && VERSION=any
[[ -z $ARCH ]] && ARCH=x64 [[ -z $ARCH ]] && ARCH=x64
[[ -z $PRECACHE ]] && PRECACHE=false
[[ -z $CACHE_PATH ]] && CACHE_PATH="$RUNNER_TEMP/flutter/:channel:-:version:-:arch:" [[ -z $CACHE_PATH ]] && CACHE_PATH="$RUNNER_TEMP/flutter/:channel:-:version:-:arch:"
[[ -z $CACHE_KEY ]] && CACHE_KEY="flutter-:os:-:channel:-:version:-:arch:-:hash:" [[ -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:" [[ -z $PUB_CACHE_KEY ]] && PUB_CACHE_KEY="flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
@ -166,6 +169,7 @@ if [[ "$PRINT_ONLY" == true ]]; then
echo "CHANNEL=$info_channel" echo "CHANNEL=$info_channel"
echo "VERSION=$info_version" echo "VERSION=$info_version"
echo "ARCHITECTURE=$info_architecture" echo "ARCHITECTURE=$info_architecture"
echo "PRECACHE=$PRECACHE"
echo "CACHE-KEY=$CACHE_KEY" echo "CACHE-KEY=$CACHE_KEY"
echo "CACHE-PATH=$CACHE_PATH" echo "CACHE-PATH=$CACHE_PATH"
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY" echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
@ -173,15 +177,17 @@ if [[ "$PRINT_ONLY" == true ]]; then
exit 0 exit 0
fi fi
{ if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
echo "CHANNEL=$info_channel" {
echo "VERSION=$info_version" echo "CHANNEL=$info_channel"
echo "ARCHITECTURE=$info_architecture" echo "VERSION=$info_version"
echo "CACHE-KEY=$CACHE_KEY" echo "ARCHITECTURE=$info_architecture"
echo "CACHE-PATH=$CACHE_PATH" echo "CACHE-KEY=$CACHE_KEY"
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY" echo "CACHE-PATH=$CACHE_PATH"
echo "PUB-CACHE-PATH=$PUB_CACHE" echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
} >>"$GITHUB_OUTPUT" echo "PUB-CACHE-PATH=$PUB_CACHE"
} >>"$GITHUB_OUTPUT"
fi
exit 0 exit 0
fi fi
@ -199,13 +205,22 @@ if [[ ! -x "$CACHE_PATH/bin/flutter" ]]; then
fi fi
fi fi
{ if [ -n "${GITHUB_ENV:-}" ]; then
echo "FLUTTER_ROOT=$CACHE_PATH" {
echo "PUB_CACHE=$PUB_CACHE" echo "FLUTTER_ROOT=$CACHE_PATH"
} >>"$GITHUB_ENV" echo "PUB_CACHE=$PUB_CACHE"
} >>"$GITHUB_ENV"
fi
{ if [ -n "${GITHUB_PATH:-}" ]; then
echo "$CACHE_PATH/bin" {
echo "$CACHE_PATH/bin/cache/dart-sdk/bin" echo "$CACHE_PATH/bin"
echo "$PUB_CACHE/bin" echo "$CACHE_PATH/bin/cache/dart-sdk/bin"
} >>"$GITHUB_PATH" echo "$PUB_CACHE/bin"
} >>"$GITHUB_PATH"
fi
if [ "$PRECACHE" = true ]; then
echo "Will run precache..."
flutter precache
fi