Skip to content

Commit ac75baf

Browse files
committed
CI installation refactoring.
Signed-off-by: fruffy <[email protected]> asdasd Signed-off-by: fruffy <[email protected]>
1 parent 5dc7f87 commit ac75baf

19 files changed

+344
-54
lines changed

.github/workflows/ci-lint.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ jobs:
3535
tools/ci-build.sh
3636
3737
- name: Run cpplint on C/C++ files.
38-
run: cmake --build build --target cpplint
38+
run: poetry run cmake --build build --target cpplint
3939

4040
- name: Run clang-format on C/C++ files.
41-
run: cmake --build build --target clang-format
41+
run: |
42+
poetry run clang-format --version
43+
poetry run cmake --build build --target clang-format
4244
4345
- name: Run black and isort on Python files.
4446
run: |
45-
cmake --build build --target black
46-
cmake --build build --target isort
47+
poetry run black --version
48+
poetry run cmake --build build --target black
49+
poetry run isort --version
50+
poetry run cmake --build build --target isort

.github/workflows/ci-p4tools.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ jobs:
4040
4141
- name: Run tests (Ubuntu 22.04)
4242
# Need to use sudo for the eBPF kernel tests.
43-
run: sudo -E ctest -R "testgen|smith" --output-on-failure --schedule-random
43+
run: sudo -E env PATH="$PATH" poetry run ctest -R "testgen|smith" --output-on-failure --schedule-random
4444
working-directory: ./build

.github/workflows/ci-ptf-kernels-weekly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ jobs:
119119

120120
- name: Install VM and run PTF tests for eBPF backend
121121
run: |
122-
sudo -E ./tools/ci-ptf/run_test.sh sudo docker run --privileged -v /sys/fs/bpf:/sys/fs/bpf -w /p4c/backends/ebpf/tests p4c ./test.sh
122+
sudo -E ./tools/ci-ptf/run_test.sh sudo docker run --privileged -v /sys/fs/bpf:/sys/fs/bpf -w /p4c/backends/ebpf/tests p4c poetry run ./test.sh

.github/workflows/ci-ptf.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ jobs:
5353
tools/ci-build.sh
5454
5555
- name: Run PTF tests for eBPF backend (Ubuntu 20.04)
56-
run: sudo -E ./test.sh
56+
run: sudo -E env PATH="$PATH" poetry run ./test.sh
5757
working-directory: ./backends/ebpf/tests

.github/workflows/ci-static-build-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ jobs:
4848
- shell: bash
4949
name: Build (Ubuntu 20.04)
5050
run: |
51-
sudo -E tools/ci-build.sh
51+
tools/ci-build.sh
5252
./tools/ci-check-static.sh ./build/p4c-bm2-ss ./build/p4c-dpdk ./build/p4c-ebpf \
5353
./build/p4c-pna-p4tc ./build/p4c-ubpf ./build/p4test ./build/p4testgen

.github/workflows/ci-test-debian.yml

+34-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,36 @@ concurrency:
1414
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1515

1616
jobs:
17+
18+
# Build with GCC and test P4C on Ubuntu 24.04.
19+
test-ubuntu24:
20+
runs-on: ubuntu-24.04
21+
env:
22+
CTEST_PARALLEL_LEVEL: 4
23+
IMAGE_TYPE: test
24+
BUILD_GENERATOR: Ninja
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
fetch-depth: 0
30+
31+
- name: ccache
32+
uses: hendrikmuhs/ccache-action@v1
33+
with:
34+
key: test-${{ runner.os }}-gcc
35+
max-size: 1000M
36+
37+
- name: Build (Ubuntu 24.04, GCC)
38+
run: |
39+
tools/ci-build.sh
40+
41+
- name: Run tests (Ubuntu 24.04)
42+
# Need to use sudo for the eBPF kernel tests.
43+
run: |
44+
sudo -E env PATH="$PATH" poetry run ctest --output-on-failure --schedule-random
45+
working-directory: ./build
46+
1747
# Build with GCC and test P4C on Ubuntu 22.04.
1848
test-ubuntu22:
1949
runs-on: ubuntu-22.04
@@ -39,7 +69,8 @@ jobs:
3969
4070
- name: Run tests (Ubuntu 22.04)
4171
# Need to use sudo for the eBPF kernel tests.
42-
run: sudo -E ctest --output-on-failure --schedule-random
72+
run: |
73+
sudo -E env PATH="$PATH" poetry run ctest --output-on-failure --schedule-random
4374
working-directory: ./build
4475

