leoafarias / fvm

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

leoafarias/fvm:latest broken with latest FVM version #621

Closed AngeloAvv closed 2 months ago

AngeloAvv commented 7 months ago

Before creating a bug report please make check the following

Describe the bug After upgrading to the latest fvm version (3.x) the tool changed the file config moving everything under .fvmrc. Since my CI is using leoafarias/fvm:latest, sounds like that image is not using the latest FVM version

To Reproduce Steps to reproduce the behavior:

In the CI script: $ fvm install Please provide a channel or a version, or run this command in a Flutter project that has FVM configured.

Expected behavior latest version of fvm should detect the new .fvmrc file

leoafarias commented 7 months ago

@AngeloAvv This is related to #626

leoafarias commented 7 months ago

@AngeloAvv can you try again as this should have been resolved on 3.0.4 which was just released

AngeloAvv commented 7 months ago

@leoafarias unfortunately nothing changed. This is part of my CI output log:

Using Docker executor with image leoafarias/fvm:latest ...
Pulling docker image leoafarias/fvm:latest ...
Using docker image sha256:5842ebf363d002bfe4bb93094674ece87d5a9958de3535b536c4a59f2a289b1c for leoafarias/fvm:latest with digest leoafarias/fvm@sha256:3696a70138d1444b353244446138bf0915b1884356bb443d7e100e9bf66e2d19 ...
Successfully extracted cache
Executing "step_script" stage of the job script
00:00
Using docker image sha256:5842ebf363d002bfe4bb93094674ece87d5a9958de3535b536c4a59f2a289b1c for leoafarias/fvm:latest with digest leoafarias/fvm@sha256:3696a70138d1444b353244446138bf0915b1884356bb443d7e100e9bf66e2d19 ...
$ fvm install
Please provide a channel or a version, or run this command in a Flutter project that has FVM configured.
Running after_script
00:01
Running after script...
$ echo $CI_PIPELINE_IID
450
$ date
Fri Feb 16 18:06:20 UTC 2024
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
leoafarias commented 7 months ago

Based on the output, the command is not running on a project folder, and there is no fvm config found to install the version

AngeloAvv commented 7 months ago

I don't understand how this could be possible since I didn't change anything in my CI scripts. Every single Flutter project is failing if I forget to rollback the migration to .fvmrc.

The following script is one of the simplest ones that are failing. As you can see, I'm not going back and forth in the folders, I'm just running fvm instructions:

.android_image:
  image: fabernovel/android:api-33-v1.7.0

.flutter:
  image: leoafarias/fvm:latest
  before_script:
    - fvm install
    - fvm flutter doctor
    - fvm flutter pub get
  stage: test
  tags:
    - flutter
.test:
  extends: .flutter
  stage: test

analyze:
  extends: .test
  script:
    - fvm flutter analyze

tests:
  extends: .test
  script:
    - apt-get update && apt-get -y install lcov
    - pub global activate junitreport
    - fvm flutter test --machine --coverage
      | tojunit -o report.xml
    - lcov --summary coverage/lcov.info
    - genhtml coverage/lcov.info --output=coverage
  coverage: '/lines\.*: \d+\.\d+\%/'
  artifacts:
    name: coverage
    paths:
      - $CI_PROJECT_DIR/coverage
    expire_in: 7 days
    reports:
      junit: report.xml

I also tried running the script locally using gitlab-ci-local and is failing too, but if I use fvm install in my project, everything is working fine. It's a clear indication that something is wrong in the docker image.

EDIT: After taking a look at the fvm Dockerfile, I'm assuming you need to rebuild the image because five months ago (last time you built fvm:latest) you hadn't released fvm 3.x yet

leoafarias commented 7 months ago

@AngeloAvv I am not a rocket expert but the image should just install the latest.

I will take a look at what could be happening, maybe there is a directory issue on fvm.

AngeloAvv commented 7 months ago

I don't think so :) at least if you're using this file to create the fvm image.

As far as I can see, there's a param FVM_VERSION which has been used to define the version of fvm to be used at that time. This means that every time you release a newer version of fvm, you need to rerun the image creation process to update the fvm version in the fvm:latest image.

Also, it would be nice to tag previous versions for those people who don't want to use the latest version but a fixed version instead.

cc @andreadelfante who worked on the Dockerfile

CodeRedDev commented 3 months ago

Unfortunately this does not seem to be resolved in the PRs mentioned above. As my console logs will show the current leoafarias/fvm:latest is not shipping the current FVM version and instead ships with 2.3.1

run_test:
  image: leoafarias/fvm:latest
  stage: run_test
  before_script:
    # Flutter version should already be configured in .fvmrc
    - ls -la
    - fvm --version
    - fvm install
    - fvm flutter pub global activate junitreport

Console log:

Using docker image sha256:5842ebf363d002bfe4bb93094674ece87d5a9958de3535b536c4a59f2a289b1c for leoafarias/fvm:latest with digest leoafarias/fvm@sha256:3696a70138d1444b353244446138bf0915b1884356bb443d7e100e9bf66e2d19 ...
$ /pre_build_script.sh
npm not found or npm version is >8
$ ls -la
total 44
drwxrwxrwx. 7 root root 4096 Jun 10 07:44 .
drwxrwxrwx. 4 root root   40 Jun 10 07:44 ..
-rw-rw-rw-. 1 root root   25 Jun 10 07:44 .fvmrc
drwxrwxrwx. 6 root root  113 Jun 10 07:44 .git
-rw-rw-rw-. 1 root root  717 Jun 10 07:44 .gitignore
-rw-rw-rw-. 1 root root 6169 Jun 10 07:44 .gitlab-ci.yml
-rw-rw-rw-. 1 root root 1114 Jun 10 07:44 .metadata
-rw-rw-rw-. 1 root root  184 Jun 10 07:44 README.md
-rw-rw-rw-. 1 root root 1446 Jun 10 07:44 analysis_options.yaml
drwxrwxrwx. 5 root root  168 Jun 10 07:44 android
drwxrwxrwx. 8 root root  188 Jun 10 07:44 ios
drwxrwxrwx. 2 root root  101 Jun 10 07:44 lib
-rw-rw-rw-. 1 root root 7428 Jun 10 07:44 pubspec.lock
-rw-rw-rw-. 1 root root 3922 Jun 10 07:44 pubspec.yaml
drwxrwxrwx. 2 root root   30 Jun 10 07:44 test
$ fvm --version
2.3.1
$ fvm install
Please provide a channel or a version, or run this command in a Flutter project that has FVM configured.
katzet20 commented 3 months ago

You can add this script to pull the version from .fvmrc:

before_script:

cheymos commented 2 months ago

@leoafarias Hi! Could you please run the deploy_docker workflow to update the image in docker hub to the latest version?

cheymos commented 2 months ago

I'm trying to set up gitlab ci and discovered that version 2.3.1 is still stored in the docker hub :(

leoafarias commented 2 months ago

Done this was deployed