0

Currently I am stuck with trying to configure the gitlab-ci.yml file. Im trying to automatically build and test my python code when I made a commit. At the moment, I just wanted to build a simple hello world program and purposely put a mistake within the python file by misspelling print (printt instead of print). When I commit, the pipeline is run, but it seems to successfully pass the build and test phase (which it shouldn't).

Any help how to properly configure the gitlab-ci.yml file to automatically test python codes?

I've also attached my current gitlab-ci.yml file.

enter image description here Thank you

2
  • For improvement, could you paste your file in the question instead of using an image? You can use the source code formatting to make it look nice :). It will attract answers ;). Commented Nov 23, 2018 at 14:04
  • Thank you for the advice David, I've made the changes to my post :D Commented Nov 23, 2018 at 14:34

2 Answers 2

2

It's dead simple. Here is minimal working example I use in my repo:

pytest:
  image: python:3.6
  script:
    - apt-get update -q -y
    - pip install -r requirements.txt
    - pip install -r requirements-dev.txt
    - pytest  # or pytest tests/

source

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! this is really useful!
@EndisSapuandi mark answer as solved if this solves your problem
0

Pytest will bring in failed pipleine. like our

Pytest configurations

Pytest failure

It would be wonderful if you configure unittests

unittest configuration

unitest

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.