blob: 251dc1d278a02ee6de42d955016e223f73467490 [file] [edit]
name: 'Wait for Cocoon Tests'
description: 'Polls the Cocoon API and waits for a specific list of pre-submit / merge queue Cocoon tests, to complete `successfully` or `neutral`'
author: 'The Flutter Authors'
inputs:
sha:
description: 'The commit SHA to poll'
required: true
repo:
description: 'The repository slug (e.g., flutter or packages)'
required: true
required-tests:
description: 'Comma or newline-separated list of tests to wait for (optional, if omitted waits for all scheduled tests)'
required: false
wait-interval:
description: 'Time in seconds between polling checks (min: 30, max: 600)'
required: false
default: '60'
runs:
using: 'composite'
steps:
- name: Set up Dart SDK
uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260 # v1.7.2
- name: Get dependencies
id: get-deps
shell: bash
run: |
# 1. Resolve the action path.
# On real GitHub Actions runners, GITHUB_ACTION_PATH / github.action_path is set correctly.
# On local testing tools like 'nektos/act', github.action_path for local composite actions
# can be empty or incorrect. We use a fallback to 'packages/wait_for_tests' to support local testing.
ACTION_PATH="${GITHUB_ACTION_PATH:-${{ github.action_path }}}"
if [ -z "$ACTION_PATH" ] || [ "$ACTION_PATH" = "." ] || [ "$ACTION_PATH" = "$(pwd)" ]; then
ACTION_PATH="packages/wait_for_tests"
fi
echo "resolved-action-path=$ACTION_PATH" >> "$GITHUB_OUTPUT"
echo "Using action path: $ACTION_PATH"
# 2. Bypass workspace resolution.
# Since this action is part of a Dart/Flutter pub workspace that includes Flutter-dependent
# packages, running 'dart pub get' in a pure Dart runner will fail without the Flutter SDK.
# We temporarily create a pubspec_overrides.yaml to opt this package out of workspace resolution.
#
# To avoid overwriting or leaving lingering changes during local testing, we back up any
# existing pubspec_overrides.yaml and register a shell 'trap' to guarantee clean restoration/removal
# on exit (regardless of success or failure).
ORIG_OVERRIDES="$ACTION_PATH/pubspec_overrides.yaml"
BACKUP_OVERRIDES="$ACTION_PATH/pubspec_overrides.yaml.bak"
if [ -f "$ORIG_OVERRIDES" ]; then
mv "$ORIG_OVERRIDES" "$BACKUP_OVERRIDES"
trap 'mv "$BACKUP_OVERRIDES" "$ORIG_OVERRIDES"' EXIT
else
trap 'rm -f "$ORIG_OVERRIDES"' EXIT
fi
echo "resolution:" > "$ORIG_OVERRIDES"
dart pub get --directory="$ACTION_PATH"
- name: Run wait-for-tests
shell: bash
env:
INPUT_SHA: ${{ inputs.sha }}
INPUT_REPO: ${{ inputs.repo }}
INPUT_REQUIRED_TESTS: ${{ inputs.required-tests }}
INPUT_WAIT_INTERVAL: ${{ inputs.wait-interval }}
RESOLVED_ACTION_PATH: ${{ steps.get-deps.outputs.resolved-action-path }}
run: dart "$RESOLVED_ACTION_PATH/bin/wait_for_tests.dart"