github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/.circleci/config.yml (about)

     1  version: 2.1
     2  
     3  jobs:
     4    build:
     5      description: "Run Go unit and integration tests using make targets"
     6      parameters:
     7        image:
     8          description: "Image to use (1.x)"
     9          type: string
    10        go111module:
    11          description: "GO111MODULE= env var value"
    12          default: "auto"
    13          type: enum
    14          enum: ["on", "off", "auto"]
    15        vendor_deps:
    16          description: "Whether to vendor dependencies before running tests"
    17          default: "no"
    18          type: enum
    19          enum: ["yes", "no"]
    20        exclude_dirs:
    21          description: "A space-separated list of directories to ignore"
    22          default: ""
    23          type: string
    24      docker:
    25        - image: << parameters.image >>
    26          user: root
    27        - image: postgres:14
    28          environment:
    29            POSTGRES_USER: postgres
    30            POSTGRES_DB: postgres
    31            POSTGRES_PASSWORD: mysecretpassword
    32        - image: couchbase/server-sandbox:7.1.1
    33      working_directory: /go/src/github.com/instana/go-sensor
    34      steps:
    35        - checkout
    36        - run:
    37            name: Waiting for Postgres to be ready
    38            command: |
    39              for i in `seq 1 10`;
    40              do
    41                nc -z localhost 5432 && echo Success && exit 0
    42                echo -n .
    43                sleep 1
    44              done
    45              echo Failed waiting for Postgress && exit 1
    46  
    47        - run:
    48            name: Waiting for Couchbase to be ready
    49            command: |
    50              for i in `seq 1 15`;
    51              do
    52                nc -z localhost 8091 && echo Success && exit 0
    53                echo -n .
    54                sleep 1
    55              done
    56              echo Failed waiting for Couchbase && exit 1
    57  
    58  
    59        - restore_cache:
    60            keys:
    61              - go-mod-v4-{{ checksum "go.sum" }}
    62        - run:
    63            command: apt-get --allow-releaseinfo-change-suite update -y && apt-get install ca-certificates libgnutls30 -y || true
    64        - run:
    65            command: go install golang.org/x/tools/cmd/goimports@latest || true
    66        - run:
    67            name: Check fmt
    68            command: make fmtcheck
    69        - run:
    70            name: Check imports
    71            command: make importcheck
    72        - run:
    73            name: Run unit tests
    74            environment:
    75              RUN_LINTER: yes
    76              GO111MODULE: << parameters.go111module >>
    77              VENDOR_DEPS: << parameters.vendor_deps >>
    78              EXCLUDE_DIRS: << parameters.exclude_dirs >>
    79            command: make test
    80        - run:
    81            name: Run integration tests
    82            command: make integration
    83            environment:
    84              GO111MODULE: << parameters.go111module >>
    85              VENDOR_DEPS: << parameters.vendor_deps >>
    86              EXCLUDE_DIRS: << parameters.exclude_dirs >>
    87        - save_cache:
    88            key: go-mod-v4-{{ checksum "go.sum" }}
    89            paths:
    90              - "/go/pkg/mod"
    91  
    92  workflows:
    93    version: 2
    94    build:
    95      jobs:
    96        - build:
    97            name: "go1.21"
    98            image: "cimg/go:1.21"
    99        - build:
   100            name: "go1.22"
   101            image: "cimg/go:1.22"