Skip to content

Commit

Permalink
Run build and tests directly on Ubuntu 20.04, 22.04 without docker (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbolvansky authored Dec 17, 2022
1 parent 79bbe99 commit 9bfb5a1
Show file tree
Hide file tree
Showing 12 changed files with 346 additions and 156 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/ci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ on:

jobs:
p4c-lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
runs-on: ubuntu-20.04
env:
IMAGE_TYPE: test
CMAKE_ONLY: ON
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -18,22 +23,23 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: apply-linters
key: apply-linters-${{ runner.os }}
max-size: 1000M

# TODO: This check is disabled because git on the Github serves behaves differently. Unclear why.
# - name: Check submodule ref points.
# run: |
# ./tools/check-git-submodules.sh

- name: Build
- name: Build (Ubuntu 20.04)
run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg CMAKE_ONLY=ON .
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
- name: Run cpplint.
run: |
docker run p4c make cpplint -C build
run: make cpplint -C build
working-directory: /p4c

- name: Run clang-format.
run: |
docker run p4c make clang-format -C build
run: make clang-format -C build
working-directory: /p4c
20 changes: 11 additions & 9 deletions .github/workflows/ci-p4tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ jobs:
build-and-test-tools:
strategy:
fail-fast: false
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
env:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
ENABLE_UNIFIED_COMPILATION: ON
ENABLE_TEST_TOOLS: ON
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -30,13 +33,12 @@ jobs:
key: test-tools-${{ matrix.unified }}-${{ runner.os }}
max-size: 1000M

- name: Build (Ubuntu Linux)
- name: Build (Ubuntu 20.04)
run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg ENABLE_TEST_TOOLS=ON .
./tools/export_ccache.sh
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
sudo cp -rf /p4c/.ccache .
# run with sudo (...) --privileged
# this is needed to create network namespaces for the ebpf tests.
- name: Run tests (Ubuntu Linux)
run: |
sudo docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest -R testgen- -j2 --output-on-failure --schedule-random
- name: Run tests (Ubuntu 20.04)
run: sudo -E ctest -R testgen- --output-on-failure --schedule-random
working-directory: /p4c/build
2 changes: 1 addition & 1 deletion .github/workflows/ci-ptf-kernels-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ env.UNIFIED }}-${{ runner.os }}
key: test-ptf-kernels-${{ runner.os }}
max-size: 1000M

- name: Cache VM image
Expand Down
25 changes: 16 additions & 9 deletions .github/workflows/ci-ptf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ concurrency:

jobs:
ptf-linux:
strategy:
fail-fast: false
runs-on: ubuntu-20.04
env:
UNIFIED: ON
runs-on: ubuntu-latest
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
ENABLE_UNIFIED_COMPILATION: ON
MAKEFLAGS: -j8
INSTALL_PTF_EBPF_DEPENDENCIES: ON
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -39,14 +45,15 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ env.UNIFIED }}-${{ runner.os }}
key: test-ptf-${{ runner.os }}
max-size: 1000M

- name: Build (Linux)
- name: Build (Ubuntu 20.04)
run: |
docker build --network host -t p4c --build-arg MAKEFLAGS=-j8 --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=$UNIFIED --build-arg INSTALL_PTF_EBPF_DEPENDENCIES=ON .
./tools/export_ccache.sh
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
sudo cp -rf /p4c/.ccache .
- name: Run PTF tests for eBPF backend (Linux)
run: |
sudo docker run --privileged -v /sys/fs/bpf:/sys/fs/bpf -w /p4c/backends/ebpf/tests p4c ./test.sh
- name: Run PTF tests for eBPF backend (Ubuntu 20.04)
run: sudo -E ./test.sh
working-directory: /p4c/backends/ebpf/tests
15 changes: 9 additions & 6 deletions .github/workflows/ci-static-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ jobs:
build-linux:
strategy:
fail-fast: false
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
env:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
ENABLE_UNIFIED_COMPILATION: ON
BUILD_STATIC_RELEASE: ON
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -28,10 +30,11 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: static-${{ runner.os }}
key: test-static-${{ runner.os }}
max-size: 1000M

- name: Build (Linux)
- name: Build (Ubuntu 20.04)
run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg BUILD_STATIC_RELEASE=ON .
./tools/export_ccache.sh
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
sudo cp -rf /p4c/.ccache .
102 changes: 85 additions & 17 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,48 @@ concurrency:
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
ENABLE_UNIFIED_COMPILATION: ON
steps:
- uses: actions/checkout@v2
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: |
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
sudo cp -rf /p4c/.ccache .
- name: Run tests (Ubuntu 22.04)
run: sudo -E ctest --output-on-failure --schedule-random
working-directory: /p4c/build

