4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CircleCI 2.1のローカル実行、、、がうまくいかないログ :-(

Last updated at Posted at 2020-02-06

環境

  • 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を使っていたりする。

使った.circleci/config.yml

参照ドキュメント

CircleCI のローカル CLI の使用

ローカルでのジョブ実行時の制約があるので注意

  • Machine Executor を使用できない。
  • ジョブのみを実行でき、ワークフローは実行できない。
  • キャッシュがサポートされていない。
  • UIで設定した環境変数は参照されない。代わりに、-eフラグを使用して CLI に環境変数を指定できる。

手順

CLI(circleci)のインストール

$ brew install circleci

circleciのセットアップ

$ 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
4
1
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?