環境
- Circle CI 2.1
- Mac(macOS Mojava 10.14.6)
TL;DR
build job(yarn install
)は成功するが、test jobが失敗する。
test jobではbuild jobで作ったキャッシュを使っているので、それが原因か?
その他は、test jobではDBを使っていたりする。
参照ドキュメント
ローカルでのジョブ実行時の制約があるので注意
- Machine Executor を使用できない。
- ジョブのみを実行でき、ワークフローは実行できない。
- キャッシュがサポートされていない。
- UIで設定した環境変数は参照されない。代わりに、
-e
フラグを使用して CLI に環境変数を指定できる。
手順
CLI(circleci
)のインストール
$ brew install circleci
circleci
のセットアップ
- 要APIトークン
- APIトークンがない人は、パーソナル API トークンの作成で取得。
$ circleci setup
// ログ
// CircleCI Host を聞かれるので、↑の参照先に書かれている通り、デフォルトのまま設定。
//
✔ CircleCI API Token: ****************************************
API token has been set.
✔ CircleCI Host: https://circleci.com
CircleCI host has been set.
Setup complete.
Your configuration has been saved to /Users/<your_home_dir>/.circleci/cli.yml.
Trying an introspection query on API to verify your setup... Ok.
Trying to query our API for your profile name... Hello, <Your Name>.
デモ・リポジトリがあるので、実行を試す
※動作確認のため、スキップ可。
$ git clone https://github.com/CircleCI-Public/circleci-demo-go.git
$ cd circleci-demo-go/
$ circleci local execute --job build
// ログ(一部抜粋)
// cacheはサポートされていないので、Errorが出ます。
// いくつかErrorが出ますが、最後にSuccess!となって完了。
//
====>> Restoring Cache
Error:
Skipping cache - error checking storage: not supported
Step failed
:
:
Step canceled
Success!
設定ファイルをvalidationする
$ circleci config validate .circleci/config.yml
// ログ
Config file at .circleci/config.yml is valid.
ジョブの実行 → 2.1 はサポートされていないのでエラーになる
$ circleci local execute --job build
// ログ
Error:
You attempted to run a local build with version '2.1' of configuration.
Local builds do not support that version at this time.
You can use 'circleci config process' to pre-process your config into a version that local builds can run (see 'circleci help config process' for more information)
configをversion 2.0
用に変換する
$ circleci config process .circleci/config.yml > config-for-v2.yml
変換したconfigを使ってbuild jobを実行する → Success
$ circleci local execute -c config-for-v2.yml --job build
// ログ(一部抜粋)
// cacheはサポートされていないので、Errorが出ます。
// いくつかErrorが出ますが、最後にSuccess!となって完了。
====>> Save node dependencies cache
Error:
Skipping cache - error checking storage: not supported
Step failed
Success!
続いてtest jobを実行する → Error: task failed :-(
Checkout code
の直後にコケている(cacheのrestoreに失敗??)。
$ circleci local execute -c config-for-v2.yml --job test
// ログ(一部抜粋)
====>> Checkout code
#!/bin/bash -eo pipefail
mkdir -p /home/circleci/project && cd /tmp/_circleci_local_build_repo && git ls-files | tar -T - -c | tar -x -C /home/circleci/project && cp -a /tmp/_circleci_local_build_repo/.git /home/circleci/project
Error: Received 'interrupt' signal
Step signaled
Error: runner failed (exited with 101)
Task failed
Error: task failed
コマンドのヘルプ
// help
$ circleci help config process
$ circleci help local execute