-
Notifications
You must be signed in to change notification settings - Fork 461
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!
- Control services
- Run commands in service
- Test Suites
- Create data to play with in development
- Debugging
- Reset your Environment
- Troubleshooting
You can bring up/tear down services
docker-compose up -ddocker-compose stop backenddocker-compose restart
check their status
docker-compose ps
or view the output of services
docker-compose logs
If you need to update the frontend service you can rebuild your local image with
docker-compose build --pull frontendYou can run any command in a service by calling exec. This command needs two parameters, the service you want to use and the command you want to execute.
docker-compose exec frontend hostname
You can also start an interactive shell inside the service and run any command you like from it.
docker-compose exec frontend /bin/bash -l
Be sure to have the seeds in your test database with RAILS_ENV=test bundle exec rake db:seed
Run all specs
docker-compose exec frontend rspec
or just a single spec
docker-compose exec frontend rspec spec/models/package_spec.rb
While working on feature specs, by default the tests are running for desktop (large viewport). If you want to run it for mobile (small viewport), you need to set the environment variable CAPYBARA_DRIVER to mobile.
docker-compose exec frontend /bin/bash -lCAPYBARA_DRIVER=mobile rspec spec/feature/beta/something_spec.rb
You can run all tests (including spider)
docker-compose -f docker-compose.yml -f docker-compose.minitest.yml run --rm minitest bundle exec rake testRun a single test file
docker-compose -f docker-compose.yml -f docker-compose.minitest.yml run --rm minitest bundle exec ruby test/mytest_test.rbOr run a single test from a test file
docker-compose -f docker-compose.yml -f docker-compose.minitest.yml run --rm minitest bundle exec ruby test/mytest_test.rb -n test_method_namedocker-compose run --rm frontend rake dev:lint
docker-compose run --rm frontend rake dev:lint:rubocop:auto_correct
This will create some projects, a submit request, an interconnect to build.o.o and a maintenance project.
docker-compose run --rm frontend rake dev:development_testdata:create
If you need some random objects to play around, you can use our factories. For this you can include the FactoryBot syntax on a rails console and use all the commands you usually use in rspec.
include FactoryBot::Syntax::Methods
create_list(:package_with_file, 100)- Add binding.pry to some spec
docker-compose run --rm 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.
docker-compose run --rm --service-ports frontend bash -c "bundle exec rake ts:start && bundle exec rails s -b 0.0.0.0"- Add binding.pry to some code path
- Access your code path and
prywill run
docker-compose run --rm frontend rake db:drop dev:bootstrap
You can remove a single image
docker image rm openbuildservice/frontend-base
or all of them
docker image prune
Sometimes you just have to go back to where you have started....
docker-compose stopdocker-compose rmdocker image prune -arake docker:builddocker-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 1That 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 --buildThe frontend fails to start and you you get the following error trying to create objects via console:
Traceback (most recent call last):
2: from (irb):1
1: from app/mixins/populate_sphinx.rb:5:in `populate_sphinx'
ThinkingSphinx::ConnectionError (Error connecting to Sphinx via the MySQL protocol. Can't connect to MySQL server on '127.0.0.1' (115))Please make sure that you didn't start the frontend with docker-compose up but with the following command:
docker-compose run --rm --service-ports frontend bash -c "(bundle exec rails sphinx:start_for_development &) && rails s -b 0.0.0.0"
Running specs in RSpec might take minutes before finally starting. This can be caused by the strategy used by DatabaseCleaner. As the time of writing, we use truncation. This strategy can be slow depending on the filesystem you use. Switching the strategy to deletion can greatly decrease the time it takes for RSpec to start running specs.
Recommended strategy depending on the filesystem you use:
-
deletionforext4 -
truncationforbtrfs
Your experience might differ, so be sure to give both strategies a try.
- Development Environment Overview
- Development Environment Tips & Tricks
- Spec-Tips
- Code Style
- Rubocop
- Testing with VCR
- Test in kanku
- 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
- Package Versions
- next_rails
- Ruby Update
- Rails Profiling
- 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
- Brakeman
- How to Introduce Software Design Patterns
- Query Objects
- Services
- View Components
- RFC: Core Components
- RFC: Decorator Pattern
- RFC: Backend models
- RFC: Hotwire Turbo Frames Pattern