summaryrefslogtreecommitdiff
path: root/.circleci/config.yml
blob: 5f91633fe86c6368f544d4c60d4894efd36f51ed (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
version: 2.1

orbs:
  codecov: codecov/codecov@3

executors:
  node:
    docker:
      - image: node:18-slim
  golangci-lint:
    docker:
      - image: golangci/golangci-lint:v1.50-alpine
  golang-previous:
    docker:
      - image: golang:1.18
  golang-latest:
    docker:
      - image: golang:1.19

jobs:
  lint-markdown:
    executor: node
    steps:
      - checkout
      - run:
          name: Install markdownlint
          command: npm install -g markdownlint-cli
      - run:
          name: Check for Lint
          command: markdownlint .

  lint-source:
    executor: golangci-lint
    steps:
      - checkout
      - run:
          name: Check for Lint
          command: golangci-lint run

  check-go-mod:
    executor: golang-latest
    steps:
      - checkout
      - run:
          name: Go Mod Tidy
          command: go mod tidy
      - run:
          name: Check Module Tidiness
          command: git diff --exit-code -- go.mod go.sum

  check-test-corpus:
    executor: golang-latest
    steps:
      - checkout
      - run:
          name: Generate Test Corpus
          command: pushd test/ && go run ./gen_sifs.go && popd
      - run:
          name: Check Test Corpus Tidiness
          command: git diff --exit-code --

  check-vulnerabilities:
    executor: golang-latest
    steps:
      - checkout
      - run:
          name: Install govulncheck
          command: go install golang.org/x/vuln/cmd/govulncheck@latest
      - run:
          name: Check for vulnerabilities
          command: govulncheck ./...

  build-source:
    parameters:
      e:
        type: executor
    executor: << parameters.e >>
    steps:
      - checkout
      - run:
          name: Build Source
          command: go build ./...

  unit-test:
    parameters:
      e:
        type: executor
    executor: << parameters.e >>
    steps:
      - checkout
      - run:
          name: Run Unit Tests
          command: go test -coverprofile cover.out -race ./...
      - codecov/upload:
          file: cover.out

  release-test:
    executor: golang-latest
    steps:
      - checkout
      - run:
          name: Install syft
          command: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
      - run:
          name: Test Release
          command: curl -sL https://git.io/goreleaser | bash -s -- --snapshot --skip-publish

  publish-release:
    executor: golang-latest
    steps:
      - checkout
      - run:
          name: Install syft
          command: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
      - run:
          name: Publish Release
          command: curl -sL https://git.io/goreleaser | bash

workflows:
  version: 2

  build-and-test:
    jobs:
      - lint-markdown
      - lint-source
      - check-go-mod
      - check-test-corpus
      - check-vulnerabilities
      - build-source:
          matrix:
            parameters:
              e: ["golang-previous", "golang-latest"]
      - unit-test:
          matrix:
            parameters:
              e: ["golang-previous", "golang-latest"]
      - release-test

  tagged-release:
    jobs:
      - publish-release:
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /v[0-9]+(\.[0-9]+)*(-.*)*/
          context: github-release