<commit_before>version: 2.1

orbs:
  win: circleci/windows@2.2.0
  slack: circleci/slack@4.2.0

commands:
  win_install_go:
    steps:
      - run:
          command: go version
  macos_install_go:
    steps:
      - run:
          # Ensure we have the latest Homebrew revision
          # which downloads from GitHub, not Bintray
          command: brew update
      - run:
          command: brew install golang
      - run:
          command: go version

  go_build:
    steps:
      - run: go build ./...
  go_unit_test:
    steps:
      - run:
          command: go test $(go list ./... | grep -v /tfexec/internal/e2etest)
  go_e2e_test:
    steps:
      - run:
          no_output_timeout: 20m
          command: go test -timeout=20m -v ./tfexec/internal/e2etest

jobs:
  # combined due to slowness of Go install
  macosbuildtest:
    macos:
      xcode: "12.0.0"
    steps:
      - macos_install_go
      - checkout
      - go_build
      - go_unit_test
      - go_e2e_test
    
  # combined due to slowness of Go install
  winbuildtest:
    executor:
      name: win/default
    steps:
      - win_install_go
      - checkout
      - go_build
      - go_unit_test
      - go_e2e_test

  # previous stable Go version
  go116_build:
    docker:
      - image: circleci/golang:1.16
    steps:
      - checkout
      - go_build
  go116_test:
    docker:
      - image: circleci/golang:1.16
    parameters:
      test_results:
        type: string
        default: /tmp/test-results
    steps:
      - checkout
      - go_unit_test

  # latest stable Go version
  go117_build:
    docker:
      - image: circleci/golang:1.17
    steps:
      - checkout
      - go_build
  go117_test:
    docker:
      - image: circleci/golang:1.17
    parameters:
      test_results:
        type: string
        default: /tmp/test-results
    steps:
      - checkout
      - go_unit_test
  go117_test_main:
    environment:
      TFEXEC_E2ETEST_VERSIONS: refs/heads/main
    docker:
      - image: circleci/golang:1.17
    parameters:
      test_results:
        type: string
        default: /tmp/test-results
    steps:
      - checkout
      - go_unit_test
      - go_e2e_test
  go117_vet:
    docker:
      - image: circleci/golang:1.17
    steps:
      - checkout
      - run: go vet ./...
  go117_fmt:
    docker:
      - image: circleci/golang:1.17
    steps:
      - checkout
      - run: gofmt -s -l .
  go117_release:
    docker:
      - image: circleci/golang:1.17
    steps:
      - add_ssh_keys:
          fingerprints:
            - fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b:96:e1:54:e4:bc:27:2b:d0
      - checkout
      - run: ./scripts/release/release.sh

workflows:
  version: 2
  pr:
    jobs:
      - winbuildtest
      - macosbuildtest

      - go116_build
      - go116_test:
          requires:
            - go116_build
      - go117_build
      - go117_test:
          requires:
            - go117_build
      - go117_test_main:
          requires:
            - go117_build
      - go117_vet:
          requires:
            - go117_build
      - go117_fmt:
          requires:
            - go117_build
  release:
    jobs:
      - winbuildtest:
          filters:
            branches:
              only:
                - main
      - macosbuildtest:
          filters:
            branches:
              only:
                - main
      - go116_build:
          filters:
            branches:
              only:
                - main
      - go116_test:
          requires:
            - go116_build
          filters:
            branches:
              only:
                - main

      - go117_build:
          filters:
            branches:
              only:
                - main
      - go117_test:
          requires:
            - go117_build
          filters:
            branches:
              only:
                - main

      - go117_test_main:
          requires:
            - go117_build
          filters:
            branches:
              only:
                - main
      - go117_vet:
          requires:
            - go117_build
          filters:
            branches:
              only:
                - main
      - go117_fmt:
          requires:
            - go117_build
          filters:
            branches:
              only:
                - main

      - trigger-release:
          filters:
            branches:
              only:
                - main
          type: approval

      - go117_release:
          filters:
            branches:
              only:
                - main
          requires:
            - trigger-release
            - go117_test_main
            - go117_vet
            - go117_fmt
            - winbuildtest
            - macosbuildtest
  nightly:
    triggers:
      - schedule:
          cron: "0 0 * * *"
          filters:
            branches:
              only:
                - main
    jobs:
      - winbuildtest
      - macosbuildtest:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
      - go116_build:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
      - go116_test:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
          requires:
            - go116_build
      - go117_build:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
      - go117_test:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
          requires:
            - go117_build
      - go117_test_main:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
            - slack/notify:
                event: pass
                custom: |
                  {
                    "blocks": [
                      {
                        "type": "section",
                        "fields": [
                          {
                            "type": "plain_text",
                            "text": ":terraform-da: The nightly test run passed. :terraformda:",
                            "emoji": true
                          }
                        ]
                      }
                    ]
                  }
          requires:
            - go116_build
            - go116_test
            - go117_build
            - winbuildtest
            - macosbuildtest
