コミット & プッシュせずにCircle CIのビルドをテストする。
Circle CI 2.0で環境を構築中、とある記事に出会った。
前からいちいちプッシュするのめんどくさいなーと思っていたので、手を止めて実際にやってみた。
また、以下のエラーにもあるが、
個人用のリポジトリはパブリックなので、環境変数とか使わないとDBのアカウント系がGitHubのpush履歴に
残ってしまうので、不用意にビルドのテストを行えなかった。
なので、これができればいちいちpushして、webサイト見て〜という行為をしなくてもテストができるので、 やってみる価値はすごく高いと思った。
ちなみに現在はCircle CIで以下のようなビルドのエラーが起きている。
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>nil, "password"=>nil, "socket"=>"/var/lib/mysql/mysql.sock", "database"=>"xxxxxx"} rake aborted!
これと同じエラーがターミナルで出てくればOK。
本来なら成功例を出したいところであるが。。。
記事と同じように自分もDocker for Mac Dockerの使い方はあまりわかっていない。 ない場合はDockerのアカウントを作成して、インストールしておく。
$ docker -v Docker version 18.06.1-ce, build e68fc7a $ curl -o /usr/local/bin/circleci https://circle-downloads.s3.amazonaws.com/releases/build_agent_wrapper/circleci && chmod +x /usr/local/bin/circleci % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 4691 100 4691 0 0 4269 0 0:00:01 0:00:01 --:--:-- 4272 $ circleci -v // こちらはコマンド間違えてるぽいが Receiving latest version of circleci... INFO: We've built a brand new CLI for CircleCI! Please run 'circleci switch' to upgrade. Error: unknown shorthand flag: 'v' in -v $ circleci switch // upgradeする。 Thank you for your interest in trying the new CLI! Be sure to read the docs if you get stuck. [https://github.com/CircleCI-Public/circleci-cli#readme] Are you sure you're ready to upgrade? [y/N]: y Upgrading CircleCI to the newest version. % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1216 100 1216 0 0 3423 0 --:--:-- --:--:-- --:--:-- 3415 Finding latest release. Downloading CircleCI v0.1.3093 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 632 0 632 0 0 764 0 --:--:-- --:--:-- --:--:-- 764 100 3432k 100 3432k 0 0 409k 0 0:00:08 0:00:08 --:--:-- 659k x client/LICENSE x md_docs/LICENSE x circleci Installing to /usr/local/bin/circleci /usr/local/bin/circleci $ which circleci /usr/local/bin/circleci
rails rootまでcd
コマンドで移動。
$ circleci config validate -c .circleci/config.yml Config file at .circleci/config.yml is valid $ circleci build Downloading latest CircleCI build agent... .... Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>nil, "password"=>nil, "socket"=>"/var/lib/mysql/mysql.sock", "database"=>"xxxxxx"} rake aborted!
もともとビルドミスっている状態だったが、同じエラーが出されていた。感動。
$ circleci version 0.1.3093+2558d82 $ circleci --help This project is the seed for CircleCI's new command-line application. Usage: circleci [command] Available Commands: config Operate on build config files diagnostic Check the status of your CircleCI CLI. help Help about any command local Debug jobs on the local machine namespace Operate on namespaces orb Operate on orbs query Query the CircleCI GraphQL API. setup Setup the CLI with your credentials update Update the tool version Display version information Flags: -h, --help help for circleci --host string URL to your CircleCI host (default "https://circleci.com") --token string your token for using CircleCI --verbose Enable verbose logging. Use "circleci [command] --help" for more information about a command.