anthroprose / supermarket

Chef's new Community platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Supermarket

Code Climate Build Status Dependency Status Coverage Status Inline docs

Supermarket is Chef's new community project. Here is a rough roadmap that corresponds to the main outcomes we hope to achieve through improving the Chef community experience:

  • Better facilitation for signing and managing Contribor License Agreements (CLA). #2
  • Storing community member information and presenting it in a more user friendly and manageable way. #2
  • [In Progress] Establishing a low barrier to entry for individuals to contribute and improve the community experience. #2
  • [In Progress] Improving the Cookbooks API to provide more relevant information about individual cookbooks. #3
  • Better organized documentation for various Chef projects. [#4]
  • Chef Server cookbook API. [#4]
  • Dependency API. [#4]
  • Incorporating other community contributions like knife plugins, ohai plugins, and related Chef packages. [#5]
  • Improved Cookbook ratings using automatic multifactor metascore instead of voting. [#6]

Project Status

This project is currently in heavy active development and is a pre-release.

You can follow along with the project development in Trello.

Talk To Us

We have an open project chat on Gitter. There are usually active developers available for collaboration during normal weekly business hours.

Gitter chat

Contributing

We'd love for you to be involved. Read the contributor's workflow for license information and helpful tips before you get started.

There are some project artifacts such as planning docs, wireframes, recorded demos, and team retrospectives in a public Google Drive folder.

If you have questions, feature ideas, or other suggestions, please create a Github Issue and we'll respond in a timely manner.

Continuous Integration

Supermarket is using Travis CI. View build info

OmniAuth

Supermarket uses OmniAuth for linking OAuth accounts to users. You need to create and register Supermarket as an application and setup the keys in the .env file.

To register GitHub as an OmniAuth sign in method:

  1. Register your application
  2. Make sure the Authorization callback URL has the app's URL with the /auth/github/callback path
  3. Add the following to your .env:
GITHUB_KEY: MY_KEY
GITHUB_SECRET: MY_SECRET

where MY_KEY and MY_SECRET are the values given when you created the application.

Adding Additional Providers

You can add support for additional OAUTH providers by creating an extractor object in app/extractors.

Since each OmniAuth provider returns a different set of information, you often end up with nested case statements to account for all the different providers. Supermarket accounts for this behavior using Extractor objects. Each OmniAuth provider must have an associated Extractor object that extracts the correct information from the OmniAuth response hash into a object with a unified interface.

Requirements

  • Ruby 2.0.0
  • PostgreSQL 9.3+

Tests

Run the entire test suite (rspec, rubocop and mocha) with:

bundle exec rake spec:all

Acceptance tests

Acceptance tests are run with Capybara. Run rake spec:features to run the specs in spec/features. The default rake spec also runs these.

When writing a feature, use require 'spec_feature_helper' instead of spec_helper to require the extra configuration and libraries needed to run the feature specs.

The specs run using PhantomJS, which must be installed.

JavaScript Tests

The JavaScript specs are run with Karma and use the Mocha test framework and the Chai Assertion Library

The specs live in spec/javascripts. Run rake spec:javascripts to run the specs, and rake spec:javascripts:watch to run them continuously and watch for changes.

Node.js is required to run the JavaScript tests.

Other Stuff We Need to Document

  • System dependencies
  • Configuration
  • Database creation
  • Database initialization
  • How to run the test suite
  • Services (job queues, cache servers, search engines, etc.)
  • Deployment instructions

Development

Using Vagrant (Beginner)

Supermarket includes a collection of Chef cookbooks and a preconfigured Vagrantfile to make it easy to get up an running without modifying your local system.

  1. Install VirtualBox and Vagrant

  2. Install the vagrant-omnibus plugin:

vagrant plugin install vagrant-omnibus
  1. Run the server:
$ ./bin/supermarket server

The next time you want to start the application, you only need to run:

$ ./bin/supermarket server

Notes

About Vagrant

Vagrant uses VirtualBox to run a VM that has access to the application project files. It syncs your local project files with the VM. Running the ./bin/supermarket server command spins up a VM. When you are done running the application, do not forget to run vagrant suspend or vagrant halt to give the VM a break.

You can read more about Vagrant teardown in the Vagrant docs.

Changing the VM Defaults

By default, the VM uses NFS mounted folders, 4GB of RAM, and 2 CPUs. If you are constrained in any of these areas, you can override these defaults by specifying the environment variables:

$ VM_MEMORY=2048 VM_CPUS=1 VM_NFS=false ./bin/supermarket server

By default, Supermarket will be forwarded locally to port 3000. If for some reason port 3000 is already occupied on your computer you may override this:

$ PORT=5000 ./bin/supermarket server

Supermarket would then be accessible by visiting http://localhost:5000 in this case.

These variables must be set the first time you run any supermarket command. After that, they will be persisted. To change them, you'll need to destroy the Vagrant machine (vagrant destroy) and run the command again.

If your operating system supports NFS mounted folders, you may be asked to supply your administrative password. Please note, sometimes VirtualBox explodes when trying to mount NFS shares (specifically on OSX Mavericks); although it will make the application significantly slower, disabling NFS folder sharing can alleviate an error like:

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory

VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterface, interface IHostNetworkInterface
VBoxManage: error: Context: "int handleCreate(HandlerArg*, int, int*)" at line 68 of file VBoxManageHostonly.cpp

Running sudo /Library/StartupItems/VirtualBox/VirtualBox restart can help fix this problem, but sometimes you just can't use NFS mounts with VirtualBox.

Guest Additions

If you get an error about Guest Additions, install the vagrant-vbguest vagrant plugin:

vagrant plugin install vagrant-vbguest

Switching from Vagrant to Local Environment Development

If you want to switch from Vagrant to your developing locally, you have two options:

When Vagrant runs bundle install it installs the gems into vendor/ruby/gems. This is because of the Bundler config in .bundle/config.

  1. If you want to continue to install gems in vendor/ruby/gems, delete that directory and run bundle install. This will rebuild the gems with native dependencies on your local machine instead of the Vagrant VM.
  2. If you want to install your gems system wide, delete the .bundle directory.

Local Environment (Advanced)

  1. Install Ruby 2.0 (latest patch) using your favorite Ruby manager

  2. Install Postgres (from homebrew or the app)

  3. Install Redis (required to run background jobs)

  4. Make sure both Postgres and the Redis server are running

  5. Install bundler

     $ gem install bundler
    
  6. Install required gems:

     $ bundle
    
  7. Configure the dotenv keys and secrets. See .env.example for required keys and secrets to get up and running. docs/CONFIGURING.md goes into detail about the not so straight forward configuration that needs to happen to get Supermarket working locally.

  8. Run the migrations:

     $ ./bin/rake db:create && ./bin/rake db:migrate && ./bin/rake db:seed
    
  9. Start the server:

     $ foreman start
    

Deployment

Deploying with Chef

  1. Upload the supermarket cookbook to your Chef server.

     $ knife cookbook upload supermarket -o path-to-supermarket-repo/chef/cookbooks
    
  2. Bootstrap a server as a new node.

     $ knife bootstrap someserver.com -u some-user -N some-node
    
  3. Change the defaults in chef/data_bags/apps/supermarket.json and upload this databag to your Chef server.

     $ knife data bag from file apps path-to-supermarket-repo/chef/data_bags
    
  4. Add the supermarket cookbook to your newly bootstraped nodes run list.

     $ knife node run_list add some-node 'recipe[supermarket]'
    
  5. Override any default attributes found in chef/cookbooks/supermarket/attributes/default.rb in a role or environment as needed.

  6. SSH into your node and run chef-client this will deploy supermarket.

     ssh some-user@someserver.com
     chef-client
    

About

Chef's new Community platform

License:Apache License 2.0


Languages

Language:Ruby 88.9%Language:CSS 8.6%Language:Shell 1.4%Language:JavaScript 1.1%