LoginSignup
2

More than 5 years have passed since last update.

CircleCIでLintとTestをParallel実行

Last updated at Posted at 2017-01-30

CircleCIのビルド時間を5分短くした話と、スクリプト書いている際に詰まったところを紹介します。

そもそもビルドの長い原因は、LintとTestを1つのコンテナで実行していたため、各6分ずつ時間を要していることでした。
そのため、複数コンテナで実行してみた、というのが今回のQiitaです。

LintとTestの複数コンテナで実行

circle.yml
  override:
    - ./scripts/run_test.sh:
        parallel: true
run_test.sh
#!/bin/bash
case $CIRCLE_NODE_INDEX in
  0) ./gradlew -b lint; cp -r ./app/build/outputs $CIRCLE_ARTIFACTS;;
  1) ./gradlew -b testUnitTest -PdisablePreDex;;
esac

こんな感じで5分短縮できたので非常に幸せです。

parallelでの実行周りで悩んだこと

must be a mapで失敗する

  override:
    - ./scripts/run_test.sh:
      parallel: true

  override:
    - ./scripts/run_test.sh:
        parallel: true

parallelの前にインデントを1つ増やしましょう。

Action failed: Configure the build

  override:
    - ./scripts/run_test.sh
      parallel: true

  override:
    - ./scripts/run_test.sh:
        parallel: true

実行したいコマンドの末尾にコロン(:)を1つ増やしましょう。

deploymentでのparallelの実行

Please note that since we do not support parallel deployment, specifying ‘parallel:true’ in the deployment phase will cause an error

無理なので諦めましょう。

https://circleci.com/docs/parameterized-builds/
deploymentで並列化させたい処理は別Jobとして実行すると準並列化のように出来るのでおすすめです。

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
2