circle ci で rspecのjob時に bundle exec rails db:create db:migrateでエラーになります。
下記の記事を参考に
bundlerのバージョンをローカルと合わせたり、
$ bundle lock --add-platform x86_64-linux をしましたがダメでした。
どなたか原因分かる方いらっしゃらないでしょうか?
https://qiita.com/vinaka/items/0301a488c0fc09ca453f
https://qiita.com/kobayashiryou/items/0d50e25cb29c475db229
.circleci/config.yml
version: 2.1 orbs: aws-ecr: circleci/aws-ecr@8.1.2 aws-ecs: circleci/aws-ecs@2.2.1 executors: default_container: docker: - image: cimg/ruby:3.1 environment: RAILS_ENV: test BUNDLE_JOBS: 4 BUNDLE_RETRY: 3 BUNDLE_PATH: vendor/bundle BUNDLER_VERSION: 2.3.7 - image: cimg/mysql:8.0 environment: MYSQL_ROOT_PASSWORD: password working_directory: ~/photudio commands: install_bundler: description: Bundler install steps: - run: gem install bundler -v 2.3.7 jobs: fetch_source_code: executor: name: default_container steps: - checkout - save_cache: key: v2-photudio-{{ .Branch }}-{{ .Revision }} paths: - ~/photudio bundle_dependencies: executor: name: default_container steps: - restore_cache: key: v2-photudio-{{ .Branch }}-{{ .Revision }} - restore_cache: key: v2-dependencies-{{ checksum "api/Gemfile.lock" }} - install_bundler - run: name: Bundle Install Dependencies working_directory: api command: | bundle install - save_cache: key: v2-dependencies-{{ checksum "api/Gemfile.lock" }} paths: - api/vendor/bundle rspec: executor: name: default_container steps: - restore_cache: key: v2-photudio-{{ .Branch }}-{{ .Revision }} - restore_cache: key: v2-dependencies-{{ checksum "api/Gemfile.lock" }} - run: name: Waiting for database startup working_directory: api command: | dockerize -wait \ tcp://127.0.0.1:3306 -timeout 120s - run: mv ./api/config/database.yml.ci ./api/config/database.yml - install_bundler - run: working_directory: api command: | bundle install - run: name: DB create and migrate working_directory: api command: | bundle exec rails db:create db:migrate - run: name: Run rspec command: | mkdir tmp/test-results mkdir -p ~/rspec TEST_FILES="$(circleci tests glob \"spec/**/*_spec.rb\" | circleci tests split --split-by=timings)" bundle exec rspec working_directory: api - store_test_results: path: api/rspec - store_artifacts: path: api/tmp/test-results destination: test-results rubocop: executor: name: default_container steps: - restore_cache: key: v2-photudio-{{ .Branch }}-{{ .Revision }} - restore_cache: key: v2-dependencies-{{ checksum "api/Gemfile.lock" }} - install_bundler - run: command: | bundle install working_directory: api - run: name: Execute rubocop working_directory: api command: | bundle exec rubocop build_and_push_image_api: machine: image: ubuntu-2004:202010-01 steps: - checkout - aws-ecr/build-and-push-image: repo: "my-rails" region: AWS_REGION tag: "${CIRCLE_SHA1}" path: ./api/ build_and_push_image_web: machine: image: ubuntu-2004:202010-01 steps: - checkout - aws-ecr/build-and-push-image: repo: "my-nginx" region: AWS_REGION tag: "${CIRCLE_SHA1}" path: ./nginx/ workflows: build: jobs: - fetch_source_code: filters: branches: only: main - bundle_dependencies: requires: - fetch_source_code filters: branches: only: main - rubocop: requires: - bundle_dependencies filters: branches: only: main - rspec: requires: - bundle_dependencies filters: branches: only: main - build_and_push_image_api: requires: - rubocop - rspec filters: branches: only: main - build_and_push_image_web: requires: - rubocop - rspec filters: branches: only: main - aws-ecs/deploy-service-update: requires: - build_and_push_image_api # ECSのタスク定義名 family: "my-task" # ECSのクラスター名かARNのフルパス cluster-name: "my-cluster" # サービス名 service-name: "my-service" # containerはタスク定義で設定したコンテナ名にする container-image-name-updates: "container=nginx,tag=${CIRCLE_SHA1}" - aws-ecs/deploy-service-update: requires: - build_and_push_image_web # ECSのタスク定義名 family: "my-task" # ECSのクラスター名かARNのフルパス cluster-name: "my-cluster" # サービス名 service-name: "my-service" # containerはタスク定義で設定したコンテナ名にする container-image-name-updates: "container=rails,tag=${CIRCLE_SHA1}"
database.yml.ci
test: adapter: mysql2 encoding: utf8 pool: 5 username: <%= ENV.fetch("MYSQL_USER", "root") %> password: <%= ENV.fetch("MYSQL_USER", "password") %> host: <%= ENV.fetch("MYSQL_HOST", "127.0.0.1") %> port: <%= ENV.fetch("MYSQL_PORT", "3306") %> database: <%= ENV.fetch("MYSQL_DATABASE", "photudio_test") %>
Gemfile.lock
. . . PLATFORMS aarch64-linux x86_64-linux . . . RUBY VERSION ruby 3.1.2p20 BUNDLED WITH 2.3.7
あなたの回答
tips
プレビュー