flutterdartgitlabcontinuous-integration

GitLab - analyze command failing


I want to run dart analyze and flutter analyze commands as part of my ci process (gitlab) using this gitlab-ci.yml file:

before_script:
  - apt-get update -qy
  - apt-get install -y apt-transport-https
  - sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
  - sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
  - apt-get update -qy
  - apt-get install -y dart
  - apt-get install -y xz-utils
  

  # Install Flutter
  - git clone https://github.com/flutter/flutter.git -b stable --depth 1
  - export PATH="$PATH:`pwd`/flutter/bin"

dart_analyze:
  stage: analyze
  script:
    - flutter pub get
    - dart analyze

flutter_analyze:
  stage: analyze
  script:
    - flutter pub get
    - flutter analyze

As you can see dart analyze command starts to run (screenshot taken from the pipeline while running)

enter image description here

After that, I will get this error:


error - flutter/packages/flutter_driver/test/src/real_tests/wait_test.dart:105:3 - The function 'group' isn't defined. Try importing the library that defines 'group', correcting the name to the name of an existing function, or defining a function named 'group'. - undefined_function

error - flutter/packages/flutter_driver/test/src/real_tests/wait_test.dart:106:5 - The function 'test' isn't defined. Try importing the library that defines 'test', correcting the name to the name of an existing function, or defining a function named 'test'. - undefined_function

    **More errors in here, and the end of the errors will display those lines:**

   info - flutter/packages/integration_test/example/test_driver/failure_test.dart:7:8 - The imported package 'test' isn't a dependency of the importing package. Try adding a dependency for 'test' in the 'pubspec.yaml' file. - depend_on_referenced_packages
   info - flutter/packages/integration_test/test/binding_test.dart:153:23 - Unreachable member 'getVMTimeline' in an executable library. Try referencing the member or removing it. - unreachable_from_main
   info - flutter/packages/integration_test/test/binding_test.dart:159:24 - Unreachable member 'getVMTimelineMicros' in an executable library. Try referencing the member or removing it. - unreachable_from_main
   info - flutter/packages/integration_test/test/binding_test.dart:165:22 - Unreachable member 'setVMTimelineFlags' in an executable library. Try referencing the member or removing it. - unreachable_from_main
   info - flutter/packages/integration_test/test/binding_test.dart:170:22 - Unreachable member 'clearVMTimeline' in an executable library. Try referencing the member or removing it. - unreachable_from_main
11439 issues found.
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

Here you can find the full log from the pipeline


I checked locally that everything is okay when running dart analyze and flutter analyze:

enter image description here

What could be the problem ?


Solution

  • In the end I found the correct syntax :

    code_quality:
      stage: test
      image: ghcr.io/cirruslabs/flutter:stable
    
      before_script:
        - flutter pub get
    
      script:
        - flutter analyze
        - flutter test