# Build with gcc and test p4c on Ubuntu 20.04.
test-linux:
test-ubuntu20:
strategy:
fail-fast: false
matrix:
unified: [ON, OFF]
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
env:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
ENABLE_UNIFIED_COMPILATION: ${{ matrix.unified }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -33,47 +66,82 @@ jobs:
key: test-${{ matrix.unified }}-${{ runner.os }}-gcc
max-size: 1000M

- name: Build (Ubuntu Linux, GCC)
- name: Build (Ubuntu 20.04, GCC)
run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=${{ matrix.unified }} .
./tools/export_ccache.sh
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
sudo cp -rf /p4c/.ccache .
# run with sudo (...) --privileged
# this is needed to create network namespaces for the ebpf tests.
- name: Run tests (Ubuntu Linux)
run: |
sudo docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest --output-on-failure --schedule-random
- name: Run tests (Ubuntu 20.04)
run: sudo -E ctest --output-on-failure --schedule-random
working-directory: /p4c/build
if: matrix.unified == 'ON'

# Build with clang and test p4c on Ubuntu 20.04.
test-linux-clang-sanitizers:
test-ubuntu20-clang-sanitizers:
strategy:
fail-fast: false
runs-on: ubuntu-20.04
env:
CTEST_PARALLEL_LEVEL: 2
IMAGE_TYPE: test
ENABLE_UNIFIED_COMPILATION: ON
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@v2
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: |
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
sudo cp -rf /p4c/.ccache .
- name: Run tests (Ubuntu 20.04)
run: sudo -E ctest --output-on-failure --schedule-random
working-directory: /p4c/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
ENABLE_UNIFIED_COMPILATION: ON
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ runner.os }}-clang
key: test-ubuntu-18.04-gcc
max-size: 1000M

- name: Build (Ubuntu Linux, Clang, Sanitizers)
- name: Build (Ubuntu 18.04, GCC)
run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg COMPILE_WITH_CLANG=ON \
--build-arg BUILD_AUTO_VAR_INIT_PATTERN=ON --build-arg ENABLE_SANITIZERS=ON .
docker build -t p4c --build-arg BASE_IMAGE=ubuntu:18.04 --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON .
./tools/export_ccache.sh
# run with sudo (...) --privileged
# this is needed to create network namespaces for the ebpf tests.
- name: Run tests (Ubuntu Linux)
- name: Run tests (Ubuntu 18.04)
run: |
sudo docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest --output-on-failure --schedule-random
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:
Expand Down
25 changes: 10 additions & 15 deletions .github/workflows/ci-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ jobs:
# We only test the front end and some mid end passes for now.
validate:
env:
UNIFIED: ON
BUILD_SUCCESS: true
CTEST_PARALLEL_LEVEL: 4
runs-on: ubuntu-latest
IMAGE_TYPE: test
ENABLE_UNIFIED_COMPILATION: ON
VALIDATION: ON
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -32,18 +33,12 @@ jobs:
key: validation-${{ runner.os }}
max-size: 1000M

- name: Build (Linux)
- name: Build (Ubuntu 20.04)
run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=$UNIFIED --build-arg VALIDATION=ON . || echo "BUILD_SUCCESS=false" >> $GITHUB_ENV
./tools/export_ccache.sh || echo "BUILD_SUCCESS=false" >> $GITHUB_ENV
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
sudo cp -rf /p4c/.ccache .
- name: Validate
if: env.BUILD_SUCCESS == 'true'
run: |
docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest -R toz3-validate-p4c --output-on-failure --schedule-random
- name: Build Failed
if: env.BUILD_SUCCESS == 'false'
run: |
echo "Building Gauntlet failed."
run: sudo -E ctest -R toz3-validate-p4c --output-on-failure --schedule-random
working-directory: /p4c/build
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM p4lang/behavioral-model:latest
ARG BASE_IMAGE=p4lang/behavioral-model:latest
FROM ${BASE_IMAGE}
LABEL maintainer="P4 Developers <[email protected]>"

# Default to using 2 make jobs, which is a good default for CI. If you're
Expand Down Expand Up @@ -46,6 +47,6 @@ ENV ASAN_OPTIONS=print_stacktrace=1:detect_leaks=0

# Delegate the build to tools/ci-build.
COPY . /p4c/
RUN chmod u+x /p4c/tools/ci-build.sh && /p4c/tools/ci-build.sh
RUN /p4c/tools/ci-build.sh
# Set the workdir after building p4c.
WORKDIR /p4c/
2 changes: 1 addition & 1 deletion backends/ubpf/ubpfTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void UBPFTable::emitInstance(EBPF::CodeBuilder* builder) {
}

void UBPFTable::setTableKind() {
// set table kind to HASH by default
// Set table kind to HASH by default
this->tableKind = EBPF::TableHash;
if (keyGenerator == nullptr) {
return;
Expand Down
Loading

0 comments on commit 9bfb5a1

Please sign in to comment.