diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..52908f82 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,36 @@ +name: Main Branch CI + +# Declare default permissions as read only. +permissions: read-all + +on: + push: + branches: [main] + pull_request: + branches: [main, ffi-wrapper-core-pkg] + workflow_dispatch: + schedule: + - cron: "0 0 * * *" # Every day at midnight + +defaults: + run: + shell: bash + +jobs: + flutter-tests: + name: Test mediapipe_core against ${{ matrix.flutter_version }} + runs-on: ${{ matrix.os }} + # Skip running job on forks + if: github.repository == 'google/flutter-mediapipe' + strategy: + fail-fast: false + matrix: + flutter_version: [stable, beta, master] + # TODO(craiglabenz): Add `ubuntu-latest` and `windows-latest` when those artifacts exist + os: [macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 + with: + channel: ${{ matrix.flutter_version }} + - run: ./tool/mediapipe_ci_script_${{ matrix.flutter_version }}.sh diff --git a/tool/ci_script_shared.sh b/tool/ci_script_shared.sh new file mode 100644 index 00000000..183f71a5 --- /dev/null +++ b/tool/ci_script_shared.sh @@ -0,0 +1,28 @@ +function ci_package () { + local channel="$1" + + shift + local arr=("$@") + for PACKAGE_NAME in "${arr[@]}" + do + echo "== Testing '${PACKAGE_NAME}' on Flutter's $channel channel ==" + pushd "packages/${PACKAGE_NAME}" + + # Grab packages. + flutter pub get + + # Run the analyzer to find any static analysis issues. + dart analyze --fatal-infos + + # Run the formatter on all the dart files to make sure everything's linted. + dart format --output none --set-exit-if-changed . + + # Run the actual tests. + if [ -d "test" ] + then + flutter test + fi + + popd + done +} diff --git a/tool/mediapipe_ci_script_beta.sh b/tool/mediapipe_ci_script_beta.sh new file mode 100755 index 00000000..5f914f48 --- /dev/null +++ b/tool/mediapipe_ci_script_beta.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +DIR="${BASH_SOURCE%/*}" +source "$DIR/ci_script_shared.sh" + +flutter doctor -v + +declare -ar PACKAGE_NAMES=( + "mediapipe-core" +) + +ci_package "beta" "${PACKAGE_NAMES[@]}" + +echo "-- Success --" diff --git a/tool/mediapipe_ci_script_master.sh b/tool/mediapipe_ci_script_master.sh new file mode 100755 index 00000000..48c5d65b --- /dev/null +++ b/tool/mediapipe_ci_script_master.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +DIR="${BASH_SOURCE%/*}" +source "$DIR/ci_script_shared.sh" + +flutter doctor -v + +declare -ar PACKAGE_NAMES=( + "mediapipe-core" +) + +ci_package "master" "${PACKAGE_NAMES[@]}" + +echo "-- Success --" diff --git a/tool/mediapipe_ci_script_stable.sh b/tool/mediapipe_ci_script_stable.sh new file mode 100755 index 00000000..153dda2a --- /dev/null +++ b/tool/mediapipe_ci_script_stable.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +DIR="${BASH_SOURCE%/*}" +source "$DIR/ci_script_shared.sh" + +flutter doctor -v + +declare -ar PACKAGE_NAMES=( + "mediapipe-core" +) + +ci_package "stable" "${PACKAGE_NAMES[@]}" + +echo "-- Success --"