4576
# Build with GCC and test Tofino backend on Ubuntu 22.04.
@@ -112,6 +143,7 @@ jobs:
112143
113144
- name: Run tests (Ubuntu 20.04)
114145
# Need to use sudo for the eBPF kernel tests.
115-
run: sudo -E ctest --output-on-failure --schedule-random
146+
run: |
147+
sudo -E env PATH="$PATH" poetry run ctest --output-on-failure --schedule-random
116148
working-directory: ./build
117149
if: matrix.unity == 'ON' && matrix.gtest == 'ON'

.github/workflows/ci-test-fedora.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ jobs:
3535
submodules: recursive
3636

3737
- name: Install dependencies (Fedora Linux)
38-
run: tools/install_fedora_deps.sh
38+
run: |
39+
export PATH="$HOME/.local/bin:$PATH"
40+
tools/install_fedora_deps.sh
3941
4042
- name: ccache
4143
uses: hendrikmuhs/ccache-action@v1
@@ -45,10 +47,12 @@ jobs:
4547

4648
- name: Build p4c (Fedora Linux)
4749
run: |
50+
export PATH="$HOME/.local/bin:$PATH"
4851
./bootstrap.sh -DCMAKE_BUILD_TYPE=Release -DCMAKE_UNITY_BUILD=ON --build-generator "Ninja"
4952
cmake --build build -- -j $(nproc)
5053
5154
- name: Run p4c tests (Fedora Linux)
5255
run: |
53-
export PATH="$HOME/.local/bin:$PATH"; ctest --output-on-failure --schedule-random
56+
export PATH="$HOME/.local/bin:$PATH"
57+
poetry run ctest --output-on-failure --schedule-random
5458
working-directory: ./build

.github/workflows/ci-test-mac.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646

4747
- name: Install dependencies (MacOS)
4848
run: |
49+
source ~/.bash_profile
4950
tools/install_mac_deps.sh
5051
5152
- name: Build (MacOS)
@@ -58,7 +59,7 @@ jobs:
5859
- name: Run tests (MacOS)
5960
run: |
6061
source ~/.bash_profile
61-
ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith"
62+
poetry run ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith"
6263
working-directory: ./build
6364

6465
# Build and test p4c on MacOS 13 on x86.
@@ -93,6 +94,7 @@ jobs:
9394

9495
- name: Install dependencies (MacOS)
9596
run: |
97+
source ~/.bash_profile
9698
tools/install_mac_deps.sh
9799
98100
- name: Build (MacOS)
@@ -105,5 +107,5 @@ jobs:
105107
- name: Run tests (MacOS)
106108
run: |
107109
source ~/.bash_profile
108-
ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith"
110+
poetry run ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith"
109111
working-directory: ./build

.github/workflows/ci-ubuntu-18-nightly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
# this is needed to create network namespaces for the ebpf tests.
4040
- name: Run tests (Ubuntu 18.04)
4141
run: |
42-
sudo -E docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest --output-on-failure --schedule-random
42+
sudo -E docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c poetry run --output-on-failure --schedule-random

.github/workflows/ci-ubuntu-20-sanitizer-nightly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ jobs:
4040
4141
- name: Run tests (Ubuntu 20.04)
4242
# Need to use sudo for the eBPF kernel tests.
43-
run: sudo -E ctest --output-on-failure --schedule-random
43+
run: sudo -E env PATH="$PATH" poetry run ctest --output-on-failure --schedule-random
4444
working-directory: ./build

.github/workflows/ci-validation-nightly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ jobs:
3838
3939
- name: Validate
4040
run: |
41-
ctest -R toz3-validate-p4c --output-on-failure --schedule-random
41+
poetry run ctest -R toz3-validate-p4c --output-on-failure --schedule-random
4242
working-directory: ./build

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ docs/doxygen/awesome_css/
5252

5353
# thirdparty
5454
backends/tofino/third_party/
55+
56+
# Poetry
57+
poetry.lock

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ARG BUILD_AUTO_VAR_INIT_PATTERN=OFF
4646
# - Disable leaks detector as p4c uses GC.
4747
ENV UBSAN_OPTIONS=print_stacktrace=1
4848
ENV ASAN_OPTIONS=print_stacktrace=1:detect_leaks=0
49+
ENV PATH="/root/.local/bin:$PATH"
4950

5051
# Delegate the build to tools/ci-build.
5152
COPY . /p4c/

pyproject.toml

