Skip to content

Commit

Permalink
ci: add actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg committed Apr 26, 2024
1 parent 8d9b458 commit e243343
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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: make test

12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +43,13 @@ $(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: test
test:
CGO_CFLAGS=$(CGO_CFLAGS_STATIC) \
CGO_LDFLAGS=$(CGO_LDFLAGS_STATIC) \
CGO_ENABLED=1 go test -v ./...

.PHONY: generate
generate:
Expand Down

0 comments on commit e243343

Please sign in to comment.