forked from p4lang/p4c
-
Notifications
You must be signed in to change notification settings - Fork 0
223 lines (194 loc) · 6.17 KB
/
ci-test.yml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: "test-p4c"
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Cancel any preceding run on the pull request.
concurrency:
group: test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
# Build with gcc and test p4c on Ubuntu 22.04.
test-ubuntu22:
strategy:
fail-fast: false
runs-on: ubuntu-22.04
env:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ runner.os }}-gcc
max-size: 1000M
- name: Build (Ubuntu 22.04, GCC)
run: |
tools/ci-build.sh
- name: Run tests (Ubuntu 22.04)
# Need to use sudo for the eBPF kernel tests.
run: sudo -E ctest --output-on-failure --schedule-random
working-directory: ./build
# Build with gcc and test p4c on Ubuntu 20.04.
test-ubuntu20:
name: test-ubuntu20 (Unity ${{ matrix.unity }})
strategy:
fail-fast: false
matrix:
unity: [ON, OFF]
runs-on: ubuntu-20.04
env:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
CMAKE_UNITY_BUILD: ${{ matrix.unity }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ matrix.unity }}-${{ runner.os }}-gcc
max-size: 1000M
- name: Build (Ubuntu 20.04, GCC)
run: |
tools/ci-build.sh
- name: Run tests (Ubuntu 20.04)
# Need to use sudo for the eBPF kernel tests.
run: sudo -E ctest --output-on-failure --schedule-random
working-directory: ./build
if: matrix.unity == 'ON'
# Build with clang and test p4c on Ubuntu 20.04.
test-ubuntu20-clang-sanitizers:
strategy:
fail-fast: false
runs-on: ubuntu-20.04
env:
CTEST_PARALLEL_LEVEL: 2
IMAGE_TYPE: test
COMPILE_WITH_CLANG: ON
BUILD_AUTO_VAR_INIT_PATTERN: ON
ENABLE_SANITIZERS: ON
UBSAN_OPTIONS: print_stacktrace=1
ASAN_OPTIONS: print_stacktrace=1:detect_leaks=0
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ runner.os }}-clang
max-size: 1000M
- name: Build (Ubuntu 20.04, Clang, Sanitizers)
run: |
tools/ci-build.sh
- name: Run tests (Ubuntu 20.04)
# Need to use sudo for the eBPF kernel tests.
run: sudo -E ctest --output-on-failure --schedule-random
working-directory: ./build
# Build with gcc and test p4c on Ubuntu 18.04.
test-ubuntu18:
strategy:
fail-fast: false
runs-on: ubuntu-latest
env:
CTEST_PARALLEL_LEVEL: 4
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-ubuntu-18.04-gcc
max-size: 1000M
- name: Build (Ubuntu 18.04, GCC)
run: |
docker build -t p4c --build-arg BASE_IMAGE=ubuntu:18.04 --build-arg IMAGE_TYPE=test \
--build-arg ENABLE_TEST_TOOLS=OFF .
./tools/export_ccache.sh
# run with sudo (...) --privileged
# this is needed to create network namespaces for the ebpf tests.
- name: Run tests (Ubuntu 18.04)
run: |
sudo -E docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest --output-on-failure --schedule-random
# Build and test p4c on Fedora.
test-fedora-linux:
strategy:
fail-fast: false
# This job runs in Fedora container that runs in Ubuntu VM.
runs-on: ubuntu-latest
container:
image: registry.fedoraproject.org/fedora:latest
options: --privileged
env:
CTEST_PARALLEL_LEVEL: 4
steps:
# We need to install git here because it is not provided out of the box in Fedora container.
- name: Install git
run: dnf install -y -q git
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies (Fedora Linux)
run: tools/install_fedora_deps.sh
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: fedora-test-${{ runner.os }}
max-size: 1000M
- name: Build p4c (Fedora Linux)
run: |
./bootstrap.sh -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_UNITY_BUILD=ON
make -j2 -C build
- name: Run p4c tests (Fedora Linux)
# Need to use sudo for the eBPF kernel tests.
run: sudo -E ctest --output-on-failure --schedule-random
working-directory: ./build
# Build and test p4c on MacOS 11
test-mac-os:
strategy:
fail-fast: false
runs-on: macos-11
env:
CTEST_PARALLEL_LEVEL: 4
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ runner.os }}
max-size: 1000M
- name: Install dependencies (MacOS)
run: |
tools/install_mac_deps.sh
echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH
- name: Build (MacOS)
# for some reason, brew does not install protobuf in a way cmake would be
# able to find it. Also, the library needs to be specified manually in
# order for the compiler to be correctly linked with protobuf.
# Also, there are no static protobuf libs in homebrew.
# See also https://github.com/Homebrew/homebrew-core/pull/122277
run: |
PROTOBUF=`brew --prefix --installed protobuf@21`
./bootstrap.sh -DENABLE_GC=ON -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_UNITY_BUILD=ON \
-DProtobuf_INCLUDE_DIR=$PROTOBUF/include \
-DProtobuf_LIBRARY=$PROTOBUF/lib/libprotobuf.dylib \
-DENABLE_PROTOBUF_STATIC=OFF
make -Cbuild -j2
- name: Run tests (MacOS)
# TODO: Renable gtest. Unit tests currently fail on MacOS.
run: |
ctest --output-on-failure --schedule-random -LE "bpf|gtest|ubpf"
working-directory: ./build