summaryrefslogtreecommitdiff
path: root/.github/workflows/ci-tests.yaml
blob: 5f3ae51fd178259f0d82a319d201f098de55a908 (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
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@v4
      - name: Setup Golang
        uses: actions/setup-go@v5
        with:
          go-version: '1.22'
      - 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@v4
      - 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@v4
      - name: Setup Golang
        uses: actions/setup-go@v5
        with:
          go-version: '1.22'
          cache: false
        env:
          GO111MODULE: off
      - name: Run golangci-lint
        uses: golangci/golangci-lint-action@v6
        with:
          version: v1.61.0
          args: --timeout 5m
  test:
    name: Ensure unit tests are passing
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Setup Golang
        uses: actions/setup-go@v5
        with:
          go-version: '1.22'
      - name: Run tests
        env:
          GNUPG_DISABLED: true
        run: |
          make test
      - name: Upload code coverage information to codecov.io
        uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          file: coverage.out

  test-manifests:
    name: Ensure kubernetes manifests conform to their schema
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Install Kubeconform
        run: |
          set -xo pipefail

          curl -sLf --retry 3 \
            -o /tmp/kubeconform.tar.gz \
            "https://github.com/yannh/kubeconform/releases/download/v0.6.6/kubeconform-linux-amd64.tar.gz" 
          chksum=$(sha256sum /tmp/kubeconform.tar.gz | awk '{ print $1; }')
          if test "${chksum}" != "2ff56999a6ed9e96fe5ab9ee52271f2db5335baf7f17789035b9561970cdd3eb"; then
            echo "Checksum mismatch" >&2
            exit 1
          fi

          tar -C /tmp -xvzf /tmp/kubeconform.tar.gz
          sudo mv /tmp/kubeconform /usr/local/bin/kubeconform
          chmod +x /usr/local/bin/kubeconform
      - name: Run manifest tests
        run: |
          make test-manifests

  registry-scanner:
    name: Ensure registry-scanner Go modules synchronicity and run tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Setup Golang
        uses: actions/setup-go@v5
        with:
          go-version: '1.22'
      - name: Download all Go modules
        run: |
          cd registry-scanner
          go mod download
      - name: Check for tidyness of go.mod and go.sum
        run: |
          go mod tidy
          git diff --exit-code -- .
      - name: Run tests
        env:
          GNUPG_DISABLED: true
        run: |
          make test