Skip to content

Commit aadc00a

Browse files
authored
Github Actions (#3)
1 parent 32ee382 commit aadc00a

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

.github/workflows/pr.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
on: [pull_request]
2+
3+
jobs:
4+
build:
5+
name: Build
6+
runs-on: ubuntu-22.04
7+
steps:
8+
9+
- name: Set up Go 1.x
10+
uses: actions/setup-go@v3
11+
with:
12+
go-version: ^1.18.5
13+
14+
- name: Check out code into the Go module directory
15+
uses: actions/checkout@v2
16+
17+
- name: Get dependencies
18+
run: |
19+
sudo apt install -y libpcap-dev
20+
go get -v
21+
22+
- name: check code formatting
23+
run: |
24+
if [ -n "$(go fmt ./...)" ]; then
25+
echo "Go code is not formatted, run 'go fmt github.com/google/stenographer/...'" >&2
26+
exit 1
27+
fi
28+
29+
- name: check linting
30+
if: always()
31+
run: |
32+
go get golang.org/x/lint/golint
33+
DIRS=". tcpassembly tcpassembly/tcpreader ip4defrag reassembly macs pcapgo pcap afpacket pfring routing defrag/lcmdefrag"
34+
# Add subdirectories here as we clean up golint on each.
35+
for subdir in $DIRS; do
36+
pushd $subdir
37+
if golint |
38+
grep -v CannotSetRFMon | # pcap exported error name
39+
grep -v DataLost | # tcpassembly/tcpreader exported error name
40+
grep .; then
41+
exit 1
42+
fi
43+
popd
44+
done
45+
46+
pushd layers
47+
for file in *.go; do
48+
if cat .lint_blacklist | grep -q $file; then
49+
echo "Skipping lint of $file due to .lint_blacklist"
50+
elif golint $file | grep .; then
51+
echo "Lint error in file $file"
52+
exit 1
53+
fi
54+
done
55+
popd
56+
57+
- name: vet go code
58+
if: always()
59+
run: |
60+
DIRS=". layers pcap pcapgo tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff macs defrag/lcmdefrag"
61+
set -e
62+
for subdir in $DIRS; do
63+
pushd $subdir
64+
go vet
65+
popd
66+
done
67+
68+
- name: Test
69+
if: always()
70+
run: |
71+
DIRS="afpacket layers pcap pcapgo tcpassembly tcpassembly/tcpreader reassembly routing ip4defrag bytediff macs routing defrag/lcmdefrag"
72+
set -e
73+
for subdir in $DIRS; do
74+
pushd $subdir
75+
sudo -E go test -v .
76+
popd
77+
done

0 commit comments

Comments
 (0)