Skip to content

Commit

Permalink
Changed input values for setPubCachePath
Browse files Browse the repository at this point in the history
Also -
1. Set FLUTTER_ROOT unified to bash script
  • Loading branch information
hrishikesh-kadam committed Dec 29, 2021
1 parent a194668 commit af93cb2
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 59 deletions.
38 changes: 20 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ defaults:
shell: bash

jobs:
test-setup-flutter:
test-basic:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# runner: [ ubuntu-latest, windows-latest ]
runner: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v2
Expand All @@ -35,23 +36,27 @@ jobs:
if: runner.os == 'Windows'
shell: powershell

test-setup-flutter-with-setPubCachePath:
# TODO: Add test-setup-flutter-with-setFlutterRootPath

test-with-setPubCachePath:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# runner: [ ubuntu-latest ]
runner: [ ubuntu-latest, macos-latest ]
pubCachePath: [ '~/.pub-cache-new' ]
pubCachePath: [ '$HOME/.pub-cache-new' ]
include:
- runner: windows-latest
pubCachePath: '$env:LOCALAPPDATA\NewPub\Cache'
pubCachePath: '$LOCALAPPDATA\NewPub\Cache'
- runner: ubuntu-latest
pubCachePath: '/home/runner/.pub-cache-new'
- runner: windows-latest
pubCachePath: 'C:\Users\runneradmin\AppData\Local\NewPub\Cache'
- runner: macos-latest
pubCachePath: '/Users/runner/.pub-cache-new'
steps:
- uses: actions/checkout@v2
- if: runner.os != 'Windows'
run: mkdir ${{ matrix.pubCachePath }}
- if: runner.os == 'Windows'
shell: pwsh
run: mkdir ${{ matrix.pubCachePath }}
- name: Setup Flutter
uses: ./
with:
Expand All @@ -63,11 +68,12 @@ jobs:
flutter pub get
ls $PUB_CACHE/hosted/pub.dartlang.org
test-setup-flutter-with-addPubCacheBinToPath:
test-with-addPubCacheBinToPath:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# runner: [ ubuntu-latest, windows-latest ]
runner: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v2
Expand All @@ -87,23 +93,19 @@ jobs:
echo "::debug::DEFAULT_PUB_CACHE=$DEFAULT_PUB_CACHE"
ls $DEFAULT_PUB_CACHE/global_packages
test-setup-flutter-with-all:
test-with-all:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# runner: [ ubuntu-latest ]
runner: [ ubuntu-latest, macos-latest ]
pubCachePath: [ '~/.pub-cache-new' ]
pubCachePath: [ '$HOME/.pub-cache-new' ]
include:
- runner: windows-latest
pubCachePath: '$env:LOCALAPPDATA\NewPub\Cache'
pubCachePath: '$LOCALAPPDATA\NewPub\Cache'
steps:
- uses: actions/checkout@v2
- if: runner.os != 'Windows'
run: mkdir ${{ matrix.pubCachePath }}
- if: runner.os == 'Windows'
shell: pwsh
run: mkdir ${{ matrix.pubCachePath }}
- name: Setup Flutter
uses: ./
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.idea
node_modules
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/scopes/Except__gitignored.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/setup-flutter.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.0] - 2021-12-29
### Changed
- Input `setPubCachePath` <br/><br/>

For Windows runners, it now accepts bash understandable paths instead of <br/>
pwsh understandable paths. <br/>
Example: Previously - <br/>
`setPubCachePath: '$env:LOCALAPPDATA\Pub\Cache'` <br/>
Now - <br/>
`setPubCachePath: '$LOCALAPPDATA\Pub\Cache'` <br/><br/>

For Ubuntu and macOS runners, avoid using tilde `~` in paths. <br/>
Example: Previously - <br/>
`setPubCachePath: '~/.pub-cache'` <br/>
Now - <br/>
`setPubCachePath: '$HOME/.pub-cache'` <br/>

