gitlab-org--gitlab-foss/doc/ci/examples/test-clojure-application.md

36 lines
1.2 KiB
Markdown
Raw Normal View History

2017-11-01 15:56:40 +00:00
# Test a Clojure application with GitLab CI/CD
2015-08-26 01:42:46 +00:00
This example will guide you how to run tests in your Clojure application.
You can checkout the example [source](https://gitlab.com/dzaporozhets/clojure-web-application) and check [CI status](https://gitlab.com/dzaporozhets/clojure-web-application/builds?scope=all).
2015-08-26 01:42:46 +00:00
2017-11-01 15:56:40 +00:00
## Configure the project
2015-08-26 01:42:46 +00:00
This is what the `.gitlab-ci.yml` file looks like for this project:
```yaml
variables:
POSTGRES_DB: sample-test
DATABASE_URL: "postgresql://postgres@postgres:5432/sample-test"
before_script:
- apt-get update -y
- apt-get install default-jre postgresql-client -y
- wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
- chmod a+x lein
- export LEIN_ROOT=1
- PATH=$PATH:.
- lein deps
- lein migratus migrate
2017-11-01 15:56:40 +00:00
test:
script:
2015-08-26 01:42:46 +00:00
- lein test
```
2017-11-01 15:56:40 +00:00
In before script we install JRE and [Leiningen](http://leiningen.org/).
Sample project uses [migratus](https://github.com/yogthos/migratus) library to manage database migrations.
2015-08-26 01:42:46 +00:00
So we added database migration as last step of `before_script` section
2015-09-15 22:28:59 +00:00
You can use public runners available on `gitlab.com` for testing your application with such configuration.