Travis detecting Ruby default settings in a Django project - django

I have a Django project that I want to test continuously using Travis-CI. The problem is that every time I run a build in Travis it fails because a rake command of ruby.
I have already changed my travis.yml a hundred times but it's not working. I leave my last travis.yml that is in the same directory that my requirements.txt
language: python
python:
- "3.5"
- "3.6"
- "3.7"
cache: pip
services:
- sqlite3
env:
- DJANGO=2.2.4 DB=sqlite3
install:
- pip install -r requirements.txt
before_script:
- sqlite3 - e 'create database test;' -u root
script:
- python manage.py makemigrations
- python manage.py migrate
- python manage.py test
The output I get from travis is this:
rvm
$ git clone --depth=50 --branch=master ...
1.01s$ rvm use default
ruby.versions
$ ruby --version
No Gemfile found, skipping bundle install
0.21s$ rake
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/home/travis/.rvm/gems/ruby-2.5.3#global/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/home/travis/.rvm/gems/ruby-2.5.3#global/bin/ruby_executable_hooks:24:in `eval'
/home/travis/.rvm/gems/ruby-2.5.3#global/bin/ruby_executable_hooks:24:in `<main>'
(See full trace by running task with --trace)
The command "rake" exited with 1.
Done. Your build exited with 1.

Rename travis.yml to .travis.yml.
See more at Getting started and Building a Python projects

Related

How to run two commands on Github Actions instance one after another?

So question seems easy but let me start with this, ";" "&" does not work.
The two commands to be ran on Github actions instance in CI/CD pipeline :
python3 manage.py runserver
python3 abc.py
After putting the command in the yaml file, only the first command runs and then the workflow is stuck there only and does not executes the second command.
I have tried putting in two separate blocks in workflow yaml file but no luck.
There are two to run commands one after another on Github Actions.
On the same step:
steps:
- name: Run both python files
run: |
python manage.py runserver
python abc.py
On different steps (that will run in sequence):
steps:
- name: Run first python file
run: python manage.py runserver
- name: Run second python file
run: python abc.py
Also, you don't need to inform python3, just python is enough, as you will use the setup/python action informing the version first.
Therefore, your whole workflow would probably look like this:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository content
uses: actions/checkout#v2.3.4
- name: Setup Python Version
uses: actions/setup-python#v2
with:
python-version: 3.8
- name: Install Python dependencies
run: python -m pip install --upgrade pip [...] # if necessary
- name: Execute Python scripts
run: |
python manage.py runserver
python abc.py

Bulid error on Travis CI to Django 3.0.3 on GitHub repo

After adding .travis.yml file to project directory, travis ci is giving me errors that I can't solve.
.travis.yml looks like this:
language: python
python:
- "3.7"
# command to install dependencies
install:
- pip install -r requirements.txt
# command to run tests
script: pytest
The error I get is:
Worker information
0.14s0.01s0.00s0.01s
system_info
Build system information
0.01s0.00s0.35s0.21s0.05s0.00s0.04s0.00s0.01s0.01s0.01s0.01s0.01s0.00s0.00s0.02s0.00s0.01s0.30s0.00s0.00s0.00s0.01s0.00s0.12s0.01s0.81s0.00s0.00s6.03s0.00s2.73s0.00s2.28s
docker_mtu
resolvconf
git.checkout
1.05s$ git clone --depth=50 --branch=master https://github.com/ChrisAchinga/The-Diary.git ChrisAchinga/The-Diary
0.01s0.01s$ source ~/virtualenv/python3.7/bin/activate
$ python --version
Python 3.7.1
$ pip --version
pip 19.0.3 from /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/pip (python 3.7)
install
10.77s$ pip install -r requirements.txt
0.40s$ pytest
============================= test session starts ==============================
platform linux -- Python 3.7.1, pytest-4.3.1, py-1.7.0, pluggy-0.8.0
rootdir: /home/travis/build/ChrisAchinga/The-Diary, inifile:
collected 0 items
========================= no tests ran in 0.05 seconds =========================
The command "pytest" exited with 5.
Done. Your build exited with 1.
The error from travis
The link to github: https://github.com/ChrisAchinga/The-Diary