## [1.1.1] - 2021-12-23
### Fixed
- Input addPubCacheBinToPath
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ steps:
```
ref: <br/>
&nbsp; &nbsp; description: 'channel (stable, beta or master), version(2.8.0) or any git reference(2.8.0-3.3.pre).' <br/>
&nbsp; &nbsp; description: 'channel (stable, beta or master), version(2.8.1) or any git reference(2.9.0-0.1.pre).' <br/>
&nbsp; &nbsp; required: false <br/>
&nbsp; &nbsp; default: 'stable' <br/>
Expand All @@ -89,7 +89,7 @@ steps:
- name: Setup Flutter
uses: hrishikesh-kadam/setup-flutter@v1
with:
ref: beta # or 2.8.0 or 2.8.0-3.3.pre,
ref: beta # or 2.8.1 or 2.9.0-0.1.pre,
```
setFlutterRootPath: <br/>
Expand Down Expand Up @@ -118,10 +118,10 @@ my-job:
fail-fast: false
matrix:
runner: [ ubuntu-latest, macos-latest ]
pubCachePath: [ '~/.pub-cache-new' ]
pubCachePath: [ '$HOME/.pub-cache' ]
include:
- runner: windows-latest
pubCachePath: '$env:LOCALAPPDATA\NewPub\Cache'
pubCachePath: '$LOCALAPPDATA\Pub\Cache'
steps:
- uses: actions/checkout@v2
- name: Setup Flutter
Expand All @@ -131,7 +131,7 @@ my-job:
```
addPubCacheBinToPath: <br/>
&nbsp; &nbsp; description: 'Add PUB_CACHE bin to PATH.\n <br/>
&nbsp; &nbsp; description: 'Add PUB_CACHE bin to PATH. <br/>
&nbsp; &nbsp; &nbsp; &nbsp; Note: On Windows, activated global packages can be run by without specifying <br/>
&nbsp; &nbsp; &nbsp; &nbsp; `dart pub global run` only on pwsh, cmd and powershell.' <br/>
&nbsp; &nbsp; required: false <br/>
Expand Down
34 changes: 10 additions & 24 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ author: 'Hrishikesh Kadam <hrkadam.92@gmail.com>'
description: 'Composite GitHub Action to setup and cache the Flutter SDK.'
inputs:
ref:
description: 'channel (stable, beta or master), version(2.8.0) or any git reference(2.8.0-3.3.pre).'
description: 'channel (stable, beta or master), version(2.8.1) or any git reference(2.9.0-0.1.pre).'
required: false
default: 'stable'
setFlutterRootPath:
Expand All @@ -15,9 +15,9 @@ inputs:
required: false
default: ''
addPubCacheBinToPath:
description: 'Add PUB_CACHE bin to PATH.\n
Note: On Windows, activated global packages can be run by without specifying
`dart pub global run` only on pwsh, cmd and powershell.'
description: 'Add PUB_CACHE bin to PATH.
Note: On Windows, activated global packages can be run by without specifying
`dart pub global run` only on pwsh, cmd and powershell.'
required: false
default: 'false'

Expand All @@ -43,34 +43,20 @@ runs:
https://github.com/flutter/flutter $RUNNER_TOOL_CACHE/flutter
shell: bash

- name: Set FLUTTER_ROOT on Linux or macOS
if: inputs.setFlutterRootPath == 'true' && runner.os != 'Windows'
run: echo "FLUTTER_ROOT=$RUNNER_TOOL_CACHE/flutter" >> $GITHUB_ENV
- name: Set FLUTTER_ROOT path
if: inputs.setFlutterRootPath == 'true'
run: $GITHUB_ACTION_PATH/src/set-flutter-root.sh
shell: bash

- name: Set FLUTTER_ROOT on Windows
if: inputs.setFlutterRootPath == 'true' && runner.os == 'Windows'
run: echo "FLUTTER_ROOT=$env:RUNNER_TOOL_CACHE\flutter" | Out-File -FilePath $env:GITHUB_ENV -Append
shell: pwsh

- name: Add Flutter to PATH
run: echo "$RUNNER_TOOL_CACHE/flutter/bin" >> $GITHUB_PATH
shell: bash

- name: Set PUB_CACHE on Linux or macOS
if: inputs.setPubCachePath != '' && runner.os != 'Windows'
run: |
PUB_CACHE=${{ inputs.setPubCachePath }}
echo "PUB_CACHE=$PUB_CACHE" >> $GITHUB_ENV
- name: Set PUB_CACHE path
if: inputs.setPubCachePath != ''
run: echo "PUB_CACHE=${{ inputs.setPubCachePath }}" >> $GITHUB_ENV
shell: bash

- name: Set PUB_CACHE on Windows
if: inputs.setPubCachePath != '' && runner.os == 'Windows'
run: |
$env:PUB_CACHE="${{ inputs.setPubCachePath }}"
echo "PUB_CACHE=$env:PUB_CACHE" | Out-File -FilePath $env:GITHUB_ENV -Append
shell: pwsh

- name: Add PUB_CACHE bin to PATH
if: inputs.addPubCacheBinToPath == 'true'
run: $GITHUB_ACTION_PATH/src/add-pub-cache-bin-to-path.sh
Expand Down
16 changes: 5 additions & 11 deletions src/add-pub-cache-bin-to-path.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#!/usr/bin/env bash

if [[ -n $PUB_CACHE ]]; then
if [[ $RUNNER_OS == 'Windows' ]]; then
PUB_CACHE_BIN="$PUB_CACHE\bin"
else
PUB_CACHE_BIN=$PUB_CACHE/bin
fi
PUB_CACHE=$("$GITHUB_ACTION_PATH"/src/get-pub-cache-path.sh)

if [[ $RUNNER_OS == 'Windows' ]]; then
PUB_CACHE_BIN="$PUB_CACHE\bin"
else
if [[ $RUNNER_OS == 'Windows' ]]; then
PUB_CACHE_BIN="$LOCALAPPDATA\Pub\Cache\bin"
else
PUB_CACHE_BIN=$HOME/.pub-cache/bin
fi
PUB_CACHE_BIN=$PUB_CACHE/bin
fi

echo "::debug::Adding $PUB_CACHE_BIN to \$GITHUB_PATH"
Expand Down
2 changes: 2 additions & 0 deletions src/get-pub-cache-path.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

# TODO: Add check for $FLUTTER_ROOT/.pub-cache and source code references

if [[ -n $PUB_CACHE ]]; then
echo "$PUB_CACHE"
else
Expand Down
7 changes: 7 additions & 0 deletions src/set-flutter-root.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

if [[ $RUNNER_OS == 'Windows' ]]; then
echo "FLUTTER_ROOT=$RUNNER_TOOL_CACHE\flutter" >> "$GITHUB_ENV"
else
echo "FLUTTER_ROOT=$RUNNER_TOOL_CACHE/flutter" >> "$GITHUB_ENV"
fi

0 comments on commit af93cb2

Please sign in to comment.