Skip to content
Merged
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
110 changes: 110 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: verify

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: ${{ matrix.os }}${{ matrix.label }}
runs-on: ${{ matrix.os }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
channel: stable
flutter-version: ""
label: " / stable"
- os: macos-latest
channel: stable
flutter-version: ""
label: " / stable"
- os: windows-latest
channel: stable
flutter-version: ""
label: " / stable"
- os: ubuntu-latest
channel: beta
flutter-version: ""
label: " / beta"
- os: ubuntu-latest
channel: ""
flutter-version: "3.44.4"
label: " / pinned 3.44.4"
- os: windows-latest
channel: ""
flutter-version: "3.44.4"
label: " / pinned 3.44.4"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false

- uses: ./
with:
flutter-version: ${{ matrix.flutter-version }}
channel: ${{ matrix.channel }}

- name: Verify Flutter matches the requested version
shell: bash
env:
EXPECTED_CHANNEL: ${{ matrix.channel }}
EXPECTED_VERSION: ${{ matrix.flutter-version }}
run: |
flutter --version 2>&1 | tee /tmp/flutter-version.txt
if [ -n "$EXPECTED_VERSION" ]; then
grep -q "Flutter ${EXPECTED_VERSION} " /tmp/flutter-version.txt || { echo "expected Flutter $EXPECTED_VERSION" >&2; exit 1; }
else
grep -q "channel ${EXPECTED_CHANNEL}" /tmp/flutter-version.txt || { echo "expected channel $EXPECTED_CHANNEL" >&2; exit 1; }
fi

- name: Verify pub cache location and contents
shell: bash
run: |
echo "PUB_CACHE=$PUB_CACHE"
expected="$HOME/.pub-cache"
if [ "$RUNNER_OS" = "Windows" ]; then
expected="$LOCALAPPDATA/Pub/Cache"
fi
norm() { printf '%s' "$1" | tr '\\' '/' | tr '[:upper:]' '[:lower:]'; }
if [ "$(norm "$PUB_CACHE")" != "$(norm "$expected")" ]; then
echo "expected PUB_CACHE to be $expected" >&2
exit 1
fi
test -d "$PUB_CACHE" || { echo "PUB_CACHE directory missing" >&2; exit 1; }
test -d "$PUB_CACHE/hosted" || { echo "no hosted packages cached" >&2; exit 1; }

- name: Verify pub get resolved http from the pub cache
shell: bash
run: |
test -f .dart_tool/package_config.json
PY=python3
command -v python3 >/dev/null 2>&1 || PY=python
"$PY" - "$PUB_CACHE" <<'EOF'
import json, os, sys, urllib.parse
pub_cache = os.path.normcase(os.path.realpath(sys.argv[1]))
base = os.path.dirname(os.path.abspath(".dart_tool/package_config.json"))
with open(".dart_tool/package_config.json") as f:
packages = json.load(f)["packages"]
http = next((p for p in packages if p["name"] == "http"), None)
assert http is not None, "http package missing from package_config.json"
root = http["rootUri"]
if "://" in root:
root = urllib.parse.urlparse(root).path
if os.name == "nt" and root.startswith("/"):
root = root[1:]
if not os.path.isabs(root):
root = os.path.join(base, root)
root = os.path.normcase(os.path.realpath(root))
assert root.startswith(pub_cache), f"{root} not under PUB_CACHE {pub_cache}"
print(f"http resolved under PUB_CACHE ({root})")
EOF
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.dart_tool/
pubspec.lock
Comment thread
coderabbitai[bot] marked this conversation as resolved.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ One composite action for the three-step block every Flutter CI job repeats:
install Flutter, restore the pub cache, run `flutter pub get`. Wraps
[subosito/flutter-action](https://github.com/subosito/flutter-action) and
[actions/cache](https://github.com/actions/cache), with both caches keyed on
`pubspec.lock`.
`pubspec.yaml`.

## Usage

Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Setup Flutter with pub cache
description: Install Flutter, restore the pub cache keyed on pubspec.lock, and run flutter pub get, as a single step.
description: Install Flutter, restore the pub cache keyed on pubspec.yaml, and run flutter pub get, as a single step.
branding:
icon: download
color: blue
Expand All @@ -23,7 +23,7 @@ runs:
flutter-version: ${{ inputs.flutter-version }}
channel: ${{ inputs.channel }}
cache: true
cache-key: flutter-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
cache-key: flutter-${{ runner.os }}-${{ hashFiles('pubspec.yaml') }}

- name: Cache pub
uses: actions/cache@v6
Expand All @@ -36,7 +36,7 @@ runs:
# instead misses the real cache directory on Windows runners, where
# Flutter writes pub packages to %LOCALAPPDATA%\Pub\Cache by default.
path: ${{ env.PUB_CACHE }}
key: ${{ runner.os }}-pub-${{ hashFiles('pubspec.lock') }}
key: ${{ runner.os }}-pub-${{ hashFiles('pubspec.yaml') }}
restore-keys: |
${{ runner.os }}-pub-

Expand Down
10 changes: 10 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: setup_flutter_fixture
description: Minimal Flutter fixture used by CI to verify the setup-flutter composite action.
publish_to: none
version: 0.1.0

environment:
sdk: ^3.0.0

dependencies:
http: ^1.2.0