commander-cli/commander

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1
orbs:
  win: circleci/windows@2.2.0

runOnAllBranches: &runOnAllBranches
  filters:
    branches:
      only: /.*/

runOnDefaultBranch: &runOnDefaultBranch
  filters:
    branches:
      only: master

jobs:
  style:
    docker:
      - image: cimg/go:1.21.3
    steps:
      - checkout
      - run: go vet ./...
      - run: if [ $(go fmt ./... | wc -l) -eq 0  ]; then exit 0; else echo "please run go fmt ./..."; exit 1; fi

  test:
    docker:
      - image: cimg/go:1.21.3

    steps:
      - checkout
      - setup_remote_docker:
          version: 20.10.7
      - run:
          name: Run tests
          command: |
            make test-coverage-all-dockerized-with-codeclimate

  # higher support plan is necessary
  # test-macos:
  #   macos:
  #     xcode: 11.7.0
  #   steps:
  #   - checkout
  #   - run: go test ./...

  test-windows:
    executor:
      name: win/default
      shell: powershell.exe
    steps:
      - checkout
      - run: choco install -y make
      - run: make test

  integration:
    docker:
      - image: cimg/go:1.21.3
    steps:
      - checkout
      - setup_remote_docker:
          version: 20.10.7
      - run:
          name: Install commander
          command: |
            mkdir -p ~/.local/bin/
            curl -L https://github.com/commander-cli/commander/releases/download/v2.4.0/commander-linux-amd64 -o ~/.local/bin/commander
            chmod +x ~/.local/bin/commander
      - run: make integration-linux-dockerized

  integration-windows:
    executor:
      name: win/default
      shell: powershell.exe
    steps:
      - checkout
      - run: choco install -y make
      - run: choco install -y curl
      - run: Invoke-WebRequest -Uri "https://github.com/commander-cli/commander/releases/download/v2.4.0/commander-darwin-amd64" -OutFile "C:\Windows\system32\commander.exe"
      - run: make integration-windows

  deploy:
    environment:
      GIT_RELEASE_TAG: << pipeline.git.tag >>
    docker:
      - image: cimg/go:1.21.3
    steps:
      - checkout
      - run: go install github.com/tcnksm/ghr@v0.14.0
      - run: make release
      - run:
          name: Publish release
          command: ghr $GIT_RELEASE_TAG release/

workflows:
  version: 2.1
  workflow:
    jobs:
      - style:
          <<: *runOnAllBranches
      - test:
          <<: *runOnAllBranches
      - test-windows:
          <<: *runOnDefaultBranch
      - integration:
          <<: *runOnAllBranches
      - integration-windows:
          <<: *runOnDefaultBranch
      - deploy:
          filters:
            tags:
              only: /.*/
            branches:
              ignore: /.*/