Problem I’m trying to set up a test stage in Gitlab’s CI/CD. Locally, running the unit tests goes fine and as expected. In Gitlab’s CI/CD, though, when running the script coverage run manage.py test -v 2 && coverage report the unit tests are executing before the migrations are completed in the test database, which is unexpected, and will always fail.
Tag: gitlab
How to create a new branch, push a text file and send merge request to a gitlab repository using Python?
I found https://github.com/python-gitlab/python-gitlab, but I was unable to understand the examples in the doc. Answer That’s right there are no tests we can find in the doc. Here’s a basic answer for your question. If you would like a complete working script, I have attached it here: https://github.com/torpidsnake/common_scripts/blob/main/automation_to_create_push_merge_in_gitlab/usecase_gitlab_python.py Breaking down the steps below: Create an authkey for you: Follow the
How to run pylint only on changed files in Gitlab?
I’m trying to run pylint only on changed python files, but my build keeps failing. I have extracted the changed files through git diff and saved them in a variable, but when I inject the variable into the pylint call, it fails. It works fine with a hardcoded filename however. Here is my yaml: Answer While qathulu answer is adequate,
How can I extract contents from a file stored in gitlab repos
Using the gitlab-python package, I’d like to extract lines from all Dockerfiles. Using my code below, I am able to get project names and url to the repo I want but how can I ensure there is a Dockerfile and read the contents of the Dockerfile. The output I get now is : Answer You can use the project.files.get() method