+49
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,52 @@ disable = [
5151
"missing-function-docstring",
5252
"too-few-public-methods",
5353
]
54+
55+
[tool.poetry]
56+
name = "p4c"
57+
version = "1.2.5.1"
58+
description = ""
59+
authors = ["Your Name <[email protected]>"]
60+
license = "Apache"
61+
readme = "README.md"
62+
package-mode = false
63+
64+
[tool.poetry.dependencies]
65+
# Fixme: This restriction is because of pyinstaller
66+
python = "<3.14,>=3.8"
67+
# General testing utilties.
68+
pyroute2 = "0.7.3"
69+
ply = "3.11"
70+
scapy = "2.5.0"
71+
# Utilities for BMv2 and PTF tests.
72+
ptf = "0.10.0"
73+
googleapis-common-protos = "1.53.0"
74+
grpcio = [
75+
{version = "1.67.0", python = ">3.6"},
76+
{version = "1.48.2", python = "<=3.6"}
77+
]
78+
thrift = "0.21.0 "
79+
protobuf = [
80+
{version = "3.20.2", python = ">3.6"},
81+
{version = "3.19.2", python = "<=3.6"}
82+
]
83+
# Linters and formatters.
84+
clang-format = "18.1.0"
85+
black = [
86+
{version = "24.3.0", python = ">3.6"},
87+
{version = "22.8.0", python = "<=3.6"}
88+
]
89+
isort = [
90+
{version = "5.13.2", python = ">3.6"},
91+
{version = "5.10.1", python = "<=3.6"}
92+
]
93+
# FIXME: Remove and replace with local FetchContent version.
94+
p4runtime = "1.4.1"
95+
# FIXME: The Tofino back end should vendor these tools or use them locally.
96+
jsl= "0.2.4"
97+
pyinstaller= "6.11.0"
98+
jsonschema= "4.23.0"
99+
100+
[build-system]
101+
requires = ["poetry-core"]
102+
build-backend = "poetry.core.masonry.api"

requirements.txt

-18
This file was deleted.

tools/ci-build.sh

+8-13
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ fi
104104

105105
sudo apt-get update
106106
sudo apt-get install -y --no-install-recommends ${P4C_DEPS}
107-
sudo pip3 install --upgrade pip
108-
sudo pip3 install -r ${P4C_DIR}/requirements.txt
107+
# Set up poetry.
108+
sudo apt-get install -y python3-venv curl
109+
curl -sSL https://install.python-poetry.org | python3 -
110+
poetry install -C ${P4C_DIR}
109111

110112
if [ "${BUILD_GENERATOR,,}" == "ninja" ] && [ ! $(command -v ninja) ]
111113
then
@@ -128,8 +130,6 @@ function build_bmv2() {
128130
# TODO: Remove this check once 18.04 is deprecated.
129131
if [[ "${DISTRIB_RELEASE}" == "18.04" ]] ; then
130132
P4C_RUNTIME_DEPS_BOOST="libboost-graph1.65.1 libboost-iostreams1.65.1"
131-
else
132-
P4C_RUNTIME_DEPS_BOOST="libboost-graph1.7* libboost-iostreams1.7*"
133133
fi
134134

135135
P4C_RUNTIME_DEPS="cpp \
@@ -146,7 +146,7 @@ function build_bmv2() {
146146
P4C_RUNTIME_DEPS+=" gcc-9 g++-9"
147147
export CC=gcc-9
148148
export CXX=g++-9
149-
else
149+
elif [[ "${DISTRIB_RELEASE}" != "24.04" ]] ; then
150150
sudo apt-get install -y wget ca-certificates
151151
# Add the p4lang opensuse repository.
152152
echo "deb http://download.opensuse.org/repositories/home:/p4lang/xUbuntu_${DISTRIB_RELEASE}/ /" | sudo tee /etc/apt/sources.list.d/home:p4lang.list
@@ -155,11 +155,6 @@ function build_bmv2() {
155155
fi
156156

157157
sudo apt-get update && sudo apt-get install -y --no-install-recommends ${P4C_RUNTIME_DEPS}
158-
159-
if [[ "${DISTRIB_RELEASE}" != "18.04" ]] ; then
160-
# To run PTF nanomsg tests. Not available on 18.04.
161-
sudo pip3 install nnpy
162-
fi
163158
}
164159

165160
if [[ "${ENABLE_BMV2}" == "ON" ]] ; then
@@ -292,12 +287,12 @@ fi
292287
if [ -e build ]; then /bin/rm -rf build; fi
293288
mkdir -p ${P4C_DIR}/build
294289
cd ${P4C_DIR}/build
295-
cmake ${CMAKE_FLAGS} -G "${BUILD_GENERATOR}" ..
290+
poetry run cmake ${CMAKE_FLAGS} -G "${BUILD_GENERATOR}" ..
296291

297292
# If CMAKE_ONLY is active, only run CMake. Do not build.
298293
if [ "$CMAKE_ONLY" == "OFF" ]; then
299-
cmake --build . -- -j $(nproc)
300-
sudo cmake --install .
294+
poetry run cmake --build . -- -j $(nproc)
295+
sudo -E env PATH="$PATH" cmake --install .
301296
# Print ccache statistics after building
302297
ccache -p -s
303298
fi

0 commit comments

Comments
 (0)