Coveralls is not being submitted on a Django app with Docker

I'm working on a Django project using Docker. I have configured Travis-Ci and I want to submit test coverage to coveralls. However, it is not working as expected. any help will be highly appreciated.
Here is the error I'm getting
Submitting coverage to coveralls.io...
No source for /mwibutsa/mwibutsa/settings.py
No source for /mwibutsa/mwibutsa/urls.py
No source for /mwibutsa/user/admin.py
No source for /mwibutsa/user/migrations/0001_initial.py
No source for /mwibutsa/user/models.py
No source for /mwibutsa/user/tests/test_user_api.py
No source for /mwibutsa/user/tests/test_user_model.py
Could not submit coverage: 422 Client Error: Unprocessable Entity for url: https://coveralls.io/api/v1/jobs
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/coveralls/api.py", line 177, in wear
response.raise_for_status()
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://coveralls.io/api/v1/jobs
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/coveralls/cli.py", line 77, in main
result = coverallz.wear()
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/coveralls/api.py", line 180, in wear
raise CoverallsException('Could not submit coverage: {}'.format(e))
coveralls.exception.CoverallsException: Could not submit coverage: 422 Client Error: Unprocessable Entity for url: https://coveralls.io/api/v1/jobs
**Here is my Travis.yml file**
language: python
python:
- "3.7"
services: docker
before_script: pip install docker-compose
script:
- docker-compose run web sh -c "coverage run manage.py test && flake8 && coverage report"
after_success:
- coveralls
language: python
python:
- "3.7"
services: docker
before_script: pip install docker-compose
script:
- docker-compose run web sh -c "coverage run manage.py test && flake8 && coverage report"
after_success:
- coveralls
My Dockerfile
FROM python:3.7-alpine
LABEL description="Mwibutsa Floribert"
ENV PYTHONUNBUFFERED 1
RUN mkdir /mwibutsa
WORKDIR /mwibutsa
COPY requirements.txt /mwibutsa/
RUN apk add --update --no-cache postgresql-client jpeg-dev
RUN apk add --update --no-cache --virtual .tmp-build-deps gcc libc-dev linux-headers postgresql-dev musl-dev zlib zlib-dev
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN apk del .tmp-build-deps
COPY . /mwibutsa/
My docker-compose.yml
version: '3.7'
services:
web:
build: .
command: >
sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=postgres
- DB_PASSWORD=password
- DB_USER=postgres
- DB_PORT=5432
volumes:
- .:/mwibutsa
ports:
- "8000:8000"
depends_on:
- db
db:
image: postgres:12-alpine
environment:
- POSTGRES_NAME=postgres
- POSTGRES_PASSWORD=password
- POSTGRES_USER=postgres
- POSTGRES_PORT=5432
To understand why the coverage is not being submitted, you have to understand how docker containers operate.
The container is created to mimic a separate and independent unit. This means that commands being run in the global context are different from those being run inside the container context.
In your case, you are running tests and generating a coverage report inside the container's context then trying to submit a report to coveralls from the global context.
Since the file is in the container, the coveralls command cannot find the report and hence nothing gets submitted.
You may refer to the answer provided here to solve this:
Coveralls: Error- No source for in my application using Docker container
Or check out the documentation provided by travis on how to submit to coveralls from travis using docker:
https://docs.travis-ci.com/user/coveralls/#using-coveralls-with-docker-builds
You have to run coveralls inside the container so it can send the data file generated by coverage to coveralls.io. You have to run coverage again in the after_success command so the .coverage data file is present in the container when coveralls runs. You also have to pass the coveralls repo token in as an environment variable that you set in travis https://docs.travis-ci.com/user/environment-variables#defining-variables-in-repository-settings.
.travis.yml
language: python
python:
- "3.7"
services: docker
before_script: pip install docker-compose
script:
- docker-compose run web sh -c "coverage run manage.py test && flake8 && coverage report"
after_success:
- docker-compose run web sh -c "coverage run manage.py test && TRAVIS_JOB_ID=$TRAVIS_JOB_ID TRAVIS_BRANCH=$TRAVIS_BRANCH COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN coveralls"
You need to make sure your git repo files are copied into the container for coveralls to accurately report the branch and have the badge work. You might also need to install git in the container.
Dockerfile:10
RUN apk add --update --no-cache postgresql-client jpeg-dev git

