From 99af0ba0e5a9882a3eabba7eb2d7894dcc3d5b3e Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Tue, 29 Jul 2025 16:29:05 +0200 Subject: [PATCH 1/7] .github: fix parallel selection for workflow call Signed-off-by: Richard Alpe --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 436e9de3..6f8b55bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,8 @@ jobs: build: name: Build ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }} ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }} runs-on: [ self-hosted, latest ] + env: + PARALLEL: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.parallel == 'true' || github.event_name != 'workflow_dispatch' && inputs.parallel == true }} strategy: fail-fast: false outputs: @@ -126,7 +128,7 @@ jobs: id: parallel run: | - if [ "${{ ((github.event.inputs.parallel == 'true' && github.event_name == 'workflow_dispatch') || (github.ref_name != 'main' && github.event_name != 'workflow_dispatch')) }}" == "true" ]; then + if [ "$PARALLEL" == "true" ]; then echo "BR2_PER_PACKAGE_DIRECTORIES=y" >> output/.config MAKE="make -j$((`getconf _NPROCESSORS_ONLN` / 2 + 2))" echo "Building in parallel with -j$((`getconf _NPROCESSORS_ONLN` / 2 + 2))" From c1352302893d9c4bbfdfbcbcec1d6a1ec3619d14 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Mon, 4 Aug 2025 11:19:27 +0200 Subject: [PATCH 2/7] .github: only run main workflow on kernelkit/ Avoid trying to run on forks, which most likely will cause erros and other ugliness. Signed-off-by: Richard Alpe --- .github/workflows/trigger.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/trigger.yml b/.github/workflows/trigger.yml index 125a6162..8fe5d0ba 100644 --- a/.github/workflows/trigger.yml +++ b/.github/workflows/trigger.yml @@ -1,4 +1,4 @@ -name: Self Trigger +name: Kernelkit Trigger on: pull_request: @@ -11,6 +11,7 @@ on: jobs: build-x86_64: + if: startsWith(github.repository, 'kernelkit/') uses: ./.github/workflows/build.yml with: target: "x86_64" @@ -18,6 +19,7 @@ jobs: flavor: "_minimal" build-aarch64: + if: startsWith(github.repository, 'kernelkit/') uses: ./.github/workflows/build.yml with: target: "aarch64" @@ -25,6 +27,7 @@ jobs: flavor: "_minimal" test-run-x86_64: + if: startsWith(github.repository, 'kernelkit/') needs: build-x86_64 uses: ./.github/workflows/test.yml with: @@ -32,6 +35,7 @@ jobs: name: "infix" test-publish-x86_64: + if: startsWith(github.repository, 'kernelkit/') needs: test-run-x86_64 uses: ./.github/workflows/publish.yml From 15a2221b23c024409dbedd4b4a89c5dec979a3bd Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Mon, 4 Aug 2025 11:49:16 +0200 Subject: [PATCH 3/7] .github: add generic x86 build that runs on GH hardware Signed-off-by: Richard Alpe --- .github/workflows/generic-x86-build.yml | 78 +++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/generic-x86-build.yml diff --git a/.github/workflows/generic-x86-build.yml b/.github/workflows/generic-x86-build.yml new file mode 100644 index 00000000..ed573d38 --- /dev/null +++ b/.github/workflows/generic-x86-build.yml @@ -0,0 +1,78 @@ +name: Generic X86 GitHub Build + +on: + push: + pull_request: + +jobs: + build: + name: Infix x86_64 + runs-on: ubuntu-latest + + steps: + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + bc binutils build-essential bzip2 cpio \ + diffutils file findutils git gzip \ + libncurses-dev libssl-dev perl patch \ + python3 rsync sed tar unzip wget \ + autopoint bison flex autoconf automake \ + mtools + + - name: Checkout infix repo + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + ref: ${{ github.ref }} + fetch-depth: 0 + submodules: recursive + + - name: Set Build Variables + id: vars + run: | + echo "INFIX_BUILD_ID=${{ github.run_id }}" >> $GITHUB_OUTPUT + echo "dir=Infix-x86_64" >> $GITHUB_OUTPUT + echo "tgz=Infix-x86_64.tar.gz" >> $GITHUB_OUTPUT + echo "flv=_minimal" >> $GITHUB_OUTPUT + + - name: Configure x86_64_minimal + run: | + make x86_64_minimal_defconfig + + - name: Unit Test x86_64 + run: | + make test-unit + + - name: Build x86_64_minimal + run: | + make + + - name: Check SBOM + run: | + make legal-info + + - name: Build test spec + run: | + make test-spec + + - name: Report Build Size + run: | + du -sh . + du -sh output + du -sh dl || true + ls -l output/images/ + + - name: Prepare Artifact + run: | + cd output/ + mv images Infix-x86_64 + ln -s Infix-x86_64 images + tar cfz Infix-x86_64.tar.gz Infix-x86_64 + + - uses: actions/upload-artifact@v4 + with: + path: output/Infix-x86_64.tar.gz + name: artifact-x86_64 + From b3fe0d58d875366ad6a6c1955f7be4ad9a22e46a Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Tue, 5 Aug 2025 15:05:19 +0200 Subject: [PATCH 4/7] yager: handle usb info though the HOST api Prior to this commit yanger looked at the running system using os.path..., this meant that the static reply / capture data wasn't used properly. This resulted in strange behavior during unit testing on GitHub runners where USB ports are missing. Signed-off-by: Richard Alpe --- src/statd/python/yanger/host.py | 24 ++++++++++++++++++++++++ src/statd/python/yanger/ietf_hardware.py | 22 ++++++++++------------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/statd/python/yanger/host.py b/src/statd/python/yanger/host.py index 1fcceb90..8fd4f01c 100644 --- a/src/statd/python/yanger/host.py +++ b/src/statd/python/yanger/host.py @@ -116,6 +116,11 @@ class Localhost(Host): return None + def exists(self, path: str) -> bool: + try: + return os.path.exists(path) + except OSError: + return False class Remotehost(Localhost): def __init__(self, prefix, capdir): @@ -159,6 +164,18 @@ class Remotehost(Localhost): return out + def exists(self, path: str) -> bool: + if not self._run(("ls", path), default="", log=False): + return False + + if self.capdir: + dirname = os.path.join(self.capdir, "rootfs", os.path.dirname(path[1:])) + filname = os.path.join(self.capdir, "rootfs", path[1:]) + os.makedirs(dirname, exist_ok=True) + open(filname, "w", encoding='utf-8').close() # Create empty file + + return True + def read(self, path): out = self._run(("cat", path), default="", log=False) @@ -199,6 +216,13 @@ class Replayhost(Host): common.LOG.error(f"No recording found for run \"{path}\"") raise + def exists(self, path: str) -> bool: + path = os.path.join(self.replaydir, "rootfs", path[1:]) + try: + return os.path.exists(path) + except OSError: + return False + def read(self, path): path = os.path.join(self.replaydir, "rootfs", path[1:]) try: diff --git a/src/statd/python/yanger/ietf_hardware.py b/src/statd/python/yanger/ietf_hardware.py index 70a4aa29..94a74f65 100644 --- a/src/statd/python/yanger/ietf_hardware.py +++ b/src/statd/python/yanger/ietf_hardware.py @@ -61,18 +61,16 @@ def usb_port_components(systemjson): path = usb_port["path"] if os.path.basename(path) == "authorized_default": - # TODO: Untestable. Should be done via the host API - if os.path.exists(path): - with open(path, "r") as f: - names.append(usb_port["name"]) - data = int(f.readline().strip()) - enabled = "unlocked" if data == 1 else "locked" - port["state"] = {} - port["state"]["admin-state"] = enabled - port["name"] = usb_port["name"] - port["class"] = "infix-hardware:usb" - port["state"]["oper-state"] = "enabled" - ports.append(port) + if HOST.exists(path): + names.append(usb_port["name"]) + data = int(HOST.read(path)) + enabled = "unlocked" if data == 1 else "locked" + port["state"] = {} + port["state"]["admin-state"] = enabled + port["name"] = usb_port["name"] + port["class"] = "infix-hardware:usb" + port["state"]["oper-state"] = "enabled" + ports.append(port) return ports From 30757c8160b35a726b81b5c58e5039caa9d75439 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Tue, 5 Aug 2025 15:15:49 +0200 Subject: [PATCH 5/7] test: add statd usb data captured by yanger Signed-off-by: Richard Alpe --- test/case/statd/system/cli/show-hardware | 4 ++-- test/case/statd/system/ietf-hardware.json | 4 ++-- test/case/statd/system/operational.json | 4 ++-- .../system/rootfs/sys/bus/usb/devices/usb1/authorized_default | 1 + .../system/rootfs/sys/bus/usb/devices/usb2/authorized_default | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 test/case/statd/system/system/rootfs/sys/bus/usb/devices/usb1/authorized_default create mode 100644 test/case/statd/system/system/rootfs/sys/bus/usb/devices/usb2/authorized_default diff --git a/test/case/statd/system/cli/show-hardware b/test/case/statd/system/cli/show-hardware index 29460a6c..a598d096 100644 --- a/test/case/statd/system/cli/show-hardware +++ b/test/case/statd/system/cli/show-hardware @@ -1,4 +1,4 @@ USB PORTS  NAME STATE  -USB unlocked -USB2 unlocked +USB locked +USB2 locked diff --git a/test/case/statd/system/ietf-hardware.json b/test/case/statd/system/ietf-hardware.json index c8153af6..cea9cbe9 100644 --- a/test/case/statd/system/ietf-hardware.json +++ b/test/case/statd/system/ietf-hardware.json @@ -7,7 +7,7 @@ }, { "state": { - "admin-state": "unlocked", + "admin-state": "locked", "oper-state": "enabled" }, "name": "USB", @@ -15,7 +15,7 @@ }, { "state": { - "admin-state": "unlocked", + "admin-state": "locked", "oper-state": "enabled" }, "name": "USB2", diff --git a/test/case/statd/system/operational.json b/test/case/statd/system/operational.json index 31826b87..1cb94407 100644 --- a/test/case/statd/system/operational.json +++ b/test/case/statd/system/operational.json @@ -9,7 +9,7 @@ "class": "infix-hardware:usb", "name": "USB", "state": { - "admin-state": "unlocked", + "admin-state": "locked", "oper-state": "enabled" } }, @@ -17,7 +17,7 @@ "class": "infix-hardware:usb", "name": "USB2", "state": { - "admin-state": "unlocked", + "admin-state": "locked", "oper-state": "enabled" } } diff --git a/test/case/statd/system/system/rootfs/sys/bus/usb/devices/usb1/authorized_default b/test/case/statd/system/system/rootfs/sys/bus/usb/devices/usb1/authorized_default new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/test/case/statd/system/system/rootfs/sys/bus/usb/devices/usb1/authorized_default @@ -0,0 +1 @@ +0 diff --git a/test/case/statd/system/system/rootfs/sys/bus/usb/devices/usb2/authorized_default b/test/case/statd/system/system/rootfs/sys/bus/usb/devices/usb2/authorized_default new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/test/case/statd/system/system/rootfs/sys/bus/usb/devices/usb2/authorized_default @@ -0,0 +1 @@ +0 From ded65cf94a47d0dbe0611d6d25ee941868608246 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Mon, 11 Aug 2025 11:09:06 +0200 Subject: [PATCH 6/7] .github: remove test-spec target Has to many dependencies such as asciidoctor-pdf. Signed-off-by: Richard Alpe --- .github/workflows/generic-x86-build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/generic-x86-build.yml b/.github/workflows/generic-x86-build.yml index ed573d38..7085eb4e 100644 --- a/.github/workflows/generic-x86-build.yml +++ b/.github/workflows/generic-x86-build.yml @@ -53,10 +53,6 @@ jobs: run: | make legal-info - - name: Build test spec - run: | - make test-spec - - name: Report Build Size run: | du -sh . From 8a1747db2ca6cd7e5827ed21e092872012d8641f Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Mon, 11 Aug 2025 16:10:06 +0200 Subject: [PATCH 7/7] .github: don't run generic build in kernelkit/infix Signed-off-by: Richard Alpe --- .github/workflows/generic-x86-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generic-x86-build.yml b/.github/workflows/generic-x86-build.yml index 7085eb4e..3272d52a 100644 --- a/.github/workflows/generic-x86-build.yml +++ b/.github/workflows/generic-x86-build.yml @@ -2,10 +2,10 @@ name: Generic X86 GitHub Build on: push: - pull_request: jobs: build: + if: github.repository != 'kernelkit/infix' name: Infix x86_64 runs-on: ubuntu-latest