LoginSignup
0
1

More than 3 years have passed since last update.

様々な CIツールの設定方法を試してみた

Posted at

概要

CI の比較をする機会があり、各種設定ファイルを作って CI を回してみました。

(こんな感じです)
ci.png

対象

環境

  • GitHub の Public Repository
  • Go の build/test

gmidorii/ci-test

設定

CircleCI

ドキュメント

料金

実行コンテナ数ベースの月額料金

https://circleci.com/pricing/

補足: β 版ではあるが従量課金制の導入もあり(https://circleci.com/pricing/usage/)

ビルドファイル

.circleci/config.yml
version: 2
jobs:
  build:
    docker:
      - image: circleci/golang:1.12
    working_directory: /tmp/app

    environment:
      TEST_RESULT: /tmp/test-results

    steps:
      - checkout
      - run: mkdir -p ${TEST_RESULT}
      - run:
          name: Unit Test
          command:
            PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
            gotestsum --junitfile ${TEST_RESULT}/gotessum-report.xml -- ${PACKAGE_NAMES}
      - run: make build
      - save_cache:
          key: go-mod-v4-{{ checksum "go.mod" }}
          paths:
            - "/go/pkg/mod"
      - store_artifacts:
          path: /tmp/test-results
          destination: raw-test-output
      - store_test_results:
          path: /tmp/test-results
workflows:
  version: 2
  build-workflow:
    jobs:
      - build

メリット

  • サンプルの丁寧なビルドファイルが用意されている
  • Docker ベースで実行されている
  • GitHub との連携がスムーズ
    • GitHub or Bitbucket アカウントで登録する
  • OSS の場合は全 4 コンテナを利用可能

デメリット

  • 1.0 -> 2.0 への移行が必要
  • 1.0 系の記事が多く注意が必要

Travis CI

ドキュメント

料金

並行ジョブ数に応じた月額料金
https://travis-ci.com/plans

ビルドファイル

.travis.yml
matrix:
  include:
    - language: go
      go:
        - 1.11.x
        - 1.12.x
      script:
        - make test-cover

メリット

  • OSS の場合は無料
  • 複数のプログラムバージョンに対するテストの実施が簡単(matrix test)
  • GitHub との連携がスムーズ

デメリット

  • 最低価格が若干高め
    • \$129/month

AWS CodeBuild

料金

従量課金制
https://aws.amazon.com/jp/codebuild/pricing/

ビルドファイル

buildspec.yml
version: 0.2

phases:
  install:
    runtime-versions:
      golang: 1.12
    commands:
      - echo 'Entered install ...'
      - apt-get update -y
  build:
    commands:
      - echo 'Entered build ...'
      - make build
      - make test-cover

artifacts:
  files:
    - "./ci-test"
    - "./coverage.html"
  name: ci-test-$(date +%Y-%m-%d)

メリット

  • 利用分の従量課金制
  • Build 数に応じてスケーリングして実行可能
  • GitHub からの WebHook を AWS コンソール上から設定できる

デメリット

  • OSS の場合も同様に料金がかかる

Azure Pipelines

料金

ユーザー数ごとの月額料金制
https://azure.microsoft.com/en-us/pricing/details/devops/azure-devops-services/

ビルドファイル

azure-pipelines.yml
trigger:
  - master

variables:
  GOPATH: "$(system.defaultWorkingDirectory)/gopath"

stages:
  - stage: build
    jobs:
      - job: go
        pool:
          vmImage: "ubuntu-latest"
        steps:
          - script: |
              go build
            displayName: "go build"
          - script: |
              go test -v -cover -coverprofile=c.out
              go tool cover -html=c.out -o coverage.html
            displayName: "go test"

  - stage: deploy
    # exec only master branch
    condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/master'))
    jobs:
      - job: deploy
        pool:
          vmImage: "ubuntu-latest"
        steps:
          - script: |
              echo 'Deploy....'
            displayName: "deploy"

メリット

  • OSS の場合は 10 hosts まで無料
  • 異なるベースイメージで複数のジョブを同時に実行可能

デメリット

用途別の選択

(ここは主観が主です)

OSS

  1. Azure Pipelines
    ベースイメージを分けられるので、複数の環境があるリポジトリの場合に便利のため

  2. TravisCI or Circle CI

有料利用

最終的に AWS 上のリソースを作成する場合
-> AWS CodeBuild
料金も安くアクセスキー等を AWS 外に出さなくても良いため

その他
-> Circle CI

参考

0
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
0
1