I got an error when deploy Django appliction to IBM Bluemix

I got an error when deploy Django application to IBM Bluemix. When i see log it's show this.
2015-09-09T22:08:00.05+0700 [STG/0] ERR You are using pip version 6.1.0
.dev0, however version 7.1.2 is available.
2015-09-09T22:08:00.05+0700 [STG/0] ERR You should consider upgrading via t
he 'pip install --upgrade pip' command.
2015-09-09T22:08:00.28+0700 [STG/0] OUT -----> Preparing static assets
2015-09-09T22:08:01.02+0700 [STG/0] OUT Running collectstatic...
2015-09-09T22:08:01.84+0700 [STG/0] OUT 175 static files copied to '
/app/static'.
2015-09-09T22:08:17.95+0700 [STG/166] OUT -----> Uploading droplet (46M)
2015-09-09T22:08:34.18+0700 [DEA/166] OUT Starting app instance (index 0) wit
h guid a416b8bf-5d53-47d5-9d99-d39c4730cd22
2015-09-09T22:09:03.53+0700 [API/4] OUT App instance exited with guid a416b
8bf-5d53-47d5-9d99-d39c4730cd22 payload: {"cc_partition"=>"default", "droplet"=>
"a416b8bf-5d53-47d5-9d99-d39c4730cd22", "version"=>"31f9acf2-6bf7-4709-83fd-2ce0
00fa4483", "instance"=>"f4fc8d2f0e4f4bdeb4260fa8cae1f68f", "index"=>0, "reason"=
>"CRASHED", "exit_status"=>2, "exit_description"=>"app instance exited", "crash_
timestamp"=>1441811343}
For deploy appliction i have 3 files, that is requirements.txt, manifest.yml and run.sh file.
in my manifest.yml file
applications:
- name: RoyalCaninExam
memory: 256M
# This is command provided by cf -c option
command: bash ./run.sh
buildpack: python_buildpack
path: .
services:
- mysql-royalcanin
and in run.sh file
if [ -z "$VCAP_APP_PORT" ];
then SERVER_PORT=5000;
else SERVER_PORT="$VCAP_APP_PORT";
fi
echo [$0] port is------------------- $SERVER_PORT
python manage.py syncdb --noinput
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin#admin.com', 'admin')" | python manage.py shell
echo [$0] Starting Django Server...
python manage.py runserver 0.0.0.0:$SERVER_PORT --noreload
It looks like your run.sh script is not running as there is no output in your log. Please make sure that your run.sh does not contain any Windows EOL encoding as this causes problems with the Python buildpack. Change any EOL encoding in that file to UNIX using a file editor of your choice.

django webserver on travis for e2e testing

A quick question for some Django / Travis pros.
I would like to run some e2e tests on travis for my django/angular app, and connect to sauceLabs through a sauceConnect tunnel.
//travis.yml
addons:
sauce_connect: true
postgresql: "9.3"
branches:
only:
- master
- integration_env
language: python
python:
- '2.7.9'
cache:
directories:
- $HOME/virtualenv/python2.7.9/lib/python2.7/site-packages
- node_modules
- bower_components
install:
- npm install
- pip install -r requirements.txt
- pip install coverage -U --force-reinstall
- pip install coveralls -U --force-reinstall
- node_modules/protractor/bin/webdriver-manager update
before_script:
- psql -c 'create database travisci;' -U postgres
- pg_restore --no-acl --no-owner -h localhost -U postgres -d travisci demoDB.dump
- python manage.py runserver &
script:
# - grunt karma:sauceTravis
- grunt protractor:sauceLabs
- coverage run --source='.' manage.py test
after_success:
- grunt coveralls:run
- coveralls --merge=coverage/lcov/coveralls.json
I try to run a django webserver on my travis CI environment. I do this in a before_script after I create my database.
When I try to ping localhost:8000, however, I get a "bad gateway 301" response. Says something about dirty ssl?
If anyone has any advice about how to go about debugging this, I would be grateful.
Thanks