As we saw in the Travis CI section, it is possible to build and test pure Swift programs on Linux systems. We will use this capability in GitLab. With the help of the official prebuilt Docker images, we can quickly set up the free, continuous integration on GitLab.
In your project, add a .gitlab-ci.yml file and insert the following into it:
test:
image: swift:4.2.1
script:
- swift package update
- swift test
Line by line, here is what the code is doing:
- image: Indicates we will use the official Swift Docker image, with Swift Version 4.2.1.
- script: Indicates the list of scripts to run; each step should succeed and exit with code 0.
Push those changes to your GitLab repository and you will see that your project will be tested, as you would do locally.
The tests that are run are the ones exposed in LinuxMain.swift.