Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup CI on Gitlab for Flutter

I am trying to setup CI for my flutter project on gitlab but I don't understand where to start or what I have to do. Can anyone help me? Thanks

like image 550
Pierre Le Brun Avatar asked Jan 29 '19 08:01

Pierre Le Brun


People also ask

Is GitLab CI better than Jenkins?

Both tools come with their pros and cons. While Gitlab gets an edge in code collaboration and version control, Jenkins fares well in continuous integration. As such, you cannot rate one tool over the other in the Gitlab vs Jenkins CI/CD battle.

How to build iOS builds in flutter with GitLab CI?

Gitlab CI uses the Gitlab Runners as their build executors. They are nothing but machines where your pipeline will be executed. In order for your Flutter pipeline to be executed, you will need to install, configure (if required) and register Gitlab Runner on a machine preferably a Mac machine for supporting the iOS builds in Flutter with Android.

How do I set up a GitLab CI/CD runner?

From there, again navigate to the CI / CD Settings page in the browser. Copy the token from the “Set up a specific Runner manually > Use the following registration token during setup” and paste this into the terminal and press enter. On the resulting message, “Please enter the gitlab-ci description for this runner.”.

What is the CI pipeline for flutter?

The most common CI Pipeline in the Mobile world is Build -> Test -> Deploy. But when using Flutter, we run a Unit Test and Widget Tests without building the entire app. Before a job is created, a new GitLab Configuration file .gitlab-ci.yml needs to be generated from the root source of your codebase.

How to run flutter pipeline on a Mac machine?

In order for your Flutter pipeline to be executed, you will need to install, configure (if required) and register Gitlab Runner on a machine preferably a Mac machine for supporting the iOS builds in Flutter with Android. You can install software for the Gitlab Runner and register your mac machine following this documentation:


2 Answers

.gitlab-ci.yml in your repo root:

stages:
  - test

tests:
  image: cirrusci/flutter
  stage: test
  script:
  - flutter test

like image 141
Zingg Avatar answered Oct 19 '22 04:10

Zingg


I suggest to setup your GitLab CI integration for flutter treating the android and ios project folder by their own in order to build your APK or IPA or doing test with your GitLab CI.

To start having a clue on how to setup a CI for Android and iOS projects on GitLab I'll suggest you these readings:

Android:

  • https://about.gitlab.com/2018/10/24/setting-up-gitlab-ci-for-android-projects/

iOS

  • https://about.gitlab.com/2016/03/10/setting-up-gitlab-ci-for-ios-projects/
  • https://medium.com/flawless-app-stories/how-to-set-up-gitlab-continuous-integration-for-ios-projects-without-a-hustle-53c2b642c90f

UPDATE: using Fastlane

I've the above solutions running on my apps and so I know they work. But I've found these interesting official docs for flutter using Fastlane (they seem quite easier):

  • https://flutter.io/docs/deployment/fastlane-cd
  • https://docs.fastlane.tools/best-practices/continuous-integration/gitlab/

So I suggest to give them a try too.

like image 13
shadowsheep Avatar answered Oct 19 '22 04:10

shadowsheep