From 0a747268b4a268d57532a2cc08dd9d92709d5864 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Fri, 22 Jun 2018 16:55:05 +0900 Subject: [PATCH] Test collapse with a large nested config including rails orb --- cmd/collapse_test.go | 19 ++ .../result.yml | 310 ++++++++++++++++++ .../test/build.yml | 71 ++++ .../test/commands/say.yml | 8 + .../test/executors/parallel.yml | 1 + .../test/jobs/sayhello.yml | 10 + .../test/orbs/foo/commands/zomg.yml | 7 + .../test/orbs/foo/orb.yml | 10 + .../test/orbs/rails/README.md | 17 + .../orbs/rails/commands/bundle_install.yml | 44 +++ .../test/orbs/rails/commands/load_db.yml | 10 + .../test/orbs/rails/commands/run_rspec.yml | 25 ++ .../test/orbs/rails/jobs/build_postgres.yml | 34 ++ .../test/orbs/rails/orb.yml | 0 .../test/orbs/rails/usage/build.yml | 9 + .../orbs/rails/usage/generated_config.yml | 73 +++++ 16 files changed, 648 insertions(+) create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/result.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/build.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/commands/say.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/executors/parallel.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/jobs/sayhello.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/foo/commands/zomg.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/foo/orb.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/README.md create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/bundle_install.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/load_db.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/run_rspec.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/jobs/build_postgres.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/orb.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/usage/build.yml create mode 100644 cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/usage/generated_config.yml diff --git a/cmd/collapse_test.go b/cmd/collapse_test.go index 623ed1d84..c73c7cbfd 100644 --- a/cmd/collapse_test.go +++ b/cmd/collapse_test.go @@ -104,4 +104,23 @@ var _ = Describe("collapse with testdata", func() { Eventually(session).Should(gexec.Exit(0)) }) }) + + Describe("with a large nested config including rails orb", func() { + BeforeEach(func() { + var err error + var path string = "test-with-large-nested-rails-orb" + command = exec.Command(pathCLI, "collapse", "-r", filepath.Join("testdata", path, "test")) + results, err = ioutil.ReadFile(filepath.Join("testdata", path, "result.yml")) + Expect(err).ShouldNot(HaveOccurred()) + }) + + It("collapse all YAML contents as expected", func() { + session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) + session.Wait() + Expect(err).ShouldNot(HaveOccurred()) + Eventually(session.Err.Contents()).Should(BeEmpty()) + Eventually(session.Out.Contents()).Should(MatchYAML(results)) + Eventually(session).Should(gexec.Exit(0)) + }) + }) }) diff --git a/cmd/testdata/test-with-large-nested-rails-orb/result.yml b/cmd/testdata/test-with-large-nested-rails-orb/result.yml new file mode 100644 index 000000000..44876a6a2 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/result.yml @@ -0,0 +1,310 @@ +commands: + foo: + parameters: + mybool: + default: true + type: boolean + steps: + - run: echo in foo + - when: + condition: << parameters.mybool >> + steps: + - run: echo bool is true + - unless: + condition: << parameters.mybool >> + steps: + - run: echo bool is false + say: + description: A simple command that echoes whatever is passed + parameters: + saywhat: + description: What shall we say? + type: string + steps: + - run: echo << parameters.saywhat >> +executors: + parallel: + parallelism: 4 +jobs: + bar: + machine: + docker_layer_caching: << parameters.mybool >> + enabled: << parameters.mybool >> + parameters: + mybool: + default: false + type: boolean + myotherbool: + default: false + type: boolean + mysteps: + default: [] + type: steps + steps: + - checkout + - when: + condition: << parameters.mybool >> + steps: + - << parameters.mysteps >> + - when: + condition: << parameters.mybool >> + steps: + - foo: + mybool: << parameters.myotherbool >> + build-false: + machine: true + steps: + - foo: + mybool: false + build-true: + machine: true + steps: + - foo + sayhello: + description: A job that does very little other than demonstrate what a parameterized + job looks like + machine: true + parameters: + saywhat: + default: World + description: To whom shall we say hello? + type: string + steps: + - say: + saywhat: Hello << parameters.saywhat >> +orbs: + foo: + commands: + zomg: + description: a command inside a folder in an orb + parameters: + tm: + description: Tell me something. + type: string + steps: + - run: echo "You don't say... << parameters.saywhat >>" + description: A simple encapsulation of common tasks in Hugo + executors: + default: + docker: + - image: cibuilds/hugo:<< parameters.image >> + parameters: + tag: + description: The tag to use on the image + type: string + rails: + commands: + bundle_install: + parameters: + bundle_jobs: + default: "3" + type: string + bundle_path: + default: vendor/bundle + type: string + bundle_retry: + default: "3" + type: string + steps: + - run: + command: | + bundle config jobs << parameters.bundle_jobs >> + bundle config path << parameters.bundle_path >> + bundle config retry << parameters.bundle_retry >> + name: Configure bundler + - run: + command: | + gem --version + bundle --version + name: Log versions for debugging + - restore_cache: + keys: + - rails-demo-bundle-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" + }} + - rails-demo-bundle-{{ arch }}-{{ .Branch }}- + - rails-demo-bundle-{{ arch }}-{{ Environment.DEFAULT_BRANCH }}- + name: Restore bundler cache + - run: + command: bundle check || bundle install + name: Bundle Install + - run: + command: bundle clean --force + name: Clear unused bundle gems before saving cache + - save_cache: + key: rails-demo-bundle-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" + }} + paths: + - << parameters.bundle_path >> + load_db: + steps: + - run: + command: dockerize -wait tcp://localhost:5432 -timeout 1m + name: Wait for DB to initialize + - run: + command: bin/rails db:schema:load --trace + name: Database setup + run_rspec: + parameters: + rspec_glob: + default: spec/**/*_spec.rb + type: string + steps: + - run: + command: | + # Determine test subset to run on each container and print diagnostics + TEST_FILES=$(circleci tests glob << parameters.rspec_glob >> | \ + circleci tests split) + echo "running " $(echo $TEST_FILES | wc -w) " tests files on this container:" + echo "$TEST_FILES" + + bundle exec rspec --profile 10 \ + --format RspecJunitFormatter \ + --out CIRCLE_TEST_REPORTS/rspec.xml \ + --format documentation \ + $TEST_FILES + name: Run rspec in parallel + - store_test_results: + path: $CIRCLE_TEST_REPORTS + - store_artifacts: + path: $CIRCLE_ARTIFACTS + jobs: + build_postgres: + docker: + - image: circleci/ruby:<< parameters.ruby >>-node + - environment: + - POSTGRES_USER: << parameters.database_user >> + - POSTGRES_DB: << parameters.database_name >> + - POSTGRES_PASSWORD: << parameters.database_password >> + image: circleci/postgres:<< parameters.postgres >>-alpine-ram + environment: + - CIRCLE_TEST_REPORTS: test_results + - CIRCLE_ARTIFACTS: test_results + - DATABASE_URL: postgres://<< parameters.database_user >>:<< parameters.database_password + >>@127.0.0.1:5432/<< parameters.database_name >> + - RAILS_ENV: test + parameters: + database_name: + default: rails_blog + type: string + database_password: + default: "" + type: string + database_user: + default: circleci-demo-ruby + type: string + postgres: + type: string + rspec_glob: + default: spec/**/*_spec.rb + type: string + ruby: + type: string + steps: + - checkout + - bundle_install + - load_db + - run_rspec + usage: + build: + version: 2 + workflows: + build-test-deploy: + jobs: + - rails/build_postgres: + postgres: 9.6.8 + ruby: 2.5.1 + version: 2 + generated_config: + jobs: + build_postgres: + docker: + - image: circleci/ruby:2.5.1-node + - environment: + - POSTGRES_USER: circleci-demo-ruby + - POSTGRES_DB: rails_blog + - POSTGRES_PASSWORD: "" + image: circleci/postgres:9.6.8-alpine-ram + environment: + - CIRCLE_TEST_REPORTS: test_results + - CIRCLE_ARTIFACTS: test_results + - DATABASE_URL: postgres://circleci-demo-ruby:@127.0.0.1:5432/rails_blog + - RAILS_ENV: test + steps: + - checkout + - run: + command: | + bundle config jobs 3 + bundle config path vendor/bundle + bundle config retry 3 + name: Configure bundler + - run: + command: | + gem --version + bundle --version + name: Log versions for debugging + - restore_cache: + keys: + - rails-demo-bundle-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" + }} + - rails-demo-bundle-{{ arch }}-{{ .Branch }}- + - rails-demo-bundle-{{ arch }}-{{ Environment.DEFAULT_BRANCH }}- + name: Restore bundler cache + - run: + command: bundle check || bundle install + name: Bundle Install + - run: + command: bundle clean --force + name: Clear unused bundle gems before saving cache + - save_cache: + key: rails-demo-bundle-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" + }} + paths: + - vendor/bundle + - run: + command: dockerize -wait tcp://localhost:5432 -timeout 1m + name: Wait for DB to initialize + - run: + command: bin/rails db:schema:load --trace + name: Database setup + - run: + command: | + # Determine test subset to run on each container and print diagnostics + TEST_FILES=$(circleci tests glob spec/**/*_spec.rb | \ + circleci tests split) + echo "running " $(echo $TEST_FILES | wc -w) " tests files on this container:" + echo "$TEST_FILES" + + bundle exec rspec --profile 10 \ + --format RspecJunitFormatter \ + --out CIRCLE_TEST_REPORTS/rspec.xml \ + --format documentation \ + $TEST_FILES + name: Run rspec in parallel + - store_test_results: + path: $CIRCLE_TEST_REPORTS + - store_artifacts: + path: $CIRCLE_ARTIFACTS + version: 2 + workflows: + build-test-deploy: + jobs: + - build_postgres: {} + version: 2 +version: 2 +workflows: + version: 2 + workflow: + jobs: + - build-true + - build-false + - bar: + mybool: true + myotherbool: false + - bar: + mybool: false + myotherbool: true + - bar: + mybool: true + mysteps: + - run: echo i am a steps param, hear me shout + diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/build.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/build.yml new file mode 100644 index 000000000..b09c6f244 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/build.yml @@ -0,0 +1,71 @@ +version: 2 + +commands: + foo: + parameters: + mybool: + type: boolean + default: true + steps: + - run: "echo in foo" + - when: + condition: << parameters.mybool >> + steps: + - run: echo bool is true + - unless: + condition: << parameters.mybool >> + steps: + - run: echo bool is false + +jobs: + build-true: + machine: true + steps: + - foo + build-false: + machine: true + steps: + - foo: + mybool: false + bar: + parameters: + mybool: + type: boolean + default: false + myotherbool: + type: boolean + default: false + mysteps: + type: steps + default: [] + machine: + docker_layer_caching: << parameters.mybool >> + enabled: << parameters.mybool >> + steps: + - checkout + - when: + condition: << parameters.mybool >> + steps: + - << parameters.mysteps >> + - when: + condition: << parameters.mybool >> + steps: + - foo: + mybool: << parameters.myotherbool >> + +workflows: + version: 2 + workflow: + jobs: + - build-true + - build-false + - bar: + mybool: true + myotherbool: false + - bar: + mybool: false + myotherbool: true + - bar: + mybool: true + mysteps: + - run: echo i am a steps param, hear me shout diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/commands/say.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/commands/say.yml new file mode 100644 index 000000000..36d54858c --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/commands/say.yml @@ -0,0 +1,8 @@ +description: "A simple command that echoes whatever is passed" +parameters: + saywhat: + description: "What shall we say?" + type: string +steps: + # note: the interpolation syntax is subject to change + - run: echo << parameters.saywhat >> diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/executors/parallel.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/executors/parallel.yml new file mode 100644 index 000000000..28c7f4b4d --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/executors/parallel.yml @@ -0,0 +1 @@ +parallelism: 4 diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/jobs/sayhello.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/jobs/sayhello.yml new file mode 100644 index 000000000..2be3c054c --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/jobs/sayhello.yml @@ -0,0 +1,10 @@ +description: A job that does very little other than demonstrate what a parameterized job looks like +parameters: + saywhat: + description: "To whom shall we say hello?" + type: string + default: "World" +machine: true +steps: + - say: + saywhat: Hello << parameters.saywhat >> diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/foo/commands/zomg.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/foo/commands/zomg.yml new file mode 100644 index 000000000..11289f015 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/foo/commands/zomg.yml @@ -0,0 +1,7 @@ +description: "a command inside a folder in an orb" +parameters: + tm: + description: "Tell me something." + type: string +steps: + - run: echo "You don't say... << parameters.saywhat >>" diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/foo/orb.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/foo/orb.yml new file mode 100644 index 000000000..d12c0a238 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/foo/orb.yml @@ -0,0 +1,10 @@ +description: "A simple encapsulation of common tasks in Hugo" + +executors: + default: + parameters: + tag: + description: "The tag to use on the image" + type: string + docker: + - image: cibuilds/hugo:<< parameters.image >> diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/README.md b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/README.md new file mode 100644 index 000000000..6b5bf1236 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/README.md @@ -0,0 +1,17 @@ +# rails-orb + +Reusable configuration for Rails projects on CircleCI. Commands and jobs within this orb should abstract away common build configuration and stay up to date with best practices. + +## Getting started + +This repo can be downloaded or sub-tree'd into your `.circleci/orbs` folder in your project. See the [config compiler](https://github.com/circleci/config-compilation) during the internal pre-release period to understand usage in a `build.yml` file that will generate a `config.yml` file. + +See [the rails-postgres build.yml](usage/build.yml) for an example of current syntax. + +## Usage + +Take a look at [rails-orb-demo](https://github.com/circleci/rails-orb-demo) for example how to use this orb in a CircleCI project. + +## Versioning + +Orbs should adhere to a versioning scheme. We recommend using SemVer with [Github Releases](https://help.github.com/articles/creating-releases/). Orb consumers will then be able to download a zip of multiple files, when we add multi-file orb processing to the config compiler. diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/bundle_install.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/bundle_install.yml new file mode 100644 index 000000000..ac57579f0 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/bundle_install.yml @@ -0,0 +1,44 @@ +parameters: + bundle_jobs: + type: string + default: "3" + bundle_retry: + type: string + default: "3" + bundle_path: + type: string + default: vendor/bundle +steps: + - run: + name: Configure bundler + command: | + bundle config jobs << parameters.bundle_jobs >> + bundle config path << parameters.bundle_path >> + bundle config retry << parameters.bundle_retry >> + + - run: + name: Log versions for debugging + command: | + gem --version + bundle --version + + - restore_cache: + name: Restore bundler cache + keys: + - rails-demo-bundle-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }} + - rails-demo-bundle-{{ arch }}-{{ .Branch }}- + - rails-demo-bundle-{{ arch }}-{{ Environment.DEFAULT_BRANCH }}- + + - run: + name: Bundle Install + command: bundle check || bundle install + + - run: + name: Clear unused bundle gems before saving cache + command: bundle clean --force + + - save_cache: + key: rails-demo-bundle-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }} + paths: + - "<< parameters.bundle_path >>" + diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/load_db.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/load_db.yml new file mode 100644 index 000000000..a3d6b4f69 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/load_db.yml @@ -0,0 +1,10 @@ +steps: + # Dockerize is this pre-installed on all CircleCI images + - run: + name: Wait for DB to initialize + command: dockerize -wait tcp://localhost:5432 -timeout 1m + + - run: + name: Database setup + command: bin/rails db:schema:load --trace + diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/run_rspec.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/run_rspec.yml new file mode 100644 index 000000000..69677e5de --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/commands/run_rspec.yml @@ -0,0 +1,25 @@ +parameters: + rspec_glob: + type: string + default: "spec/**/*_spec.rb" +steps: + - run: + name: Run rspec in parallel + command: | + # Determine test subset to run on each container and print diagnostics + TEST_FILES=$(circleci tests glob << parameters.rspec_glob >> | \ + circleci tests split) + echo "running " $(echo $TEST_FILES | wc -w) " tests files on this container:" + echo "$TEST_FILES" + + bundle exec rspec --profile 10 \ + --format RspecJunitFormatter \ + --out CIRCLE_TEST_REPORTS/rspec.xml \ + --format documentation \ + $TEST_FILES + + - store_test_results: + path: $CIRCLE_TEST_REPORTS + + - store_artifacts: + path: $CIRCLE_ARTIFACTS diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/jobs/build_postgres.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/jobs/build_postgres.yml new file mode 100644 index 000000000..ec8593f42 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/jobs/build_postgres.yml @@ -0,0 +1,34 @@ +parameters: + ruby: + type: string + postgres: + type: string + rspec_glob: + type: string + default: "spec/**/*_spec.rb" + database_user: + type: string + default: "circleci-demo-ruby" + database_name: + type: string + default: "rails_blog" + database_password: + type: string + default: "" +environment: + - CIRCLE_TEST_REPORTS: test_results + - CIRCLE_ARTIFACTS: test_results + - DATABASE_URL: postgres://<< parameters.database_user >>:<< parameters.database_password >>@127.0.0.1:5432/<< parameters.database_name >> + - RAILS_ENV: test +docker: + - image: circleci/ruby:<< parameters.ruby >>-node + - image: circleci/postgres:<< parameters.postgres >>-alpine-ram + environment: + - POSTGRES_USER: "<< parameters.database_user >>" + - POSTGRES_DB: "<< parameters.database_name >>" + - POSTGRES_PASSWORD: "<< parameters.database_password >>" +steps: + - checkout + - bundle_install + - load_db + - run_rspec diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/orb.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/orb.yml new file mode 100644 index 000000000..e69de29bb diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/usage/build.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/usage/build.yml new file mode 100644 index 000000000..9e9ed3e34 --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/usage/build.yml @@ -0,0 +1,9 @@ +version: 2 + +workflows: + version: 2 + build-test-deploy: + jobs: + - rails/build_postgres: + ruby: "2.5.1" + postgres: "9.6.8" diff --git a/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/usage/generated_config.yml b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/usage/generated_config.yml new file mode 100644 index 000000000..cf7ba7afb --- /dev/null +++ b/cmd/testdata/test-with-large-nested-rails-orb/test/orbs/rails/usage/generated_config.yml @@ -0,0 +1,73 @@ +version: 2 +workflows: + version: 2 + build-test-deploy: + jobs: + - build_postgres: {} +jobs: + build_postgres: + environment: + - CIRCLE_TEST_REPORTS: test_results + - CIRCLE_ARTIFACTS: test_results + - DATABASE_URL: postgres://circleci-demo-ruby:@127.0.0.1:5432/rails_blog + - RAILS_ENV: test + docker: + - image: circleci/ruby:2.5.1-node + - image: circleci/postgres:9.6.8-alpine-ram + environment: + - POSTGRES_USER: circleci-demo-ruby + - POSTGRES_DB: rails_blog + - POSTGRES_PASSWORD: '' + steps: + - checkout + - run: + name: Configure bundler + command: | + bundle config jobs 3 + bundle config path vendor/bundle + bundle config retry 3 + - run: + name: Log versions for debugging + command: | + gem --version + bundle --version + - restore_cache: + name: Restore bundler cache + keys: + - rails-demo-bundle-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }} + - rails-demo-bundle-{{ arch }}-{{ .Branch }}- + - rails-demo-bundle-{{ arch }}-{{ Environment.DEFAULT_BRANCH }}- + - run: + name: Bundle Install + command: bundle check || bundle install + - run: + name: Clear unused bundle gems before saving cache + command: bundle clean --force + - save_cache: + key: rails-demo-bundle-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + - run: + name: Wait for DB to initialize + command: dockerize -wait tcp://localhost:5432 -timeout 1m + - run: + name: Database setup + command: bin/rails db:schema:load --trace + - run: + name: Run rspec in parallel + command: | + # Determine test subset to run on each container and print diagnostics + TEST_FILES=$(circleci tests glob spec/**/*_spec.rb | \ + circleci tests split) + echo "running " $(echo $TEST_FILES | wc -w) " tests files on this container:" + echo "$TEST_FILES" + + bundle exec rspec --profile 10 \ + --format RspecJunitFormatter \ + --out CIRCLE_TEST_REPORTS/rspec.xml \ + --format documentation \ + $TEST_FILES + - store_test_results: + path: $CIRCLE_TEST_REPORTS + - store_artifacts: + path: $CIRCLE_ARTIFACTS