From e0d3cf4ad721c491e2817b0fd352dcc53a1159a3 Mon Sep 17 00:00:00 2001 From: gazayas Date: Sat, 8 Jul 2023 18:43:02 +0900 Subject: [PATCH 1/3] Remove unneeded test --- test/magic_test_test.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/magic_test_test.rb b/test/magic_test_test.rb index b10b1b1..41739ed 100644 --- a/test/magic_test_test.rb +++ b/test/magic_test_test.rb @@ -4,8 +4,4 @@ class MagicTestTest < Minitest::Test def test_that_it_has_a_version_number refute_nil ::MagicTest::VERSION end - - def test_it_does_something_useful - assert false - end end From f7e4ebaa0b25ca7f47700044213882b7587ec41e Mon Sep 17 00:00:00 2001 From: gazayas Date: Sat, 8 Jul 2023 19:10:03 +0900 Subject: [PATCH 2/3] Add starter repo setup script for CircleCI --- bin/checkout-and-link-starter-repo | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 bin/checkout-and-link-starter-repo diff --git a/bin/checkout-and-link-starter-repo b/bin/checkout-and-link-starter-repo new file mode 100644 index 0000000..a46559f --- /dev/null +++ b/bin/checkout-and-link-starter-repo @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# TODO: This is overkill for the magic_test repository so it should be cleaned up, +# we just need to clone the starter repository so the file is the same as what you find in bullet_train-core. + +# Default to the main branch if we don't find a matching branch on the starter repository. +STARTER_REPO_BRANCH="main" + +# Look for a matching branch on the starter repository when running tests on CircleCI. +CI_BRANCH=$CIRCLE_BRANCH +if [[ -v CI_BRANCH ]]; then + BRANCH_RESPONSE=$(curl --head -H "Accept: application.vnd.github+json" https://api.github.com/repos/bullet-train-co/bullet_train/branches/$CI_BRANCH) + + if echo $BRANCH_RESPONSE | grep "200"; then + STARTER_REPO_BRANCH=$CI_BRANCH + fi +fi + +echo "Cloning from ${STARTER_REPO_BRANCH}..." +git clone -b $STARTER_REPO_BRANCH --depth 1 https://github.com/bullet-train-co/bullet_train.git . + +packages=( + "bullet_train" + "bullet_train-api" + "bullet_train-fields" + "bullet_train-has_uuid" + "bullet_train-incoming_webhooks" + "bullet_train-integrations" + "bullet_train-integrations-stripe" + "bullet_train-obfuscates_id" + "bullet_train-outgoing_webhooks" + "bullet_train-roles" + "bullet_train-scope_questions" + "bullet_train-scope_validator" + "bullet_train-sortable" + "bullet_train-super_load_and_authorize_resource" + "bullet_train-super_scaffolding" + "bullet_train-themes" + "bullet_train-themes-light" + "bullet_train-themes-tailwind_css" +) + +for package in "${packages[@]}" +do + : + grep -v "gem \"$package\"" Gemfile > Gemfile.tmp + mv Gemfile.tmp Gemfile + echo "gem \"$package\", path: \"../../$package\"" >> Gemfile +done + +updates="${packages[@]}" +bundle lock --update $updates \ No newline at end of file From 663f47d6ebc0e12b3b4a06650858f2cfb99ea71e Mon Sep 17 00:00:00 2001 From: gazayas Date: Sat, 8 Jul 2023 19:10:26 +0900 Subject: [PATCH 3/3] Add CircleCI test --- .circleci/config.yml | 138 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..4082e87 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,138 @@ +version: 2.1 +orbs: + ruby: circleci/ruby@2.0.0 + node: circleci/node@5.1.0 + browser-tools: circleci/browser-tools@1.4.1 + jq: circleci/jq@2.2.0 +aliases: + - &restore_bundler_cache + name: Restore Bundler cache + keys: + - gem-cache-v1-{{ .Branch }}-{{ checksum "Gemfile.lock" }} + - gem-cache-v1-{{ .Branch }}- + - gem-cache-v1- + - &restore_yarn_cache + name: Restore Yarn cache + keys: + - yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} + - yarn-packages-v1-{{ .Branch }}- + - yarn-packages- + - &save_bundle_cache + name: Save Bundle cache + key: gem-cache-v1-{{ .Branch }}-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + - &save_yarn_cache + name: Save Yarn cache + key: yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} + paths: + - node_modules + - &restore_tmp_bundler_cache + name: Restore Bundler cache + keys: + - tmp-starter-gem-cache-v1-{{ .Branch }}-{{ checksum "Gemfile.lock" }} + - tmp-starter-gem-cache-v1-{{ .Branch }}- + - tmp-starter-gem-cache-v1- + - &restore_tmp_yarn_cache + name: Restore Yarn cache + keys: + - tmp-starter-yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} + - tmp-starter-yarn-packages-v1-{{ .Branch }}- + - tmp-starter-yarn-packages- + - &save_tmp_bundle_cache + name: Save Bundle cache + key: tmp-starter-gem-cache-v1-{{ .Branch }}-{{ checksum "Gemfile.lock" }} + paths: + - tmp/starter/vendor/bundle + - &save_tmp_yarn_cache + name: Save Yarn cache + key: tmp-starter-yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} + paths: + - tmp/starter/node_modules + - &ruby_node_browsers_docker_image + - image: cimg/ruby:3.2.2-browsers + environment: + PGHOST: localhost + PGUSER: untitled_application + RAILS_ENV: test + - &postgres_docker_image + - imuge: circleci/postgres + environment: + POSTGRES_HOST_AUTH_METHOD: trust + POSTGRES_DB: untitled_application_test + POSTGRES_USER: untitled_application + - &wait_for_docker + # We run this because the DB might not be available for a while due to a race condition. + run: dockerize -wait tcp://localhost:5432 -timeout 1m +jobs: + 'Local Minitest': + docker: + # We currently don't have any system tests, so we don't need the browser image. + # - <<: *ruby_node_browsers_docker_image + - <<: *postgres_docker_image + executor: ruby/default + steps: + - checkout + + # Install dependencies + - run: "bundle install" + - run: "bundle clean --force" + - *wait_for_docker + - run: + name: Run unit tests + command: bundle exec rails test + + 'Local Standard Ruby': + # docker: + # - <<: *ruby_node_browsers_docker_image + steps: + - checkout + - ruby/install-deps: + clean-bundle: true + - run: + name: Check Standard Ruby + command: bundle exec standardrb + + 'Starter Repo Minitest': + docker: + - <<: *ruby_node_browsers_docker_image + - <<: *postgres_docker_image + - image: circleci/redis + executor: ruby/default + working_directory: tmp/starter + parallelism: 16 + steps: + - checkout: + path: ~/project + - browser-tools/install-browser-tools: + firefox-version: 108.0.1 + + # TODO: This is a workaround to get git clone working, but it shouldn't be here. + # https://github.com/CircleCI-Public/browser-tools-orb/issues/63 + - run: + command: rm LICENSE.chromedriver + + - run: ./bin/checkout-and-link-starter-repo + + - ruby/install-deps: + clean-bundle: true + - node/install-packages: + pkg-manager: yarn + - run: yarn build:css + + - *wait_for_docker + + - run: + name: Run tests with Knapsack Pro + command: bundle exec rails "knapsack_pro:queue:minitest[--verbose]" + environment: + RAILS_ENV: test + KNAPSACK_PRO_CI_NODE_TOTAL: 16 + +workflows: + version: 2 + build: + jobs: + - 'Local Minitest' + - 'Local Standard Ruby' + - 'Starter Repo Minitest' \ No newline at end of file