leoafarias / fvm

Flutter Version Management: A simple CLI to manage Flutter SDK versions.
https://fvm.app
MIT License
4.58k stars 225 forks source link

[BUG] fvm use stable --pin gets interactive in CI environment #753

Open twogood opened 2 months ago

twogood commented 2 months ago

Before creating a bug report please make check the following

Describe the bug I'm trying to create a GitHub action that tries to upgrade to the latest Flutter stable (fvm use stable --pin) and create a PR if there is a new version.

To Reproduce

name: Update Flutter Version in FVM

on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * 0' # Weekly

env:
  CI: true

jobs:
  update-flutter-version:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Set up Dart
        uses: dart-lang/setup-dart@v1

      - name: Install FVM
        run: dart pub global activate fvm

      - name: Run FVM use stable --pin
        run: fvm use stable --pin

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          commit-message: "Update Flutter version to latest stable"
          title: "Update Flutter version to latest stable"
          body: "This PR updates the Flutter version to the latest stable release. Tip: close and reopen this PR to trigger the GitHub Action for PRs!"
          branch: "update-flutter-stable-${{ github.run_number }}"
          delete-branch: true

What happens though is that fvm asks "Would you like to install it now? (y/n)" even in the CI environment.

Expected behavior I would like fvm to not require interaction when running in a CI environment and the "CI" environment variable is included in kCiEnvironmentVariables. If it installs or not installs Flutter by default is not important.

Logs

Run fvm use stable --pin --verbose
  fvm use stable --pin --verbose
  shell: /usr/bin/bash -e {0}
  env:
    CI: true
    DART_HOME: /opt/hostedtoolcache/dart/3.4.4/x64
    PUB_CACHE: /home/runner/.pub-cache
Argument information:
  Top level options:
  - verbose: true
Command: use
  Command options:
    - pin: true
Searching for project in /home/runner/work/bankid-demo-flutter-firebase/bankid-demo-flutter-firebase
Found project config in /home/runner/work/bankid-demo-flutter-firebase/bankid-demo-flutter-firebase
Pinning version 3.[2](https://github.com/activout/bankid-demo-flutter-firebase/actions/runs/10027622205/job/27713521073#step:6:2)2.3 from "stable" release channel...
Creating local mirror...
.
.
.
✓ Clone complete
Flutter SDK: SDK Version : 3.22.3 is not installed.
25l? Would you like to install it now? (y/n) › yes

Desktop (please complete the following information):

Additional context

Not sure if this is solved by #712 ?

fvm doctor output

Run fvm doctor
  fvm doctor
  shell: /usr/bin/bash -e {0}
  env:
    CI: true
    DART_HOME: /opt/hostedtoolcache/dart/3.4.4/x64
    PUB_CACHE: /home/runner/.pub-cache
FVM Doctor:                                                                     
--------------------------------------------------------------------------------
Project:
┌─────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────┐
│ Project                     │ bankid-demo-flutter-firebase                                                      │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Directory                   │ /home/runner/work/bankid-demo-flutter-firebase/bankid-demo-flutter-firebase       │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Active Flavor               │ None                                                                              │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Is Flutter Project          │ Yes                                                                               │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────��───────────┤
│ Dart Tool Generator Version │ Not available                                                                     │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Dart tool version           │ Not available                                                                     │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ .gitignore Present          │ Yes                                                                               │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Config Present              │ Yes                                                                               │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Pinned Version              │ FlutterVersion(name: 3.19.6, releaseFromChannel: null, type: VersionType.release) │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Config path                 │ .fvmrc                                                                            │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Local cache dir             │ .fvm/versions                                                                     │
├─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┤
│ Version symlink             │ .fvm/versions/3.19.6                                                              │
└─────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────┘

IDEs:
┌────────────────────────────────┬─────────────────────────────────────────────────────┐
│ IDEs                           │ Value                                               │
├────────────────────────────────┼─────────────────────────────────────────────────────┤
│ VSCode                         │                                                     │
├────────────────────────────────┼─────────────────────────────────────────────────────┤
│ VSCode                         │ No .vscode directory found                          │
├────────────────────────────────┼─────────────────────────────────────────────────────┤
│ IntelliJ (Android Studio, ...) │                                                     │
├────────────────────────────────┼─────────────────────────────────────────────────────┤
│ IntelliJ (Android Studio, ...) │ No local.properties file found in android directory │
├────────────────────────────────┼─────────────────────────────────────────────────────┤
│ IntelliJ (Android Studio, ...) │ No .idea folder found                               │
└────────────────────────────────┴─────────────────────────────────────────────────────┘

Environment:
┌────────────────────────┬──────────────────────────────────────────────┐
│ Environment Variables  │ Value                                        │
├────────────────────────┼──────────────────────────────────────────────┤
│ Flutter PATH           │ Not found                                    │
├────────────────────────┼──────────────────────────────────────────────┤
│ Dart PATH              │ /opt/hostedtoolcache/dart/3.4.4/x64/bin/dart │
├────────────────────────┼──────────────────────────────────────────────┤
│ FVM_CACHE_PATH         │ N/A                                          │
├────────────────────────┼──────────────────────────────────────────────┤
│ FVM_USE_GIT_CACHE      │ N/A                                          │
├────────────────────────┼──────────────────────────────────────────────┤
│ FVM_GIT_CACHE_PATH     │ N/A                                          │
├────────────────────────┼──────────────────────────────────────────────┤
│ FVM_FLUTTER_URL        │ N/A                                          │
├────────────────────────┼──────────────────────────────────────────────┤
│ FVM_PRIVILEDGED_ACCESS │ N/A                                          │
├────────────────────────┼──────────────────────────────────────────────┤
│ Flutter PATH           │ Not found                                    │
├────────────────────────┼──────────────────────────────────────────────┤
│ Dart PATH              │ /opt/hostedtoolcache/dart/3.4.4/x64/bin/dart │
└────────────────────────┴──────────────────────────────────────────────┘
┌──────────────┬──────────────────────────────────────────────────────────────────────────────────┐
│ Platform     │ Value                                                                            │
├──────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ OS           │ linux Linux 6.5.0-10[2](https://github.com/activout/bankid-demo-flutter-firebase/actions/runs/10027622205/job/27713521073#step:5:2)3-azure #24~22.04.1-Ubuntu SMP Wed Jun 12 19:55:26 UTC 2024 │
├──────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ Dart Locale  │ C.UTF-8                                                                          │
├──────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ Dart runtime │ [3](https://github.com/activout/bankid-demo-flutter-firebase/actions/runs/10027622205/job/27713521073#step:5:3).4.4 (stable) (Wed Jun 12 15:5[4](https://github.com/activout/bankid-demo-flutter-firebase/actions/runs/10027622205/job/27713521073#step:5:4):31 2024 +0000) on "linux_x[6](https://github.com/activout/bankid-demo-flutter-firebase/actions/runs/10027622205/job/27713521073#step:5:6)4"                   │
└──────────────┴──────────────────────────────────────────────────────────────────────────────────┘