Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i configure .gitlab-ci.yml to build my django project

I have succesfully installed and configured gitlab and gitlab-ci-multirunners. What i want to do now is configure the .gitlab-ci.yml file so that it runs python manage.py test and succeed if the tests pass and fail otherwise.

What would be the best approach to achieve this?

like image 386
Luis Del Giudice Avatar asked Oct 09 '15 20:10

Luis Del Giudice


1 Answers

test_app:
  script: python manage.py test

Something like the above should do it. Note, the exit code of the script command determines if the build passes or fails. If you need multiple lines of shell scripts you can use a yaml list:

test_app:
  script:
    - python dosetup.py
    - python manage.py test

test_app is the name of the build job while the script property defines the shell commands to run for the given build job. When using multiple script lines, each line is run as a separate command. If any of the lines return exit code != 0 the build will fail.

By default a build job in .gitlab-ci.yml runs as test. If you need multiple types of build steps you can define them as such:

types:
  - build
  - test

build_app:
  type: build
  script: echo Building!

test_app:
  type: test
  script: python manage.py test

More info in the official documentation: https://docs.gitlab.com/ce/ci/yaml/

like image 129
Snorre Avatar answered Sep 21 '22 03:09

Snorre