forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (99 loc) · 4.23 KB
/
lint-build-commits.yaml
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
name: Build Commits
# Any change in triggers needs to be reflected in the concurrency group.
on: [pull_request]
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
build_commits:
name: Check if build works for every commit
runs-on: ubuntu-22.04
timeout-minutes: 90
steps:
- name: Configure git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
# renovate: datasource=golang-version depName=go
go-version: 1.22.1
- name: Set clang directory
id: set_clang_dir
run: echo "clang_dir=$HOME/.clang" >> $GITHUB_OUTPUT
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ steps.set_clang_dir.outputs.clang_dir }}
key: llvm-10.0
- name: Install LLVM and Clang prerequisites
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libtinfo5
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@be40c5af3a4adc3e4a03199995ab73aa37536712 # v1.9.0
with:
version: "10.0"
directory: ${{ steps.set_clang_dir.outputs.clang_dir }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Install ginkgo
run: |
go install github.com/onsi/ginkgo/ginkgo@cc0216944b25a88d3259699a029d4e601fb8a222 # v1.12.1
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Check if build works for every commit
run: |
PR_COMMITS_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.pull_request.commits_url }})
PR_FIRST_SHA=$(echo "$PR_COMMITS_API_JSON" | jq -r ".[0].sha")
PR_PARENT_SHA=$(git rev-parse "${PR_FIRST_SHA}^")
git rebase --exec "make build -j $(nproc)" $PR_PARENT_SHA
- name: Check bpf code changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: bpf-tree
with:
filters: |
src:
- 'bpf/**'
# Runs only if code under bpf/ is changed.
- name: Check if datapath build works for every commit
if: steps.bpf-tree.outputs.src == 'true'
run: |
PR_COMMITS_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.pull_request.commits_url }})
PR_FIRST_SHA=$(echo "$PR_COMMITS_API_JSON" | jq -r ".[0].sha")
PR_PARENT_SHA=$(git rev-parse "${PR_FIRST_SHA}^")
git rebase --exec "make -C bpf build_all -j $(nproc)" $PR_PARENT_SHA
- name: Check test code changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: test-tree
with:
filters: |
src:
- 'pkg/**'
- 'test/**'
# Runs only if code under test/ is changed.
- name: Check if ginkgo test suite build works for every commit
if: steps.test-tree.outputs.src == 'true'
run: |
PR_COMMITS_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.pull_request.commits_url }})
PR_FIRST_SHA=$(echo "$PR_COMMITS_API_JSON" | jq -r ".[0].sha")
PR_PARENT_SHA=$(git rev-parse "${PR_FIRST_SHA}^")
git rebase --exec "make -C test build -j $(nproc) && make -C test build-darwin" $PR_PARENT_SHA
- name: Failed commit during the build
if: ${{ failure() }}
run: git --no-pager log --format=%B -n 1