Repository: Andreagit97/bpfvalidator
Pull request #4: new(github,ci): add a composite action.
Author: login: FedeDP
Created: 2025-05-15T16:05:04Z | Merged: 2025-05-15T18:00:45Z

Also, add a composite action CI test.

Fixes #3 

Linked issue #3: Add a github reusable workflow to wrap the tool
As per title, we in Falco would be interested in something like this to complement our [kernel-testing](https://github.com/falcosecurity/kernel-testing) eg to test multiple vanilla kernels. Something like either a composite action (eg: the one we provide with kernel-testing: https://github.com/falcosecurity/kernel-testing/blob/main/action.yml) or a reusable_workflow would be great to allow us to quickly test this.

I can quickly come up with this if you want :) 

Diff:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..a359380
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,23 @@
+name: Test composite action
+on:
+  pull_request:
+    paths:
+      - 'action.yml'
+  workflow_dispatch:    
+
+jobs:
+  test-composite-action:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+    
+      - name: Test action
+        uses: ./
+        id: test
+        with:
+          cmd: "/usr/bin/echo 'hey'"
+          kernels: "v5.4.293,v5.10.237,v5.15.182"
+
+      - name: Show report
+        run: cat ${{ steps.test.outputs.report }}
diff --git a/action.yml b/action.yml
new file mode 100644
index 0000000..78ac99e
--- /dev/null
+++ b/action.yml
@@ -0,0 +1,63 @@
+name: 'bpfvalidator'
+description: 'Run eBPF programs against range of vanilla kernels.'
+
+inputs:
+  cmd:
+    description: 'command to run in qemu machines'
+    required: true
+  kernels:
+    description: 'comma-separated list of kernels to be tested'
+    required: true
+
+outputs:
+  report:
+    description: "Report of the run"
+    value: ${{ steps.store-outputs.outputs.report }}
+
+runs:
+  using: "composite"
+  steps:
+    - name: Install vng
+      shell: bash
+      run: |
+        sudo apt update -y
+        sudo apt install -y git qemu-kvm kmod virtiofsd udev virtme-ng
+
+    - name: enable KVM support
+      if: matrix.arch == 'amd64'
+      shell: bash
+      run: |
+        echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
+        sudo udevadm control --reload-rules
+        sudo udevadm trigger --name-match=kvm
+
+    - name: Setup Go
+      uses: actions/setup-go@v5
+      with:
+        go-version-file: "${{ github.action_path }}/go.mod"
+
+    - name: Build bpfvalidator
+      shell: bash
+      working-directory: ${{ github.action_path }}
+      run: go build .
+     
+    - name: Generate bpfvalidator config
+      shell: bash
+      working-directory: ${{ github.action_path }}
+      run: |
+        echo "vng_path: \"vng\"" > conf.yaml
+        echo "bin_command: \"${{ inputs.cmd }}\"" >> conf.yaml
+        echo "parallel: 1" >> conf.yaml
+        echo "out_path: /tmp/report.yaml" >> conf.yaml
+        echo "kernel_versions: [${{ inputs.kernels }}]" >> conf.yaml
+      
+    - name: Run bpfvalidator
+      shell: bash
+      working-directory: ${{ github.action_path }}
+      run:
+        ./bpfvalidator --config conf.yaml
+
+    - name: Set output
+      id: store-outputs
+      shell: bash
+      run: echo "report=/tmp/report.yaml" >> $GITHUB_OUTPUT


Reviews:
user: login: FedeDP
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-15T16:06:06Z
user: login: FedeDP
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-15T16:06:34Z
user: login: FedeDP
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-15T16:08:51Z

Review comments:
diff_hunk: @@ -0,0 +1,23 @@
+name: Test composite action
+on:
+  pull_request:
+    paths:
+      - 'action.yml'
+  workflow_dispatch:    
+
+jobs:
+  test-composite-action:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+    
+      - name: Test action
+        uses: ./
path: .github/workflows/test.yml
user: login: FedeDP
body: Use the action provided by the repo.
created_at: 2025-05-15T16:06:06Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,63 @@
+name: 'bpfvalidator'
+description: 'Run eBPF programs against range of vanilla kernels.'
+
+inputs:
path: action.yml
user: login: FedeDP
body: I skipped `parallel` input
created_at: 2025-05-15T16:06:34Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,63 @@
+name: 'bpfvalidator'
+description: 'Run eBPF programs against range of vanilla kernels.'
+
+inputs:
+  cmd:
+    description: 'command to run in qemu machines'
+    required: true
+  kernels:
+    description: 'comma-separated list of kernels to be tested'
+    required: true
+
+outputs:
+  report:
+    description: "Report of the run"
+    value: ${{ steps.store-outputs.outputs.report }}
+
+runs:
+  using: "composite"
+  steps:
+    - name: Install vng
+      shell: bash
+      run: |
+        sudo apt update -y
+        sudo apt install -y git qemu-kvm kmod virtiofsd udev virtme-ng
+
+    - name: enable KVM support
+      if: matrix.arch == 'amd64'
+      shell: bash
+      run: |
+        echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
+        sudo udevadm control --reload-rules
+        sudo udevadm trigger --name-match=kvm
+
+    - name: Setup Go
+      uses: actions/setup-go@v5
+      with:
+        go-version-file: "${{ github.action_path }}/go.mod"
+
+    - name: Build bpfvalidator
+      shell: bash
+      working-directory: ${{ github.action_path }}
+      run: go build .
+     
+    - name: Generate bpfvalidator config
+      shell: bash
+      working-directory: ${{ github.action_path }}
+      run: |
+        echo "vng_path: \"vng\"" > conf.yaml
path: action.yml
user: login: FedeDP
body: We installed it system-wide.
created_at: 2025-05-15T16:08:51Z
author_association: CONTRIBUTOR

PR comments:
user: login: FedeDP
created_at: 2025-05-15T16:05:39Z
body: The composite action CI test won't run since i am not a maintainer of the repo :) 
author_association: CONTRIBUTOR
user: login: Andreagit97
created_at: 2025-05-15T17:57:46Z
body: Thank you very much, man! I've just changed the output path since the test was failing, let's see :crossed_fingers: 
author_association: OWNER
user: login: FedeDP
created_at: 2025-05-15T17:58:28Z
body: Good old times man
author_association: CONTRIBUTOR
user: login: Andreagit97
created_at: 2025-05-15T18:00:37Z
body: 
```
Report:
- v5.4.293 🟢
- v5.10.237 🟢
- v5.15.182 🟢
```
author_association: OWNER