1
0

More than 3 years have passed since last update.

【circleCI】を使って、githubと連携させ、テストを自動化する

Posted at

初めに

転職に向けてPF作成中。そんな中、circleCI で良い方法を見つけたので共有。

環境

macOS
ruby2.6.6
rails6.1.3
Docker20.10.2

背景

circleCIを自分のPFに導入しようとしてDocker入門を頼りに進めていたところ、
どうしても行き詰まり、何か良い方法はないかと検索していた。
そこで、Docker-composeとcircleCIを連携させている記事に出会い、
無事に導入出来たので紹介したくなりました。

結論

config.yml

version: 2
jobs:
  build:
    #Docker-composeが仮想済のマシーンをpull
    machine:
      image: circleci/classic:edge #最新のDocker環境で使えるようになる
    steps:
      - checkout
      - run:
          name: Dockerコンテナのビルド
          command: docker-compose build
      - run:
          name: Dockerコンテナの起動
          command: docker-compose up -d
      - run:
          name: "10秒待機させる"
          command: sleep 10
      - run:
          name: データベースの作成
          command: docker-compose run web rails db:create RAILS_ENV=test
      - run:
          name: データベースのセットアップ
          command: docker-compose run web rails db:migrate RAILS_ENV=test
      - run:
          name: Rspecテスト実行
          command: docker-compose run web bundle exec bin/rspec
      - run:
          name: rubocop実行
          command: docker-compose run web bundle exec rubocop
      - run:
          name: Dockerコンテナの停止
          command: docker-compose down
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0