circle-ci에서version 2.한번 써 보다

6439 단어 CircleCI2.0

tl;dr


version2.1은 편리한 기능이 많이 추가될 수 있으니 사용해 보세요.
  • executors
  • commands
  • workflows (version 2.0)
  • 아무튼 써볼게요.


    .circleci/config.yml
    version: 2.1
    
    executors:
      default:
        working_directory: ~/repo
        docker:
          - image: circleci/php:7
    
    commands:
      composer_install_with_cache:
        steps:
          - restore_cache:
              keys:
                - v1-composer-deps-{{ checksum "composer.json" }}
                - v1-composer-deps-
          - run: composer install -n --prefer-dist
          - save_cache:
              key: v1-composer-deps-{{ checksum "composer.json" }}
              paths:
                - ./vendor
    
    jobs:
      checkout_code:
        executor: default
        steps:
          - checkout
          - composer_install_with_cache
          - save_cache: # ソースコードをキャッシュ
              key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
              paths:
                - ~/repo
    
      test:
        executor: default
        steps:
          - restore_cache: # ソースコードの復元
              key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
    
          - run: phpunit
    
    workflows:
      version: 2
      build:
        jobs:
          - checkout_code
          - test:
              requires: # checkout_codeの後に実行する
                - checkout_code
    

    구성 파일 확인


    기술 오류가 있는지 확인합니다.
    단말기
    $ circleci config validate
    Config file at .circleci/config.yml is valid.
    

    실행 결과


    Workflow를 사용한 후 다음 두 가지 작업을 수행했습니다.

    version2.1이 되면 각 처리를 유창하게 쓰는 게 좋은 느낌이에요.

    로컬 실행 정보


    로컬에서 실행하면 대응하지 않으면 오류가 발생합니다. 유감입니다.
    단말기
    $ circleci local execute
    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)
    
    하지만 다음 명령으로 2.0으로 전환하면 실행할 수 있다.
    단말기
    # 設定ファイルの変換 (2.1 -> 2.0)
    $ circleci config process .circleci/config.yml > process.yml
    
    # チェックアウトのジョブを実行
    $ circleci local execute -c process.yml --job checkout-code
      ・
      ・
      ・
    ====>> echo "compoer install."
      #!/bin/bash -eo pipefail
    compoer install -n --prefer-dist
    ====>> Saving Cache
    Error: 
    Skipping cache - error checking storage: not supported
    
    Step failed
    Success!
    
    # テストのジョブを実行
    $ circleci local execute -c process.yml --job test
    
    현금으로 오류가 발생하고 개별적으로 임무를 수행하는 등 시간이 좀 걸리면 곤란하다.

    참고 자료

  • WEB+DB PRESS vol.17 실천CircleaCI
  • https://www.kaizenprogrammer.com/entry/2018/10/01/035657
  • 좋은 웹페이지 즐겨찾기