cilium

Форк
0
/
lint-workflows.yaml 
227 строк · 8.1 Кб
1
name: GitHub Workflow Related Checks
2

3
# Any change in triggers needs to be reflected in the concurrency group.
4
on:
5
  pull_request: {}
6
  push:
7
    branches:
8
      - main
9
      - ft/main/**
10

11
permissions: read-all
12

13
concurrency:
14
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
15
  cancel-in-progress: true
16

17
jobs:
18
  ginkgo-workflow-comments:
19
    name: Lint Ginko Workflows Comments
20
    runs-on: ubuntu-latest
21
    steps:
22
      - name: Checkout code
23
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
24
        with:
25
          persist-credentials: false
26
          # hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
27
          path: src/github.com/cilium/cilium
28

29
      # Load Ginkgo build from GitHub
30
      - name: Load ginkgo linter from GH cache
31
        uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
32
        id: cache
33
        with:
34
          path: /tmp/.ginkgo-build/
35
          key: ${{ runner.os }}-ginkgo-linter-${{ hashFiles('src/github.com/cilium/cilium/**/*.go') }}
36

37
      - name: Install Go
38
        if: ${{ steps.cache.outputs.cache-hit != 'true' }}
39
        uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
40
        with:
41
          # renovate: datasource=golang-version depName=go
42
          go-version: 1.22.0
43

44
      - name: Build Ginkgo
45
        if: ${{ steps.cache.outputs.cache-hit != 'true' }}
46
        shell: bash
47
        run: |
48
          cd src/github.com/cilium/cilium
49
          go install github.com/onsi/ginkgo/ginkgo@v1.16.5
50
          mkdir -p /tmp/.ginkgo-build
51

52
      - name: Building Ginkgo Linter Test
53
        if: ${{ steps.cache.outputs.cache-hit != 'true' }}
54
        shell: bash
55
        run: |
56
          cd src/github.com/cilium/cilium
57
          git apply contrib/testing/ginkgo-get-all-test-names.patch
58

59
          cd test
60
          /home/runner/go/bin/ginkgo build
61
          strip test.test
62
          tar -cz test.test -f test.tgz
63

64
      - name: Store Ginkgo Linter Test in GitHub cache path
65
        if: ${{ steps.cache.outputs.cache-hit != 'true' }}
66
        shell: bash
67
        run: |
68
          cd src/github.com/cilium/cilium
69
          mkdir -p /tmp/.ginkgo-build/
70
          if [ -f test/test.tgz ]; then
71
            cp test/test.tgz /tmp/.ginkgo-build/
72
            echo "file copied"
73
          fi
74

75
      - name: Copy Ginkgo binary
76
        if: ${{ steps.cache.outputs.cache-hit == 'true' }}
77
        shell: bash
78
        run: |
79
          cd src/github.com/cilium/cilium/test/
80
          tar -xf /tmp/.ginkgo-build/test.tgz
81

82
      - name: Reading Comments From Workflows
83
        shell: bash
84
        run: |
85
          cd src/github.com/cilium/cilium
86

87
          grep '# K8s' .github/actions/ginkgo/main-focus.yaml | \
88
          sed -e 's/^[[:space:]]\+# //g' | \
89
          sort -u > /tmp/ginkgo-workflow-comments.txt
90

91
          grep '# Runtime' .github/workflows/conformance-runtime.yaml | \
92
          sed -e 's/^[[:space:]]\+# //g' | \
93
          sort -u > /tmp/runtime-workflow-comments.txt
94

95
      - name: Getting test runs output
96
        shell: bash
97
        run: |
98
          cd src/github.com/cilium/cilium/test
99

100
          ./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=K8s | \
101
          grep TestRun | \
102
          grep -v 'TestRun\[Top Level\] Runtime' | \
103
          sed 's/TestRun\[Top Level\]\ //g' | \
104
          sort -u > /tmp/ginkgo-tests.txt
105

106
          ./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=Runtime | \
107
          grep TestRun | \
108
          grep -v 'TestRun\[Top Level\] K8s' | \
109
          sed 's/TestRun\[Top Level\]\ //g' | \
110
          sort -u > /tmp/runtime-tests.txt
111

112
      - name: Checking diff Ginkgo Workflow
113
        shell: bash
114
        run: |
