In one of my projects, I used a GitLab environment to perform Flutter tests. For this, I setup my .gitlab-ci.yaml
to use a Flutter docker image of cirrusci/flutter for code quality check or tests. The file looks like this:
YAML
code_quality:
stage: test
image: "cirrusci/flutter:stable"
tags:
- docker
before_script:
- pub global activate dart_code_metrics
- export PATH="$PATH":"$HOME/.pub-cache/bin"
script:
- metrics lib -r codeclimate > gl-code-quality-report.json
# [...]
test:
stage: test
image: "cirrusci/flutter:stable"
tags:
- docker
before_script:
- pub global activate junitreport
- export PATH="$PATH":"$HOME/.pub-cache/bin"
script:
- flutter test --machine --coverage | tojunit -o report.xml
- lcov --summary coverage/lcov.info
- genhtml coverage/lcov.info --output=coverage
# [...]
Up to version 2.10.* of the Flutter docker image, this worked fine. But starting with version 3.0.0, there seems to be some changes in the binaries or their paths. The scripts failed with an error:
/usr/bin/bash: line 123: pub: command not found
To fix this error, the pub
commands need to be adjusted and set to flutter pub
:
YAML
# [...]
before_script:
- flutter pub global activate dart_code_metrics
# [...]
before_script:
- flutter pub global activate junitreport
# [...]
This fixed the issue and all tests finished successfully.
Leave a Reply