-
Notifications
You must be signed in to change notification settings - Fork 444
Development Environment Tips & Tricks
This page is collection of tips & tricks about our development environment. For and introduction how to setup the development environment check out our contribution guide.
This will not and can not replace docker and docker-compose documentation. You are strongly encouraged get familiar with those tools!
docker-compose up
docker-compose stop
docker-compose restart
docker-compose up cache
docker-compose stop backend
docker-compose restart db
docker-compose ps
docker-compose exec frontend /bin/bash -l
You can run any command in running services by calling docker-compose exec
. This
command needs two parameters, the service you want to use and the command you
want to execute.
For example, to run a single test call
docker-compose exec frontend rspec spec/mixins/statistics_calculations_spec.rb
docker-compose up
- Add binding.pry to some spec
docker-compose exec frontend rspec spec/mixins/statistics_calculations_spec.rb
Debugging the running rails application will start the pry
session in the rails
output so you need to start the rails server
on it's own.
- Add binding.pry to some code path
docker-compose up -d worker backend cache db
docker-compose run --rm --service-ports frontend rails server
- Access your code path and pry will run
To run the features, you will need selenium up and running. To run a single rspec you can do the following:
docker-compose -f docker-compose.yml -f docker-compose.selenium.yml run --service-ports --use-aliases --rm frontend rspec spec/features/my_cool_feature_spec.rb
To run the test your the new UI (Bootstrap) check: How-to-work-in-Bootstrap-(new-UI)#how-to-run-tests.
Do not forget to prepare the database before. To do it run in the container the following commands:
bundle exec rake dev:bootstrap RAILS_ENV=test
bundle exec rake db:seed RAILS_ENV=test
While working on feature specs, you can follow what is happening live in Capybara's driver.
Steps:
- Launch our Docker Compose setup for Capybara
docker-compose -f docker-compose.yml -f docker-compose.selenium.yml run --service-ports --use-aliases --rm frontend bash -l
- Connect to Capybara's driver with your VNC client at
localhost
. For example, inTigerVNC viewer
, you typelocalhost
in theVNC Server
field and then press theConnect
button. -
Optional: Set a breakpoint in your feature specs with Pry:
binding.pry
- Run some feature specs, for example:
bundle exec rspec spec/features/something_spec.rb
. You will now start to see in your VNC client that Capybara is running. -
Optional: Debug with the usual Pry (+ byebug) commands, such as:
next
,continue
, etc...
docker-compose -f docker-compose.yml -f docker-compose.minitest.yml run --rm minitest bundle exec rake test
docker-compose -f docker-compose.yml -f docker-compose.minitest.yml run --rm minitest bundle exec ruby test/mytest_test.rb
docker-compose -f docker-compose.yml -f docker-compose.minitest.yml run --rm minitest bundle exec ruby test/mytest_test.rb -n test_method_name
docker-compose run --rm frontend rake db:drop dev:bootstrap
docker-compose stop
docker-compose rm
docker-compose stop frontend
docker-compose rm frontend
docker image prune
docker image rm openbuildservice/frontend-base
If you need to change one of the static images/Dockerfiles you can rebuild your local images with
rake docker:maintainer:rebuild
To publish the containers to the docker hub (you need access to the openbuildservice organization). Note that new docker images are automatically built whenever master changes. This happens via the GitHub docker service.
If needed, you can manually publish the built docker files with
rake docker:maintainer:publish
If you need to change the frontend Dockerfile you can rebuild your local image with
docker-compose build frontend
in your pull request that changed the Dockerfile let the other developers (@openSUSE/open-build-service) know that they need to rebuild their frontend container...
There are a couple of rake tasks that you can run in your git checkout.
rake dev:lint
runs from src/api
rake haml_lint
runs from src/api
rake dev:lint:rubocop:auto_correct
runs from src/api
Please note that this needs to get executed inside the frontend container.
rake dev:development_testdata:create
This will create some projects, a submit request, an interconnect to build.o.o and a maintenance project.
Sometimes you just have to go back to where you have started....
docker-compose stop
docker-compose rm
docker image prune -a
rake docker:build
docker-compose up
The frontend fails to start and you see a message like
frontend_1 | 09:25:14 web.1 | A server is already running. Check /obs/src/api/tmp/pids/server.pid.
...
openbuildservice_frontend_1 exited with code 1
That can happen if a docker instance forcefully get's shut down and thus doesn't clean up properly. To solve this delete the pid file with
rm tmp/pids/server.pid
The frontend fails to start and you see a message like
frontend_1 | 10:53:17 web.1 | /usr/lib64/ruby/gems/2.4.0/gems/bundler-1.13.6/lib/bundler/definition.rb:179:in
`rescue in specs': Your bundle is locked to mail (2.7.0), but that version could not be found in any of the sources
listed in your Gemfile. If you haven't changed sources, that means the author of mail (2.7.0) has removed it. You'll
need to update your bundle to a different version of mail (2.7.0) that hasn't been removed in order to install.
(Bundler::GemNotFound)
...
openbuildservice_frontend_1 exited with code 1
That can happen if you or someone else changed our bundle by updating a gem version or introducing a new gem. You have to bundle install
again in your frontend container. You can do this simply by
docker-compose up --build
The frontend fails to start and you see a message starting sphinx. The indexes must be rebuild. You can do this with:
docker-compose run frontend bash
> rake ts:index
- Development Environment Overview
- Development Environment Tips & Tricks
- Spec-Tips
- Code Style
- Rubocop
- Testing with VCR
- Authentication
- Authorization
- Autocomplete
- BS Requests
- Events
- ProjectLog
- Notifications
- Feature Toggles
- Build Results
- Attrib classes
- Flags
- The BackendPackage Cache
- Maintenance classes
- Cloud uploader
- Delayed Jobs
- Staging Workflow
- StatusHistory
- OBS API
- Owner Search
- Search
- Links
- Distributions
- Repository
- Data Migrations
- next_rails
- Ruby Update
- Rails Profiling
- Installing a local LDAP-server
- Remote Pairing Setup Guide
- Factory Dashboard
- osc
- Setup an OBS Development Environment on macOS
- Run OpenQA smoketest locally
- Responsive Guidelines
- Importing database dumps
- Problem Statement & Solution
- Kickoff New Stuff
- New Swagger API doc
- Documentation and Communication
- GitHub Actions
- How to Introduce Software Design Patterns
- Query Objects
- Services
- View Components
- RFC: Core Components
- RFC: Decorator Pattern
- RFC: Backend models