Skip to content

Commit 638daca

Browse files
committed
Fix: skip unresolvable GitHub Actions expressions in workflow version detection
flutter-version/sdk values like ${{needs.x.outputs.y}} are runtime expressions that cannot be resolved statically. Treat them as unresolvable and continue to the next detection source.
1 parent ccb0047 commit 638daca

3 files changed

Lines changed: 50 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ actionforge
5050

5151
Or as a single command: `brew install flutterplaza/tap/actionforge`
5252

53+
5354
**One-liner (fully non-interactive):**
5455

5556
```bash

setup.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ detect_workflow_flutter() {
734734
| sed "s/.*flutter-version:[[:space:]]*['\"]*//" \
735735
| sed "s/['\"].*//" \
736736
| tr -d '[:space:]') || true
737-
if [[ -n "$fv" ]]; then
737+
if [[ -n "$fv" ]] && [[ "$fv" != *'${'* ]]; then
738738
WORKFLOW_FLUTTER_VERSION="$fv"
739739
ok "Detected Flutter ${fv} from workflow ${wf_file} (flutter-action)"
740740
return 0
@@ -747,7 +747,7 @@ detect_workflow_flutter() {
747747
| sed "s/.*channel:[[:space:]]*['\"]*//" \
748748
| sed "s/['\"].*//" \
749749
| tr -d '[:space:]') || true
750-
if [[ -n "$ch" ]]; then
750+
if [[ -n "$ch" ]] && [[ "$ch" != *'${'* ]]; then
751751
WORKFLOW_FLUTTER_VERSION="$ch"
752752
ok "Detected Flutter channel '${ch}' from workflow ${wf_file} (flutter-action)"
753753
return 0
@@ -763,7 +763,7 @@ detect_workflow_flutter() {
763763
| sed "s/.*sdk:[[:space:]]*['\"]*//" \
764764
| sed "s/['\"].*//" \
765765
| tr -d '[:space:]') || true
766-
if [[ -n "$ds" ]]; then
766+
if [[ -n "$ds" ]] && [[ "$ds" != *'${'* ]]; then
767767
WORKFLOW_FLUTTER_VERSION="$ds"
768768
WORKFLOW_DART_ONLY=true
769769
ok "Detected Dart SDK ${ds} from workflow ${wf_file} (setup-dart)"

tests/unit/setup_status.bats

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,52 @@ YAML
305305
assert_output --partial "3.3.0"
306306
}
307307

308+
@test "detect_workflow_flutter skips GitHub expressions in flutter-version" {
309+
# Workflow YAML where flutter-version is a GitHub expression (unresolvable)
310+
local wf_yaml
311+
wf_yaml=$(cat <<'YAML'
312+
name: CI
313+
on: push
314+
jobs:
315+
build:
316+
runs-on: ubuntu-latest
317+
steps:
318+
- uses: subosito/flutter-action@v2
319+
with:
320+
flutter-version: ${{needs.get-flutter-version.outputs.flutter_version}}
321+
- run: flutter test
322+
YAML
323+
)
324+
local wf_b64
325+
wf_b64=$(echo -n "$wf_yaml" | base64)
326+
327+
curl() {
328+
local url="${*: -1}"
329+
if [[ "$url" == *".fvm/fvm_config.json"* ]]; then
330+
echo '{"message": "Not Found"}'
331+
elif [[ "$url" == *".github/workflows"* ]] && [[ "$url" != *".yml"* ]]; then
332+
echo '[{"name": "ci.yml"}]'
333+
elif [[ "$url" == *"ci.yml"* ]]; then
334+
echo "{\"content\": \"${WF_B64}\"}"
335+
elif [[ "$url" == *"pubspec.yaml"* ]]; then
336+
echo '{"message": "Not Found"}'
337+
else
338+
echo "{}"
339+
fi
340+
}
341+
export -f curl
342+
WF_B64="$wf_b64"
343+
export WF_B64
344+
GH_PAT="ghp_test"
345+
GH_ORG="test-org"
346+
GH_REPO="test-repo"
347+
run detect_workflow_flutter
348+
assert_success
349+
# Should NOT use the expression literal — should fall back to stable
350+
assert_output --partial "stable"
351+
refute_output --partial "needs.get-flutter-version"
352+
}
353+
308354
@test "detect_workflow_flutter falls back to stable when API returns nothing useful" {
309355
curl() {
310356
echo '{"message": "Not Found"}'

0 commit comments

Comments
 (0)