Calliope GitLab Integration¶
Our GitLab platform provides you with an easy way to manage your test scripts and execution.
To make use of this feature, you first have to register on our gitlab.spritecloud.com environment.
After registration, you have to set up your test suite as a GitLab project.
We suggest starting out with forking our Cucumber boilerplate test suite by pressing the fork button right under the repository name. Once you've done that you can then download the repository using the git clone command in combination with the URL that you can find on your newly forked repository page. The resulting command should look similar to this, but using your GitLab account name instead of
$ git clone https://gitlab.spritecloud.com/<GITLAB_ACCOUNT_NAME>/ecommerce-cucumber-web-test-automation-suite.git
If you do not have Git installed, you can read how to install Git for your respective operating system over here. We also recommend taking a look at this Git tutorial if you are unfamiliar with Git and wish to learn more about it before using it.
When we open the project that we just cloned there are two files that we're interested in for setting up our test suite so it can export the results to Calliope.
The '.gitlab.ci.yml' file is where we tell GitLab what command to run when a job gets triggered. When you're using our boilerplate you should see something like this:
GitLab with Selenium image running on Cucumber¶
image: "spritecloud/ruby-selenium-runner:2.6" services: - selenium/standalone-chrome:3.8.1 variables: SELENIUM_URL: "http://selenium__standalone-chrome:4444/wd/hub/" API_KEY: <YOUR_API_KEY> PROFILE_ID: <YOUR_PROFILE_ID> before_script: - bundle install #Install the required gems - export SELENIUM_ENV=remote curl-upload-example: script: - bundle exec cucumber -f json -o ./results/latest_results.json && true - curl -X POST -H "x-api-key:$API_KEY" -H "Content-Type:multipart/formdata" -F "file=@results/latest_results.json" https://app.calliope.pro/api/v2/profile/$PROFILE_ID/import/cucumber?os=myos&platform=myplatform&build=mybuild when: manual
The following variables are defined:
SELENIUM_URL: Is only required for this specific test suite when it's run from GitLab and using the selenium/standalone-chrome service
API_KEY: Required to import tests to Calliope.pro. Can be found on your Calliope.pro account page
PROFILE_ID: Tests will be imported in one of your profiles on Calliope.pro. You can find the ID in the curl command (see below).
The 'script:' part is the command that is going to run when the job gets triggered.
bundle exec cucumber -f json -o ./results/latest_results.json && trueruns all the Cucumber tests and stores the results in './results/latest_results.json'.
&& truemakes sure the next commands are also executed.
curl -X POST ...will import the tests into the Calliope.pro platform.
Make sure the file
@results/latest_results.json points to the results file you generated.
Customized API import curl command¶
You can find and copy your specific API import curl command on the API-Upload tab in the 'Upload a result' window of any profile page.
After you've updated the .gitlab-ci.yml file and committed the changes to your repository, your test suite is ready to import results to Calliope, and you can configure Calliope to use the GitLab jobs you've created.
You have a different example?¶
We're very interested in updating our docs with more examples, so if you have one, feel free to reach out to us!
Configuring GitLab in Calliope.pro¶
We're ready to configure the Calliope.pro profile to use GitLab! Make sure you have set your account GitLab settings on your account page.
Now you can select your GitLab test suite, when we go to our profile that we set our test suite to export to and click 'edit profile' we can select a 'repository' and a 'job' from a list.
Select the repository you created on our GitLab environment and select the job you created in the '.gitlab.ci.yml' file ('curl-upload-example' if you used our boilerplate). Finally, we can save the profile by clicking 'save'.
When we return to our dashboard we can see that something has changed, the disabled play button is now active and we can click it to start a test run. Also our profile's page has a two new tabs, 'log' and 'schedules'. In 'log' we can see the logs of our current or latest test run and in 'schedules' we can let our test suite run according to a schedule that we set.