summaryrefslogtreecommitdiff
path: root/.github/workflows/ci-tests.yaml
blob: 831f2f481972ba873d523f65e1b9728f6072e0b0 (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
name: Integration tests
on:
  push:
    branches:
    - 'master'
    - 'release-*'
  pull_request:
    branches:
    - 'master'

jobs:
  check-go:
    name: Ensure Go modules synchronicity
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Setup Golang
        uses: actions/setup-go@v3
        with:
          go-version: '1.20'
      - name: Download all Go modules
        run: |
          go mod download
      - name: Check for tidyness of go.mod and go.sum
        run: |
          go mod tidy
          git diff --exit-code -- .
  codegen:
    name: Run codegen
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Install Kustomize v2
        run: |
          set -xo pipefail
          URL="https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.1.0/kustomize_v5.1.0_linux_amd64.tar.gz"
          BINNAME=kustomize
          curl -sLf --retry 3 -o /tmp/kustomize.tar.gz "$URL"
          chksum=$(sha256sum /tmp/kustomize.tar.gz | awk '{ print $1; }')
          if test "${chksum}" != "52f4cf1ba34d38fd55a9bef819e329c9a4561f5f57f8f539346038ab5026dda8"; then
            echo "Checksum mismatch" >&2
            exit 1
          fi
          tar -C /tmp -xvzf /tmp/kustomize.tar.gz
          sudo mv /tmp/kustomize /usr/local/bin/kustomize
          chmod +x /usr/local/bin/kustomize
      - name: Run make manifests
        run: |
          make manifests
      - name: Check nothing has changed
        run: |
          set -xo pipefail
          git diff --exit-code -- . ':!go.sum' ':!go.mod' ':!assets/swagger.json' | tee codegen.patch
  lint:
    name: Ensure code is correctly linted
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Run golangci-lint
        uses: golangci/golangci-lint-action@v3
        with:
          version: v1.52.2
          args: --timeout 5m
  test:
    name: Ensure unit tests are passing
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Setup Golang
        uses: actions/setup-go@v3
        with:
          go-version: '1.20'
      - name: Run tests
        env:
          GNUPG_DISABLED: true
        run: |
          make test
      - name: Upload code coverage information to codecov.io
        uses: codecov/codecov-action@v1
        with:
          file: coverage.out