diff options
author | Manthan Mallikarjun <nahtnam@gmail.com> | 2016-07-04 10:20:16 -0700 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-10-11 09:29:14 +0200 |
commit | 987c21f51ea67f1bd00fe50e61941920bc1feaa4 (patch) | |
tree | 96119122ab9bf69ac2b6e9cdae3bde61ae8fb3e2 /doc/ci | |
parent | 73adae0f62a3d6048abbee9d076e077185370325 (diff) | |
download | gitlab-ce-987c21f51ea67f1bd00fe50e61941920bc1feaa4.tar.gz |
Add an example for testing a phoenix application with Gitlab CI.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'doc/ci')
-rw-r--r-- | doc/ci/examples/README.md | 1 | ||||
-rw-r--r-- | doc/ci/examples/test-phoenix-application.md | 52 |
2 files changed, 53 insertions, 0 deletions
diff --git a/doc/ci/examples/README.md b/doc/ci/examples/README.md index 40f0165deef..08fbd9afa2f 100644 --- a/doc/ci/examples/README.md +++ b/doc/ci/examples/README.md @@ -11,6 +11,7 @@ Apart from those, here is an collection of tutorials and guides on setting up yo - [Test and deploy a Python application to Heroku](test-and-deploy-python-application-to-heroku.md) - [Test a Clojure application](test-clojure-application.md) - [Test a Scala application](test-scala-application.md) +- [Test a Phoenix application](test-phoenix-application.md) - [Using `dpl` as deployment tool](deployment/README.md) - [Blog post about using GitLab CI for iOS projects](https://about.gitlab.com/2016/03/10/setting-up-gitlab-ci-for-ios-projects/) - [Repositories with examples for various languages](https://gitlab.com/groups/gitlab-examples) diff --git a/doc/ci/examples/test-phoenix-application.md b/doc/ci/examples/test-phoenix-application.md new file mode 100644 index 00000000000..78cab2c0aeb --- /dev/null +++ b/doc/ci/examples/test-phoenix-application.md @@ -0,0 +1,52 @@ +## Test a Phoenix application + +This example demonstrates the integration of Gitlab CI with Phoenix, elixir and +postgres. + +### Add `.gitlab-ci.yml` file to project + +The following `.gitlab-ci.yml` should be added in the root of your +repository to trigger CI: + +```yaml +image: elixir:1.3.1 + +services: + - postgres:9.5.3 + +variables: + MIX_ENV: "test" + +before_script: + # Setup phoenix dependencies + - apt-get update + - apt-get install -y postgresql-client + - mix local.hex --force + - mix deps.get --only test + - mix ecto.reset + +test: + script: + - mix test +``` + +The variables will set the Mix environment to test. The +before_script will install `psql`, and other phoenix dependencies and will also +run your migrations. + +Finally, the test script will run your tests. + +### Update the Config Settings + +In `config/test.exs`, update the database hostname: +``` +config :my_app, MyApp.Repo, + hostname: if(System.get_env("CI"), do: "postgres", else: "localhost"), +``` + +### Add the Migrations Folder + +If you do not have any migrations yet, you will need to create an empty +`.gitkeep` file in `priv/repo/migrations`. + +**Source**: https://medium.com/@nahtnam/using-phoenix-on-gitlab-ci-5a51eec81142 |