<commit_msg>ci: Test with -race flag (#307)<commit_after>version: 2.1

orbs:
  win: circleci/windows@2.2.0
  slack: circleci/slack@4.2.0

commands:
  win_install_go:
    steps:
      - run:
          command: go version
  macos_install_go:
    steps:
      - run:
          # Ensure we have the latest Homebrew revision
          # which downloads from GitHub, not Bintray
          command: brew update
      - run:
          command: brew install golang
      - run:
          command: go version

  go_build:
    steps:
      - run: go build ./...
  go_unit_test:
    steps:
      - run:
          command: go test -race $(go list ./... | grep -v /tfexec/internal/e2etest)
  go_e2e_test:
    steps:
      - run:
          no_output_timeout: 30m
          command: go test -race -timeout=30m -v ./tfexec/internal/e2etest

jobs:
  # combined due to slowness of Go install
  macosbuildtest:
    macos:
      xcode: "12.0.0"
    steps:
      - macos_install_go
      - checkout
      - go_build
      - go_unit_test
      - go_e2e_test
    
  # combined due to slowness of Go install
  winbuildtest:
    executor:
      name: win/default
    steps:
      - win_install_go
      - checkout
      - go_build
      - go_unit_test
      - go_e2e_test

  # previous stable Go version
  go116_build:
    docker:
      - image: circleci/golang:1.16
    steps:
      - checkout
      - go_build
  go116_test:
    docker:
      - image: circleci/golang:1.16
    parameters:
      test_results:
        type: string
        default: /tmp/test-results
    steps:
      - checkout
      - go_unit_test

  # latest stable Go version
  go117_build:
    docker:
      - image: circleci/golang:1.17
    steps:
      - checkout
      - go_build
  go117_test:
    docker:
      - image: circleci/golang:1.17
    parameters:
      test_results:
        type: string
        default: /tmp/test-results
    steps:
      - checkout
      - go_unit_test
  go117_test_main:
    environment:
      TFEXEC_E2ETEST_VERSIONS: refs/heads/main
    docker:
      - image: circleci/golang:1.17
    parameters:
      test_results:
        type: string
        default: /tmp/test-results
    steps:
      - checkout
      - go_unit_test
      - go_e2e_test
  go117_vet:
    docker:
      - image: circleci/golang:1.17
    steps:
      - checkout
      - run: go vet ./...
  go117_fmt:
    docker:
      - image: circleci/golang:1.17
    steps:
      - checkout
      - run: gofmt -s -l .
  go117_release:
    docker:
      - image: circleci/golang:1.17
    steps:
      - add_ssh_keys:
          fingerprints:
            - db:cf:97:b8:d6:ac:86:74:96:e1:54:e4:bc:27:2b:d0
      - checkout
      - run: ./scripts/release/release.sh

workflows:
  version: 2
  pr:
    jobs:
      - winbuildtest
      - macosbuildtest

      - go116_build
      - go116_test:
          requires:
            - go116_build
      - go117_build
      - go117_test:
          requires:
            - go117_build
      - go117_test_main:
          requires:
            - go117_build
      - go117_vet:
          requires:
            - go117_build
      - go117_fmt:
          requires:
            - go117_build
  release:
    jobs:
      - winbuildtest:
          filters:
            branches:
              only:
                - main
      - macosbuildtest:
          filters:
            branches:
              only:
                - main
      - go116_build:
          filters:
            branches:
              only:
                - main
      - go116_test:
          requires:
            - go116_build
          filters:
            branches:
              only:
                - main

      - go117_build:
          filters:
            branches:
              only:
                - main
      - go117_test:
          requires:
            - go117_build
          filters:
            branches:
              only:
                - main

      - go117_test_main:
          requires:
            - go117_build
          filters:
            branches:
              only:
                - main
      - go117_vet:
          requires:
            - go117_build
          filters:
            branches:
              only:
                - main
      - go117_fmt:
          requires:
            - go117_build
          filters:
            branches:
              only:
                - main

      - trigger-release:
          filters:
            branches:
              only:
                - main
          type: approval

      - go117_release:
          filters:
            branches:
              only:
                - main
          requires:
            - trigger-release
            - go117_test_main
            - go117_vet
            - go117_fmt
            - winbuildtest
            - macosbuildtest
  nightly:
    triggers:
      - schedule:
          cron: "0 0 * * *"
          filters:
            branches:
              only:
                - main
    jobs:
      - winbuildtest
      - macosbuildtest:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
      - go116_build:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
      - go116_test:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
          requires:
            - go116_build
      - go117_build:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
      - go117_test:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
          requires:
            - go117_build
      - go117_test_main:
          post-steps:
            - slack/notify:
                event: fail
                template: basic_fail_1
            - slack/notify:
                event: pass
                custom: |
                  {
                    "blocks": [
                      {
                        "type": "section",
                        "fields": [
                          {
                            "type": "plain_text",
                            "text": ":terraform-da: The nightly test run passed. :terraformda:",
                            "emoji": true
                          }
                        ]
                      }
                    ]
                  }
          requires:
            - go116_build
            - go116_test
            - go117_build
            - winbuildtest
            - macosbuildtest

{'fraction_non_alphanumeric': 0.07476139978791092, 'fraction_numerical': 0.03317679139524315, 'mean_word_length': 0.9971260021176827, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1160711', 'n_tokens_mistral': 4179, 'n_tokens_neox': 3801, 'n_words': 773}