-
-
Notifications
You must be signed in to change notification settings - Fork 86
117 lines (103 loc) · 4.09 KB
/
ci-check-format.yaml
File metadata and controls
117 lines (103 loc) · 4.09 KB
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
name: CI check format
on:
pull_request: {}
# By specifying the access of one of the scopes, all of those that are not specified are set to 'none'.
permissions:
# To be able to access the repository with actions/checkout
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
jobs:
format:
timeout-minutes: 30
name: Check source format
runs-on: ubuntu-24.04
steps:
- name: Checkout PR Source Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: Prep for build
run: |
echo "${{ github.event.pull_request.head.sha }}" >SOURCE_VERSION
echo "BUILDER_DOCKER_HASH=$(git ls-tree --full-tree HEAD -- ./Dockerfile.builder | awk '{ print $3 }')" >> $GITHUB_ENV
- name: Wait for build image
uses: ./.github/workflows/wait-for-image
with:
SHA: ${{ env.BUILDER_DOCKER_HASH }}
repo: cilium
images: cilium-envoy-builder-dev
- name: Check format
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
id: docker_format_ciak
with:
target: format
provenance: false
context: .
file: ./Dockerfile
platforms: linux/amd64
outputs: type=local,dest=check-format-results
build-args: |
BUILDER_BASE=quay.io/${{ github.repository_owner }}/cilium-envoy-builder-dev:${{ env.BUILDER_DOCKER_HASH }}
push: false
- name: Check for failure
run: '! grep "^Format check failed" check-format-results/format-output.txt'
- name: Upload Format results
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: check-format-results
path: check-format-results/format-output.txt
retention-days: 5
tidy:
timeout-minutes: 60
name: Lint source style
runs-on: ubuntu-24.04
steps:
- name: Checkout PR Source Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
fetch-depth: 2
- name: Prep for build
run: |
echo "${{ github.event.pull_request.head.sha }}" >SOURCE_VERSION
echo "BUILDER_DOCKER_HASH=$(git ls-tree --full-tree HEAD -- ./Dockerfile.builder | awk '{ print $3 }')" >> $GITHUB_ENV
# git diff filter has everything else than deleted files (those need not be tidied)
echo "TIDY_SOURCES=$(git diff --name-only --diff-filter=d HEAD^1 HEAD -- '*.h' '*.cc' | tr '\n' ' ')" >> $GITHUB_ENV
- name: Wait for build image
uses: ./.github/workflows/wait-for-image
with:
SHA: ${{ env.BUILDER_DOCKER_HASH }}
repo: cilium
images: cilium-envoy-builder-dev
- name: Run clang-tidy
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
# skip if nothing changed
if: ${{ env.TIDY_SOURCES != '' }}
id: docker_clang_tidy
with:
target: clang-tidy
provenance: false
context: .
file: ./Dockerfile
platforms: linux/amd64
outputs: type=local,dest=clang-tidy-results
build-args: |
BUILDER_BASE=quay.io/${{ github.repository_owner }}/cilium-envoy-builder-dev:${{ env.BUILDER_DOCKER_HASH }}
TIDY_SOURCES=${{ env.TIDY_SOURCES }}
push: false
- name: Check for failure
run: |
if grep -q "^clang-tidy fix produced changes, please commit them." clang-tidy-results/clang-tidy-output.txt; then
exit 1
fi
- name: Upload clang-tidy results
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: clang-tidy-results
path: clang-tidy-results/*.txt
retention-days: 5