diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4dba9f592c..f41055cef2 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -10,6 +10,7 @@ on: env: BUILD_DIR: Dist GCOVR_FLAGS: --gcov-ignore-parse-errors --exclude-throw-branches --filter Common --filter Pcap --filter Packet --xml + CCACHE_DIR: ${{ github.workspace }}/.ccache permissions: contents: read @@ -90,6 +91,13 @@ jobs: . /opt/intel/oneapi/setvars.sh printenv >> $GITHUB_ENV + - name: Restore Ccache + id: ccache-restore + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ matrix.image }}-ccache + - name: Configure PcapPlusPlus run: cmake -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} -DPCAPPP_BUILD_COVERAGE=ON ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR" @@ -113,7 +121,7 @@ jobs: run: | cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR + cmake --install "$BUILD_DIR" - name: Build Tutorials run: | @@ -138,6 +146,12 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Save Ccache + uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache-restore.outputs.cache-primary-key }} + dpdk: runs-on: ubuntu-latest container: seladb/${{ matrix.image }} @@ -154,6 +168,13 @@ jobs: - name: Checkout code uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Restore Ccache + id: ccache-restore + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ matrix.image }}-ccache + - name: Configure PcapPlusPlus run: cmake -DPCAPPP_USE_DPDK=ON ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR" @@ -177,7 +198,7 @@ jobs: run: | cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR + cmake --install "$BUILD_DIR" - name: Build Tutorials run: | @@ -187,6 +208,12 @@ jobs: - name: Test Tutorials run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld + - name: Save Ccache + uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache-restore.outputs.cache-primary-key }} + pfring: runs-on: ubuntu-latest container: seladb/ubuntu2004-pfring @@ -199,6 +226,13 @@ jobs: - name: Checkout code uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Restore Ccache + id: ccache-restore + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ matrix.image }}-ccache + - name: Configure PcapPlusPlus run: ${{ matrix.configure }} @@ -219,7 +253,7 @@ jobs: run: | cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR + cmake --install "$BUILD_DIR" - name: Build Tutorials run: | @@ -229,24 +263,39 @@ jobs: - name: Test Tutorials run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - macos-x86: + - name: Save Ccache + uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache-restore.outputs.cache-primary-key }} + + macos: runs-on: ${{ matrix.os-version }} strategy: matrix: include: - os-version: macos-12 + host-arch: x86_64 arch: x86_64 config-zstd: OFF - os-version: macos-12 + host-arch: x86_64 arch: arm64 config-zstd: OFF - os-version: macos-13 + host-arch: x86_64 arch: x86_64 config-zstd: OFF - os-version: macos-13 + host-arch: x86_64 arch: x86_64 config-zstd: ON - os-version: macos-13 + host-arch: x86_64 + arch: arm64 + config-zstd: OFF + - os-version: macos-14 + host-arch: arm64 arch: arm64 config-zstd: OFF @@ -254,15 +303,27 @@ jobs: - name: Checkout code uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + - name: Setup Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: # support version: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json python-version: "3.12" + - name: Install Requirements Ccache & Tcpreplay + run: brew install ccache tcpreplay + + - name: Restore Ccache + id: ccache-restore + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ matrix.os-version }}-ccache + - name: Configure PcapPlusPlus # Ensure user have access to network devices instead of giving super-user right run: | sudo chmod a+rw /dev/bpf* + sudo chmod a+rw /usr/local cmake -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -DPCAPPP_BUILD_COVERAGE=ON -S . -B "$BUILD_DIR" - name: Build PcapPlusPlus @@ -271,19 +332,16 @@ jobs: - name: Check architecture run: lipo $BUILD_DIR/Pcap++/libPcap++.a -verify_arch ${{ matrix.arch }} - - name: Install Tcpreplay - run: brew install tcpreplay - - name: Test PcapPlusPlus # We can't run cross compiled binaries - if: ${{ matrix.arch == 'x86_64' }} + if: ${{ matrix.host-arch == matrix.arch }} run: | python -m pip install -U pip python -m pip install -r ci/run_tests/requirements.txt python ci/run_tests/run_tests.py --interface en0 - name: Test Examples - if: ${{ matrix.arch == 'x86_64' }} + if: ${{ matrix.host-arch == matrix.arch }} run: | cd Tests/ExamplesTest python -m pip install -U pip @@ -294,7 +352,7 @@ jobs: run: | cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR + cmake --install "$BUILD_DIR" - name: Build Tutorials run: | @@ -303,7 +361,7 @@ jobs: cmake --build build_examples -j - name: Test Tutorials - if: ${{ matrix.arch == 'x86_64' }} + if: ${{ matrix.host-arch == matrix.arch }} run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - name: Create Cobertura Report @@ -321,80 +379,11 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - macos-m1: - runs-on: ${{ matrix.os-version }} - strategy: - matrix: - os-version: [macos-14] - - steps: - - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - # support version: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json - python-version: "3.12" - - - name: Configure PcapPlusPlus - # Ensure user have access to network devices instead of giving super-user right - # Seems macos-14 has more strict file permission - run: | - sudo chmod a+rw /dev/bpf* - sudo chmod a+rw /usr/local - cmake -DPCAPPP_BUILD_COVERAGE=ON -S . -B "$BUILD_DIR" - - - name: Build PcapPlusPlus - run: cmake --build "$BUILD_DIR" -j - - - name: Check architecture - run: lipo $BUILD_DIR/Pcap++/libPcap++.a -verify_arch arm64 - - - name: Install Tcpreplay - run: brew install tcpreplay - - - name: Test PcapPlusPlus - run: | - python -m pip install -U pip - python -m pip install -r ci/run_tests/requirements.txt - python ci/run_tests/run_tests.py --interface en0 - - - name: Test Examples - run: | - cd Tests/ExamplesTest - python -m pip install -U pip - python -m pip install -r requirements.txt - python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin - - - name: Check installation - run: | - cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" - cmake --build "$BUILD_DIR" -j - cmake --install "$BUILD_DIR" - - - name: Build Tutorials - run: | - mkdir -p build_examples - cmake -DPCAPPP_BUILD_TUTORIALS=ON -S Examples -B build_examples - cmake --build build_examples -j - - - name: Test Tutorials - run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld - - - name: Create Cobertura Report - run: | - python3 -m pip install gcovr - gcovr -v -r . $GCOVR_FLAGS -o coverage.xml - - - name: Upload Coverage Results - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 + - name: Save Ccache + uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: - files: ./coverage.xml - flags: ${{ matrix.os-version }},unittest - fail_ci_if_error: false - verbose: true - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache-restore.outputs.cache-primary-key }} mingw-w64: runs-on: windows-latest @@ -423,7 +412,7 @@ jobs: - name: Setup Python uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: - python-version: "3.8.x" + python-version: "3.12" - name: Install NPcap env: @@ -504,9 +493,10 @@ jobs: - name: Checkout code uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + - name: Setup Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: - python-version: "3.8.x" + python-version: "3.12" - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0 @@ -660,7 +650,7 @@ jobs: PCAPPLUSPLUS_INCLUDE_PATH="$TOYVPN_PCAPPLUSPLUS/include" cmake -DPCAPPP_BUILD_COVERAGE=OFF -S . -B "$BUILD_DIR" cmake --build "$BUILD_DIR" -j - cmake --install $BUILD_DIR --prefix ${TOYVPN_PCAPPLUSPLUS} + cmake --install "$BUILD_DIR" --prefix ${TOYVPN_PCAPPLUSPLUS} mkdir -p ${PCAPPLUSPLUS_LIBS_PATH} ${PCAPPLUSPLUS_INCLUDE_PATH} mv ${TOYVPN_PCAPPLUSPLUS}/lib/*.a ${PCAPPLUSPLUS_LIBS_PATH}/ mv ${TOYVPN_PCAPPLUSPLUS}/include/pcapplusplus/*.h ${PCAPPLUSPLUS_INCLUDE_PATH}/ @@ -681,7 +671,14 @@ jobs: - name: Install dependencies run: | - sudo apt update && sudo apt -y install libpcap-dev libbpf-dev tcpreplay + sudo apt update && sudo apt -y install ccache libpcap-dev libbpf-dev tcpreplay + + - name: Restore Ccache + id: ccache-restore + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ matrix.image }}-ccache - name: Configure PcapPlusPlus run: cmake -DPCAPPP_USE_XDP=ON -DPCAPPP_BUILD_COVERAGE=ON -S . -B $BUILD_DIR @@ -692,8 +689,8 @@ jobs: - name: Test PcapPlusPlus run: | python -m pip install -U pip - python -m pip install -r ci/run_tests/requirements.txt - python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" + python -m pip install -r ci/run_tests/requirements.txt + python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp" - name: Create Cobertura Report run: | @@ -710,6 +707,12 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Save Ccache + uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache-restore.outputs.cache-primary-key }} + test_regressions: name: Run ${{ matrix.engine }}-${{ matrix.sanitizer }} fuzzer for regressions runs-on: ubuntu-latest @@ -721,23 +724,40 @@ jobs: container: image: gcr.io/oss-fuzz-base/base-builder steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Checkout code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Install prerequisites run: | - apt-get update && apt-get install -y cmake autoconf flex bison + apt-get update && apt-get install -y autoconf bison ccache cmake flex cd .. cp -r PcapPlusPlus/ $SRC/PcapPlusPlus git clone --depth=1 https://github.com/the-tcpdump-group/libpcap.git $SRC/libpcap cd $SRC/PcapPlusPlus/ - - name: Compile fuzzer + + - name: Restore Ccache + id: ccache-restore + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ matrix.engine }}-${{ matrix.sanitizer }}-ccache + + - name: Compile PcapPlusPlus Fuzzer application run: | export FUZZING_LANGUAGE=c export ARCHITECTURE=x86_64 export FUZZING_ENGINE=${{ matrix.engine }} export SANITIZER=${{ matrix.sanitizer }} $SRC/PcapPlusPlus/Tests/Fuzzers/ossfuzz.sh + - name: Check for regressions run: | export BINARY="$OUT/FuzzTarget" export SAMPLES="Tests/Fuzzers/RegressionTests/regression_samples" Tests/Fuzzers/RegressionTests/run_tests.sh + + - name: Save Ccache + uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache-restore.outputs.cache-primary-key }}