From ee8af2fdb1b7788fa3ec7d7477d4d5177f613257 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 23 Nov 2018 11:25:22 +0100 Subject: [PATCH 1/5] Move build.sh to bin/build Using bin/ for internal utils is the default for both Rails and Bundler. The script has now no extension and is marked as executable improving its usability (the user doesn't need to know how to deal with each extension) and maintainability (it's easy to switch to a ruby script just changing the shebang line). The doc is updated and env variables are passed with `env` making life easier for some non-bash shells such as fish-shell. --- .gitignore | 1 - CONTRIBUTING.md | 2 +- README.md | 10 +++++----- build.sh => bin/build | 4 ++-- .../getting-started/develop-solidus.html.md | 14 +++++++------- 5 files changed, 15 insertions(+), 16 deletions(-) rename build.sh => bin/build (91%) diff --git a/.gitignore b/.gitignore index 4f34c827369..8ce04a6e84e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ .loadpath .project .ruby-version -bin/* doc Gemfile.lock Gemfile-custom diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index def224821f0..367be5bbaa4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ Here's a quick guide: 2. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate: - $ bash build.sh + $ bin/build 3. Create new branch then make changes and add tests for your changes. Only refactoring and documentation changes require no new tests. If you are adding diff --git a/README.md b/README.md index dc0c409d50f..4e678d8785f 100644 --- a/README.md +++ b/README.md @@ -211,16 +211,16 @@ You can see the build statuses at [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/home) is required to run the frontend and backend test suites. -To execute all of the test specs, run the `build.sh` script at the root of the Solidus project: +To execute all of the test specs, run the `bin/build` script at the root of the Solidus project: ```bash -bash build.sh +bin/build ``` -The `build.sh` script runs using PostgreSQL by default, but it can be overridden by setting the DB environment variable to `DB=sqlite` or `DB=mysql`. For example: +The `bin/build` script runs using PostgreSQL by default, but it can be overridden by setting the DB environment variable to `DB=sqlite` or `DB=mysql`. For example: ```bash -DB=mysql bash build.sh +env DB=mysql bin/build ``` #### Run an individual test suite @@ -236,7 +236,7 @@ By default, `rspec` runs the tests for SQLite 3. If you would like to run specs against another database you may specify the database in the command: ```bash -DB=postgresql bundle exec rspec +env DB=postgresql bundle exec rspec ``` #### Code coverage reports diff --git a/build.sh b/bin/build similarity index 91% rename from build.sh rename to bin/build index 9a13a15a7b8..bf08e1ec5a7 100755 --- a/build.sh +++ b/bin/build @@ -1,8 +1,8 @@ -#!/bin/sh +#!/usr/bin/env bash set -e -# Target postgresql. Override with: `DB=sqlite bash build.sh` +# Target postgresql. Override with: `env DB=sqlite bin/build` export DB=${DB:-postgresql} # Solidus defaults diff --git a/guides/source/developers/getting-started/develop-solidus.html.md b/guides/source/developers/getting-started/develop-solidus.html.md index ad76c1de8dc..6853a00c697 100644 --- a/guides/source/developers/getting-started/develop-solidus.html.md +++ b/guides/source/developers/getting-started/develop-solidus.html.md @@ -34,7 +34,7 @@ You can prepend `DB=mysql` or `DB=postgresql` to the command in order use those databases instead of the default SQLite 3 database. For example: ```bash -DB=postgresql bundle exec rake sandbox +env DB=postgresql bundle exec rake sandbox ``` After the sandbox has been generated, you can change into its directory and @@ -68,19 +68,19 @@ You can see the build statuses [on our CircleCI status page][circleci]. ### Run all Solidus test suites -To execute all of the test specs, run the `build.sh` script at the root of the +To execute all of the test specs, run the `bin/build` script at the root of the Solidus project: ```bash -bash build.sh +bin/build ``` -The `build.sh` script runs using PostgreSQL by default, but it can be overridden +The `bin/build` script runs using PostgreSQL by default, but it can be overridden by setting the `DB` environment variable to `DB=sqlite` or `DB=mysql`. For example: ```bash -DB=mysql bash build.sh +env DB=mysql bin/build ``` Note that this will fail if you have not installed ChromeDriver on your system. @@ -99,7 +99,7 @@ By default, the tests run against the default SQLite 3 database. You can instead specify `DB=mysql` or `DB=postgresql` by prepending it to the command: ```bash -DB=postgresql bundle exec rspec +env DB=postgresql bundle exec rspec ``` ### Generate a code coverage report @@ -108,7 +108,7 @@ You can generate a [SimpleCov][simplecov] code coverage report by prepending `COVERAGE=true` to the `rspec` command: ```bash -COVERAGE=true bundle exec rspec +env COVERAGE=true bundle exec rspec ``` [simplecov]: https://github.com/colszowka/simplecov From 4b0171b9dcba496735403133d6b1478dd6246d35 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 23 Nov 2018 11:30:42 +0100 Subject: [PATCH 2/5] Move build-ci.rb to bin/build-ci --- .circleci/config.yml | 2 +- build-ci.rb => bin/build-ci | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename build-ci.rb => bin/build-ci (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index e0f7c5deeaa..66bff32a87c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,7 +34,7 @@ jobs: - run: name: Run Tests - command: ./build-ci.rb test + command: ./bin/build-ci test - store_artifacts: path: /tmp/test-artifacts diff --git a/build-ci.rb b/bin/build-ci similarity index 100% rename from build-ci.rb rename to bin/build-ci From 5223fec7f67ac29cd7a483197bb705e62d622211 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 23 Nov 2018 11:31:41 +0100 Subject: [PATCH 3/5] Fix indentation of some fenced block in README --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4e678d8785f..4e780832bdc 100644 --- a/README.md +++ b/README.md @@ -159,16 +159,16 @@ Use at own risk. * Clone the Git repo - ```bash - git clone git://github.com/solidusio/solidus.git - cd solidus - ``` + ```bash + git clone git://github.com/solidusio/solidus.git + cd solidus + ``` * Install the gem dependencies - ```bash - bundle install - ``` + ```bash + bundle install + ``` ### Sandbox @@ -188,10 +188,10 @@ data already loaded. * Start the server - ```bash - cd sandbox - rails server - ``` + ```bash + cd sandbox + rails server + ``` ### Tests From cca7b559acdaf5b18de1b69f9710fc3d1ae426f3 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 23 Nov 2018 11:48:57 +0100 Subject: [PATCH 4/5] Add instructions on how to create the PG user To help newcomers with the first run. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4e780832bdc..056dffc3abb 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,7 @@ required to run the frontend and backend test suites. To execute all of the test specs, run the `bin/build` script at the root of the Solidus project: ```bash +createuser --superuser --echo postgres # only the first time bin/build ``` From 0b3409ed693089caa9173160fe32d40ff40dcd81 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 23 Nov 2018 12:44:10 +0100 Subject: [PATCH 5/5] Add instructions on how to setup the MySQL user Many installation will only have a password-less root user available (e.g. Homebrew). --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 056dffc3abb..8633eb78497 100644 --- a/README.md +++ b/README.md @@ -224,6 +224,13 @@ The `bin/build` script runs using PostgreSQL by default, but it can be overridde env DB=mysql bin/build ``` +If the command fails with MySQL related errors you can try creating a user with this command: + +```bash +# Creates a user with the same name as the current user and no restrictions. +mysql --user="root" --execute="CREATE USER '$USER'@'localhost'; GRANT ALL PRIVILEGES ON * . * TO '$USER'@'localhost';" +``` + #### Run an individual test suite Each gem contains its own series of tests. To run the tests for the core project: