aboutsummaryrefslogtreecommitdiff
path: root/.circleci/config.yml
blob: 047748bd0d909193c72c56065aab115688134879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
version: 2.1

orbs:
  prometheus: prometheus/prometheus@0.4.0

executors:
  # Whenever the Go version is updated here, .promu.yml and .promu-cgo.yml
  # should also be updated.
  golang:
    docker:
    - image: circleci/golang:1.14

jobs:
  test:
    executor: golang

    steps:
    - prometheus/setup_environment
    - run: go mod download
    - run: make
    - prometheus/store_artifact:
        file: node_exporter

  codespell:
    docker:
    - image: circleci/python

    steps:
    - checkout
    - run: sudo pip install codespell
    - run: codespell --skip=".git,./vendor,ttar,go.mod,go.sum,*pem,./collector/fixtures" -L uint,packages\',uptodate

  build:
    machine:
      image: ubuntu-1604:201903-01

    environment:
      DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.14-base
      REPO_PATH: github.com/prometheus/node_exporter

    steps:
    - checkout
    - run: docker run --privileged linuxkit/binfmt:v0.7
    - run: make promu
    - run: promu crossbuild
    - run: promu --config .promu-cgo.yml crossbuild
    - persist_to_workspace:
        root: .
        paths:
        - .build
    - store_artifacts:
        path: .build
        destination: /build
    - run:
        command: |
          if [ -n "$CIRCLE_TAG" ]; then
            make docker DOCKER_IMAGE_TAG=$CIRCLE_TAG
          else
            make docker
          fi
    - run: docker images
    - run: docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T
    - run:
        command: |
          if [ -n "$CIRCLE_TAG" ]; then
            make test-docker DOCKER_IMAGE_TAG=$CIRCLE_TAG
          else
            make test-docker
          fi

workflows:
  version: 2
  node_exporter:
    jobs:
    - test:
        filters:
          tags:
            only: /.*/
    - build:
        filters:
          tags:
            only: /.*/
    - codespell:
        filters:
          tags:
            only: /.*/
    - prometheus/publish_master:
        context: org-context
        requires:
        - test
        - build
        filters:
          branches:
            only: master
    - prometheus/publish_release:
        context: org-context
        requires:
        - test
        - build
        filters:
          tags:
            only: /^v.*/
          branches:
            ignore: /.*/