From 52e214f6132b2cc85596681ddc17ec3366e2735f Mon Sep 17 00:00:00 2001 From: mozillazg Date: Fri, 26 Apr 2024 21:49:52 +0800 Subject: [PATCH] ci: add actions --- .github/dependabot.yml | 12 ++++++++++++ .github/workflows/test.yml | 34 ++++++++++++++++++++++++++++++++++ Makefile | 6 +++--- 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..6a3f63bc --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + open-pull-requests-limit: 10 + schedule: + interval: monthly + - package-ecosystem: github-actions + directory: / + open-pull-requests-limit: 5 + schedule: + interval: monthly diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..d0c8f786 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: Test + +on: + workflow_dispatch: + push: + branches: [ "master", "dev" ] + pull_request: + branches: [ "master", "dev" ] + +permissions: + contents: read + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + + - name: Set up deps + run: | + sudo apt-get install -y gcc flex bison make libelf-dev + + - name: Build + run: make build + + - name: Test + run: go test -v ./... + diff --git a/Makefile b/Makefile index ba943776..97f35ab9 100644 --- a/Makefile +++ b/Makefile @@ -20,13 +20,13 @@ CGO_LDFLAGS_STATIC = "-L$(LIBPCAP_OBJ_DIR) -lelf -lz $(LIBPCAP_OBJ)" .PHONY: libpcap libpcap: $(LIBPCAP_OBJ) -$(LIBPCAP_OBJ): $(LIBPCAP_SRC) $(wildcard $(LIBPCAP_SRC)/*.[ch]) | $(LIBPCAP_DIST_DIR) +$(LIBPCAP_OBJ): $(LIBPCAP_SRC)/configure $(wildcard $(LIBPCAP_SRC)/*.[ch]) | $(LIBPCAP_DIST_DIR) cd $(LIBPCAP_SRC) && \ ./configure --enable-dbus=no && \ $(MAKE) && \ $(MAKE) install prefix=$(LIBPCAP_DIST_DIR) -$(LIBPCAP_SRC): +$(LIBPCAP_SRC)/configure: ifeq ($(wildcard $@), ) echo "INFO: updating submodule 'libpcap'" $(GIT) submodule update --init --recursive @@ -43,7 +43,7 @@ $(OUTPUT): build: generate libpcap CGO_CFLAGS=$(CGO_CFLAGS_STATIC) \ CGO_LDFLAGS=$(CGO_LDFLAGS_STATIC) \ - CGO_ENABLED=1 go build -tags static -ldflags '-extldflags "-static"' + CGO_ENABLED=1 go build -tags=static -ldflags '-extldflags "-static"' .PHONY: generate generate: