Gitlab also allows you to define secret variables on a per-project basis, but there’s no need for that here.
Finally, we’ll add our before_script section, which just updates apt-get and loads the dependencies.
1 2 3
before_script: - apt-get update -y - lein deps
Update: Notice that I’m updating the package lists using apt-get. This is necessary because I’ll also need to install the Postgres client. If you don’t need to install anything using apt, you might save some build time by removing that line.
Before proceeding to test, we’ll install the Postgres client, initialize the database (adding some plugins), and run the migrations.
1 2 3 4 5 6
test: script: - apt-get install postgresql-client -y - psql -h postgres -U postgres < db-setup.sql - lein with-profile test run migrate - lein test
And voilá! Tests will run on push. You can find a history for the status of the Pipelines section of your project.
If for any reason you don’t see a Pipelines option, make sure that Builds are enabled in the project’s settings.