From 49a24b675ea6330d780801c1312f9fbf4ca74beb Mon Sep 17 00:00:00 2001 From: "Dr.Blank" <64108942+Dr-Blank@users.noreply.github.com> Date: Fri, 4 Apr 2025 23:06:58 +0530 Subject: [PATCH] Add Flutter setup composite action for streamlined environment configuration --- .github/actions/flutter-setup/action.yaml | 57 +++++++++++++++++++++++ .github/workflows/flutter_test.yaml | 14 +++--- 2 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 .github/actions/flutter-setup/action.yaml diff --git a/.github/actions/flutter-setup/action.yaml b/.github/actions/flutter-setup/action.yaml new file mode 100644 index 0000000..85137a4 --- /dev/null +++ b/.github/actions/flutter-setup/action.yaml @@ -0,0 +1,57 @@ +# .github/actions/flutter-setup/action.yml +name: "Flutter Setup Composite Action" +description: "Checks out code, sets up Java/Flutter, caches, and runs pub get" + +# Define inputs for customization (optional, but good practice) +inputs: + flutter-channel: + description: "Flutter channel to use (stable, beta, dev, master)" + required: false + default: "stable" + java-version: + description: "Java version to set up" + required: false + default: "17" + +runs: + using: "composite" # Specify this is a composite action + steps: + # Note: Checkout needs to happen *within the job using the composite action* usually. + # However, for self-contained setup, we can include it here. + # If you need checkout options controlled by the main workflow, move checkout + # to be the first step in the main workflow's job *before* calling this action. + - name: Checkout repository (within composite) + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: ${{ inputs.java-version }} + + - name: Set up Flutter SDK + uses: subosito/flutter-action@v2 + with: + channel: ${{ inputs.flutter-channel }} + flutter-version-file: pubspec.yaml + cache: true # Cache Flutter SDK itself + + - name: Cache Flutter dependencies + id: cache-pub + uses: actions/cache@v4 + with: + path: ${{ env.FLUTTER_HOME }}/.pub-cache + key: ${{ runner.os }}-flutter-pub-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter-pub- + # Use shell: bash for potential cross-platform compatibility in complex commands + shell: bash + + - name: Get Flutter dependencies + run: flutter pub get + # Use shell: bash for potential cross-platform compatibility in complex commands + shell: bash + + # Add other common setup steps if needed diff --git a/.github/workflows/flutter_test.yaml b/.github/workflows/flutter_test.yaml index bcd661d..3daab96 100644 --- a/.github/workflows/flutter_test.yaml +++ b/.github/workflows/flutter_test.yaml @@ -14,14 +14,14 @@ on: jobs: test: name: Test - - uses: ./.github/workflows/flutter-setup.yaml - secrets: inherit - with: - flutter-channel: stable - java-version: 17 - + runs-on: ubuntu-latest steps: + - name: Setup Flutter Environment + uses: ./.github/actions/flutter-setup # Path to the composite action directory + # Pass inputs if needed (optional, using defaults here) + # with: + # flutter-channel: 'stable' + # java-version: '17' # Debug: Echo current directory contents - name: List root directory contents run: |