From 15439d7da0fbfe1c3c40c4195f68a433cb62f253 Mon Sep 17 00:00:00 2001
From: Andrii Nakryiko <andrii@kernel.org>
Date: Tue, 19 Nov 2024 11:46:37 -0800
Subject: [PATCH] ci: minimal CI testing setup

Add static and shared build and runtime testing.
---
 .github/workflows/test.yml | 30 ++++++++++++++++++++++++++++++
 tests/Makefile             |  7 ++++---
 2 files changed, 34 insertions(+), 3 deletions(-)
 create mode 100644 .github/workflows/test.yml

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..333c208
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,30 @@
+name: USDT CI
+
+on:
+  push:
+    branches: [ "main" ]
+  pull_request:
+    branches: [ "main" ]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v4
+
+    - name: Install prerequisites
+      run: apt-get install -y bpftrace sudo
+
+    - name: Build (static)
+      run: make SHARED=0 -C tests -j$(nproc) build
+
+    - name: Build (shared)
+      run: make SHARED=1 -C tests -j$(nproc) build
+
+    - name: Test (static)
+      run: make SHARED=0 -C tests test
+
+    - name: Test (shared)
+      run: make SHARED=1 -C tests test
diff --git a/tests/Makefile b/tests/Makefile
index 4d27eef..b971d3c 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -34,13 +34,13 @@ endif
 NONTESTS = tester common
 
 TESTS := $(filter-out $(NONTESTS), 								\
-		$(shell ls *.{c,cpp} 2>/dev/null | grep -v '^lib' | 				\
-			${AWK} '{split($$0, p, /[^A-Za-z_]+/); print p[1]}' | 			\
+		$(shell ls *.c *.cpp 2>/dev/null | grep -v '^lib' | 				\
+			${AWK} '{split($$0, p, /[^A-Za-z_]+/); print p[1]}' |			\
 			sort | uniq 								\
 		)										\
 )
 LIBS := $(filter-out $(NONTESTS), 								\
-		$(shell ls lib*.{c,cpp} 2>/dev/null | 						\
+		$(shell ls lib*.c lib*.cpp 2>/dev/null | 					\
 			${AWK} '{split($$0, p, /[^A-Za-z_]+/); print substr(p[1], 4)}' |	\
 			sort | uniq 								\
 		)										\
@@ -59,6 +59,7 @@ clean:
 
 .PHONY: list
 list:
+	$(call msg,TESTS,$@)
 	$(Q)$(foreach test,$(TESTS), $(info $(test)))
 
 .PHONY: build