115
          diff /tmp/ginkgo-workflow-comments.txt /tmp/ginkgo-tests.txt --suppress-common-lines
116

117
          if [ $? -ne 0 ]; then
118
            echo ""
119
            echo "Ginkgo tests out of sync with comments from GH workflow:"
120
            echo "$diff"
121
            echo "Please fix the comments from .github/actions/ginkgo/main-focus.yaml accordingly"
122
            echo ""
123
            exit 1
124
          fi
125

126
      - name: Checking diff Runtime Workflow
127
        shell: bash
128
        run: |
129
          diff /tmp/runtime-workflow-comments.txt /tmp/runtime-tests.txt --suppress-common-lines
130

131
          if [ $? -ne 0 ]; then
132
            echo ""
133
            echo "Ginkgo tests out of sync with comments from GH workflow:"
134
            echo "$diff"
135
            echo ""
136
            echo "Please fix the comments from .github/workflows/conformance-runtime.yaml accordingly"
137
            exit 1
138
          fi
139

140
  ginkgo-schema-validation:
141
    name: Validate Ginko Schema
142
    runs-on: ubuntu-latest
143
    steps:
144
      - name: Checkout
145
        uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
146
        with:
147
          python-version: '3.10'
148
      - name: Install yamela
149
        run: pip install yamale
150
      - name: Checkout code
151
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
152
        with:
153
          persist-credentials: false
154
          # hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
155
          path: src/github.com/cilium/cilium
156

157
      - name: Validate schema of ginkgo action files
158
        shell: bash
159
        run: |
160
          cd src/github.com/cilium/cilium/.github/actions/ginkgo/
161
          for type in focus k8s-versions prs scheduled; do
162
            yamale -s ${type}-schema.yaml *-${type}.yaml;
163
          done
164

165
  conformance-schema-validation:
166
    name: Validate k8s Versions Schema
167
    runs-on: ubuntu-latest
168
    steps:
169
      - name: Checkout
170
        uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
171
        with:
172
          python-version: '3.10'
173
      - name: Install yamela
174
        run: pip install yamale
175
      - name: Checkout code
176
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
177
        with:
178
          persist-credentials: false
179
          # hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
180
          path: src/github.com/cilium/cilium
181

182
      - name: Validate schema of aws, azure and gke action files
183
        shell: bash
184
        run: |
185
          for dir in aws azure gke;do
186
            dir_base=".github/actions/${dir}"
187
            file_base="${dir_base}/k8s-versions"
188
            if [ -f ${file_base}.yaml ];then
189
              yamale -s ${file_base}-schema.yaml ${file_base}.yaml;
190
            fi
191
            if [ -f ${dir_base}/test-config-schema.yaml ];then
192
              yamale -s ${dir_base}/test-config-schema.yaml ${dir_base}/test-config-classic.yaml
193
              yamale -s ${dir_base}/test-config-schema.yaml ${dir_base}/test-config-helm.yaml
194
            fi
195
          done
196

197
  name-validation:
198
    name: Validate Workflow Names
199
    runs-on: ubuntu-latest
200
    steps:
201
      - name: Checkout code
202
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
203
        with:
204
          persist-credentials: false
205
          # hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
206
          path: src/github.com/cilium/cilium
207

208
      - name: Validate Job and Step names
209
        shell: bash
210
        run: |
211
          EXIT=0
212
          cd src/github.com/cilium/cilium/.github/workflows
213
          for FILE in *.yaml;do
214
            JOBS=$(yq '.jobs | to_entries | .[] | select(.value.name == null) | "  " + .key' $FILE)
215
            STEPS=$(yq '.jobs | to_entries | .[] as $job | $job.value.steps[] | {"key": $job.key, "name": .name} | select(.name == null) | "  "+.key' $FILE)
216
            if [ "${JOBS}" != "" ];then
217
              echo Jobs are missing name field, in file $FILE
218
              echo "${JOBS}" | awk '{for (i=1; i<=NF; i++) print "  " $i}'
219
              EXIT=1
220
            fi
221
            if [ "${STEPS}" != "" ];then
222
              echo Steps are missing name field, under these Jobs in file $FILE
223
              echo "${STEPS}" | awk '{for (i=1; i<=NF; i++) print "  " $i}'
224
              EXIT=1
225
            fi
226
          done
227
          exit ${EXIT}
228

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.