From b15dd0306b8be9ce1217f9de84411c36699de2d3 Mon Sep 17 00:00:00 2001 From: Zhihua Lai <92519564+doctorlai-msrc@users.noreply.github.com> Date: Wed, 2 Jul 2025 17:32:40 +0100 Subject: [PATCH 1/5] syncs from the dev branch to the main branch (#122) * Adding a emulator * Add Python/ctypesgen dependencies for emulator * Add jbpf_agent_hooks.h and generate py * Add time helper functions * Test emulator * Add missing file * Add missing fields * Fix time event initialization * Refactor * Remove protobuf, update jbpf_stats_report.o * Add xran helper functions, and create random stream_id * Clang-format * Fix cppcheck issue * Refactor default values * Default num_codelet_descriptors to len(codelet_descriptors) * Enable ASAN in tests, ignore ODR, cleanup * Clangformat * Support custom helper functions and refactor * Fix clang-format * Move definitions above users include file * Remove XRAN * Add Custom init code * Add yaml_to_json, refactor * Fix path * Add debug option to emulator_utils.jbpf_handle_out_bufs * Match codelet_descriptor in yaml * Add missing define agent hooks * Revert * jbpf_handle_out_bufs should return how many messages that have been processed * Add some debug output when calling periodic_call and report_stats hook * Add a test to make sure the report_stats is actually called * Add comment * Clang-format -i * Add debug printf * Continued work * Add matching ck_epoch_end * Clang * Continued testing * Add more debugging * Clang * Debug * Debug print * Add more debugging message * More debugging * Add tests for report_stats and periodic_call, add debugging * Clang-format * Pipeline integration * simple_output2.o * Add missing files * Refactor & debug * COntinued work * Continued work * Revert and Cleanup * Revert * Fix * Ignore dynamic builds * Fix * Fix syntax * Fix syntax * Keep static mode only * Revert * Emulate time and add a test * Add test * Fix clang-format * Add missing file * Fix compilation under ubuntu20 * Init draft of adding both options * Fix * Pipeline * Move autogen wrappers * Fix cppcheck issue * Build both by default * Fix JBPF_SHARED_LIB * Fix build under ubuntu24.04 * Fix segfault at Static * Add emulator tests to github action, fix RELEASE * Typo * First round of addressing comments * Improve test description comments * Add some more doc * Add to ARM pipeline * Sync dev with main (#105) * Add helper function for fixed points (#71) * Add helper function for fixed points * Addressing the comments * Revert * Continued work * Fix the algorithms and tests * Minor tweaks * Cleanup * Avoid clang optimise the code * Fix implementations * Test fixed_to_float and fixed_to_double * Fix type * Add 2 more tests * Cleanup * Clang format inconsistent fix * Add more tests in the codelet * Increase MAX_NUM_HOOKS from 64 to 128 (#90) * Increase MAX_NUM_HOOKS from 64 to 96 * Increase MAX_NUM_HOOKS to 128 --------- Co-authored-by: Zhihua Lai <92519564+doctorlai-msrc@users.noreply.github.com> Co-authored-by: matthewbalkwill <93522480+matthewbalkwill@users.noreply.github.com> * Refactor docker files * Add to github actions * Add System Information * Merge and fix * Fix comments * Readme * More doc * Update docs * Move emulator tests to the end * Add debug messages * Add more debug * Update codelet to provide more information * Comment * Fix print error * Revert "Update codelet to provide more information" This reverts commit 95dc9e4db9ae44e5f0b715a29917cc5c3db73d77. * Fix segfault * Use smart ptr * Revert "Adding a emulator" * Revert "Enable Building Both libjbpf.a and libjbpf.so with cmake option -DJBPF_STATIC=Both" --------- Co-authored-by: Xenofon Foukas <137962+xfoukas@users.noreply.github.com> Co-authored-by: matthewbalkwill <93522480+matthewbalkwill@users.noreply.github.com> --- src/io/jbpf_io_channel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/io/jbpf_io_channel.c b/src/io/jbpf_io_channel.c index 3956df9..20262de 100644 --- a/src/io/jbpf_io_channel.c +++ b/src/io/jbpf_io_channel.c @@ -442,11 +442,9 @@ jbpf_io_destroy_out_channel(struct jbpf_io_channel_list* channel_list, struct jb ck_epoch_end(local_out_channel_list_epoch_record, NULL); ck_epoch_call(local_out_channel_list_epoch_record, &io_channel->epoch_entry, io_channel_destructor); ck_epoch_barrier(local_out_channel_list_epoch_record); - jbpf_logger( - JBPF_INFO, - "Barrier reached and channel %p was destroyed (stream id %s)\n", - io_channel, - io_channel->stream_id.id); + char sname[JBPF_IO_STREAM_ID_LEN * 3]; + _jbpf_io_tohex_str(io_channel->stream_id.id, JBPF_IO_STREAM_ID_LEN, sname, JBPF_IO_STREAM_ID_LEN * 3); + jbpf_logger(JBPF_INFO, "Barrier reached and channel %p was destroyed (stream id %s)\n", io_channel, sname); } void @@ -673,7 +671,9 @@ jbpf_io_channel_send_data(struct jbpf_io_channel* channel, void* data, size_t si jbpf_channel_buf_ptr data_buf = jbpf_io_channel_reserve_buf(channel); if (!data_buf) { - jbpf_logger(JBPF_ERROR, "Error reserving buffer for channel %s\n", channel->stream_id.id); + char sname[JBPF_IO_STREAM_ID_LEN * 3]; + _jbpf_io_tohex_str(channel->stream_id.id, JBPF_IO_STREAM_ID_LEN, sname, JBPF_IO_STREAM_ID_LEN * 3); + jbpf_logger(JBPF_ERROR, "Error reserving buffer for channel %s\n", sname); return -1; } memcpy(data_buf, data, size); From c489120236fc14eb3f15e1f2d0d1385059310bf7 Mon Sep 17 00:00:00 2001 From: Zhihua Lai Date: Fri, 21 Aug 2026 09:38:40 +0100 Subject: [PATCH 2/5] Ensure PR flow from dev only --- .github/workflows/ensure-main-from-dev.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/ensure-main-from-dev.yaml diff --git a/.github/workflows/ensure-main-from-dev.yaml b/.github/workflows/ensure-main-from-dev.yaml new file mode 100644 index 0000000..04e7793 --- /dev/null +++ b/.github/workflows/ensure-main-from-dev.yaml @@ -0,0 +1,19 @@ +## This workflow ensures that all pull requests to the main branch come from the dev branch. +## If a PR is opened against main from any other branch, the workflow will fail and prevent merging. +name: Enforce PR Flow + +on: + pull_request: + branches: + - main + +jobs: + check-source-branch: + runs-on: ubuntu-latest + + steps: + - name: Only allow dev into main + if: github.head_ref != 'dev' + run: | + echo "PRs to main must come from dev." + exit 1 From 6dfee03bd67bee9bbedc2c75bdc61594d04b5e48 Mon Sep 17 00:00:00 2001 From: Zhihua Lai Date: Fri, 21 Aug 2026 11:59:40 +0100 Subject: [PATCH 3/5] fix(ci): retry the tdnf --- deploy/mariner.Dockerfile | 15 +++++++++------ deploy/retry-tdnf.sh | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 deploy/retry-tdnf.sh diff --git a/deploy/mariner.Dockerfile b/deploy/mariner.Dockerfile index 56f103d..c704be3 100644 --- a/deploy/mariner.Dockerfile +++ b/deploy/mariner.Dockerfile @@ -1,13 +1,16 @@ FROM mcr.microsoft.com/azurelinux/base/core:3.0 +COPY deploy/retry-tdnf.sh /usr/local/bin/retry-tdnf +RUN chmod 755 /usr/local/bin/retry-tdnf + RUN echo "*** Installing packages" -RUN tdnf upgrade tdnf --refresh -y -RUN tdnf -y update -RUN tdnf -y install build-essential cmake git -RUN tdnf -y install yaml-cpp-devel yaml-cpp-static boost-devel gcovr clang python3 -RUN tdnf -y install doxygen +RUN retry-tdnf upgrade tdnf --refresh -y +RUN retry-tdnf -y update +RUN retry-tdnf -y install build-essential cmake git +RUN retry-tdnf -y install yaml-cpp-devel yaml-cpp-static boost-devel gcovr clang python3 +RUN retry-tdnf -y install doxygen ## clang-format -RUN tdnf -y install clang-tools-extra +RUN retry-tdnf -y install clang-tools-extra WORKDIR /jbpf COPY . /jbpf diff --git a/deploy/retry-tdnf.sh b/deploy/retry-tdnf.sh new file mode 100644 index 0000000..a08efbb --- /dev/null +++ b/deploy/retry-tdnf.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -u + +max_attempts="${TDNF_MAX_ATTEMPTS:-5}" +attempt=1 + +while :; do + tdnf "$@" + status=$? + if [ "$status" -eq 0 ]; then + exit 0 + fi + if [ "$attempt" -ge "$max_attempts" ]; then + exit "$status" + fi + + echo "tdnf failed (attempt $attempt/$max_attempts); refreshing metadata and retrying" + tdnf makecache --refresh || true + sleep $((attempt * 5)) + attempt=$((attempt + 1)) +done \ No newline at end of file From 58ceb14221d8e56a52d0258fcc906f5cb1fe60ea Mon Sep 17 00:00:00 2001 From: Zhihua Lai Date: Fri, 21 Aug 2026 12:02:11 +0100 Subject: [PATCH 4/5] Revert "fix(ci): retry the tdnf" This reverts commit 6dfee03bd67bee9bbedc2c75bdc61594d04b5e48. --- deploy/mariner.Dockerfile | 15 ++++++--------- deploy/retry-tdnf.sh | 22 ---------------------- 2 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 deploy/retry-tdnf.sh diff --git a/deploy/mariner.Dockerfile b/deploy/mariner.Dockerfile index c704be3..56f103d 100644 --- a/deploy/mariner.Dockerfile +++ b/deploy/mariner.Dockerfile @@ -1,16 +1,13 @@ FROM mcr.microsoft.com/azurelinux/base/core:3.0 -COPY deploy/retry-tdnf.sh /usr/local/bin/retry-tdnf -RUN chmod 755 /usr/local/bin/retry-tdnf - RUN echo "*** Installing packages" -RUN retry-tdnf upgrade tdnf --refresh -y -RUN retry-tdnf -y update -RUN retry-tdnf -y install build-essential cmake git -RUN retry-tdnf -y install yaml-cpp-devel yaml-cpp-static boost-devel gcovr clang python3 -RUN retry-tdnf -y install doxygen +RUN tdnf upgrade tdnf --refresh -y +RUN tdnf -y update +RUN tdnf -y install build-essential cmake git +RUN tdnf -y install yaml-cpp-devel yaml-cpp-static boost-devel gcovr clang python3 +RUN tdnf -y install doxygen ## clang-format -RUN retry-tdnf -y install clang-tools-extra +RUN tdnf -y install clang-tools-extra WORKDIR /jbpf COPY . /jbpf diff --git a/deploy/retry-tdnf.sh b/deploy/retry-tdnf.sh deleted file mode 100644 index a08efbb..0000000 --- a/deploy/retry-tdnf.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -set -u - -max_attempts="${TDNF_MAX_ATTEMPTS:-5}" -attempt=1 - -while :; do - tdnf "$@" - status=$? - if [ "$status" -eq 0 ]; then - exit 0 - fi - if [ "$attempt" -ge "$max_attempts" ]; then - exit "$status" - fi - - echo "tdnf failed (attempt $attempt/$max_attempts); refreshing metadata and retrying" - tdnf makecache --refresh || true - sleep $((attempt * 5)) - attempt=$((attempt + 1)) -done \ No newline at end of file From 6f8d0490976035c5355cdcdb5f1056c44cab29f4 Mon Sep 17 00:00:00 2001 From: Zhihua Lai Date: Fri, 21 Aug 2026 12:02:53 +0100 Subject: [PATCH 5/5] Refactor the CI --- .github/workflows/ensure-main-from-dev.yaml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ensure-main-from-dev.yaml b/.github/workflows/ensure-main-from-dev.yaml index 04e7793..0c2ff23 100644 --- a/.github/workflows/ensure-main-from-dev.yaml +++ b/.github/workflows/ensure-main-from-dev.yaml @@ -1,19 +1,21 @@ -## This workflow ensures that all pull requests to the main branch come from the dev branch. -## If a PR is opened against main from any other branch, the workflow will fail and prevent merging. name: Enforce PR Flow on: pull_request: - branches: - - main + types: [opened, synchronize, reopened, edited] jobs: check-source-branch: runs-on: ubuntu-latest steps: - - name: Only allow dev into main - if: github.head_ref != 'dev' + - name: Check PR flow run: | - echo "PRs to main must come from dev." - exit 1 + echo "PR: ${{ github.head_ref }} -> ${{ github.base_ref }}" + + if [[ "${{ github.base_ref }}" == "main" && "${{ github.head_ref }}" != "dev" ]]; then + echo "PRs to main must come from dev." + exit 1 + fi + + echo "PR flow is valid."