Skip to content

Commit fd90884

Browse files
authored
remove binaries, add makefile, add github actions (#2)
* Delete generated binaries from source control * Add makefile * Add GithubActions files * Build x86_64 and aarch64 * Add release.yaml
1 parent f416238 commit fd90884

File tree

7 files changed

+160
-68
lines changed

7 files changed

+160
-68
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Pull Request Validation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
validate:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v4
18+
with:
19+
go-version-file: go.mod
20+
21+
- name: Validate go fmt
22+
run: |
23+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
24+
echo "The following files are not properly formatted:"
25+
gofmt -s -l .
26+
echo "Please run 'go fmt ./...' to fix formatting issues."
27+
exit 1
28+
fi
29+
30+
- name: Validate go mod tidy
31+
run: |
32+
go mod tidy
33+
if ! git diff --exit-code go.mod go.sum; then
34+
echo "go.mod or go.sum files are not up to date"
35+
echo "Please run 'go mod tidy' and commit the changes"
36+
exit 1
37+
fi
38+
39+
build:
40+
runs-on: ${{ matrix.runner }}
41+
strategy:
42+
matrix:
43+
include:
44+
- arch: x86_64
45+
runner: ubuntu-22.04
46+
# - arch: aarch64
47+
# runner: ARM64-CMX
48+
49+
steps:
50+
- name: Checkout code
51+
uses: actions/checkout@v4
52+
53+
- name: Set up Go
54+
uses: actions/setup-go@v4
55+
with:
56+
go-version-file: go.mod
57+
58+
- name: Install dependencies
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install -y clang llvm libbpf-dev
62+
63+
- name: Run make generate
64+
run: make generate
65+
66+
- name: Run make build
67+
run: make build
68+
69+
- name: Verify build artifact
70+
run: |
71+
if [ ! -f pktstat-bpf ]; then
72+
echo "Build artifact 'pktstat-bpf' not found"
73+
exit 1
74+
fi
75+
echo "Build successful - artifact created for ${{ matrix.arch }}"

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build-x86_64:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- uses: actions/checkout@v4
13+
- run: git config --global --add safe.directory $(pwd) # Workaround for fatal: detected dubious ownership in repository at '/__w/reliability-matrix/reliability-matrix'
14+
- name: Set up Go
15+
uses: actions/setup-go@v4
16+
with:
17+
go-version-file: go.mod
18+
- run: make generate build VERSION=${{ github.ref_name }}
19+
- run: mv ./pktstat-bpf ./pktstat-bpf-x86_64
20+
- name: Upload x86_64 binary
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: pktstat-bpf-x86_64
24+
path: ./pktstat-bpf-x86_64
25+
26+
build-aarch64:
27+
runs-on: ARM64-CMX
28+
steps:
29+
- uses: actions/checkout@v4
30+
- run: git config --global --add safe.directory $(pwd) # Workaround for fatal: detected dubious ownership in repository at '/__w/reliability-matrix/reliability-matrix'
31+
- name: Set up Go
32+
uses: actions/setup-go@v4
33+
with:
34+
go-version-file: go.mod
35+
- run: make generate build VERSION=${{ github.ref_name }}
36+
- run: mv ./pktstat-bpf ./pktstat-bpf-aarch64
37+
- name: Upload aarch64 binary
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: pktstat-bpf-aarch64
41+
path: ./pktstat-bpf-aarch64
42+
43+
create-release:
44+
runs-on: ubuntu-22.04
45+
needs:
46+
- build-x86_64
47+
- build-aarch64
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Download x86_64 binary
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: pktstat-bpf-x86_64
54+
path: ./bin
55+
- name: Download aarch64 binary
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: pktstat-bpf-aarch64
59+
path: ./bin
60+
- name: Create GitHub Release
61+
run: gh release create ${{ github.ref_name }} ./bin/pktstat-bpf-x86_64 ./bin/pktstat-bpf-aarch64 --generate-notes
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.exe~
55
*.dll
66
*.so
7+
*.o
78
*.dylib
89
pktstat-bpf
910
dist/

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Variables
2+
TARGET := pktstat-bpf
3+
GIT_LAST_TAG := $(shell git describe --abbrev=0 --tags 2>/dev/null || echo latest)
4+
GIT_HEAD_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
5+
GIT_TAG_COMMIT := $(shell git rev-parse --short $(GIT_LAST_TAG) 2>/dev/null || echo unknown)
6+
GIT_MODIFIED1 := $(shell git diff $(GIT_HEAD_COMMIT) $(GIT_TAG_COMMIT) --quiet 2>/dev/null || echo .dev)
7+
GIT_MODIFIED2 := $(shell git diff --quiet 2>/dev/null || echo .dirty)
8+
GIT_MODIFIED := $(GIT_MODIFIED1)$(GIT_MODIFIED2)
9+
BUILD_DATE := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
10+
11+
# Environment variables
12+
export CGO_ENABLED := 0
13+
14+
# Targets
15+
.PHONY: generate build
16+
17+
generate:
18+
go generate
19+
20+
build:
21+
go build -trimpath -pgo=auto -ldflags="-s -w -X main.GitTag=$(GIT_LAST_TAG) -X main.GitCommit=$(GIT_HEAD_COMMIT) -X main.GitDirty=$(GIT_MODIFIED) -X main.BuildTime=$(BUILD_DATE)" -o $(TARGET)

Taskfile.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

counter_arm64_bpfel.o

-75 KB
Binary file not shown.

counter_x86_bpfel.o

-74.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)