Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
on: [pull_request]

jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.18.5

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
sudo apt install -y libpcap-dev
go get -v

- name: check code formatting
run: |
if [ -n "$(go fmt ./...)" ]; then
echo "Go code is not formatted, run 'go fmt github.com/google/stenographer/...'" >&2
exit 1
fi

- name: check linting
if: always()
run: |
go get golang.org/x/lint/golint
DIRS=". tcpassembly tcpassembly/tcpreader ip4defrag reassembly macs pcapgo pcap afpacket pfring routing defrag/lcmdefrag"
# Add subdirectories here as we clean up golint on each.
for subdir in $DIRS; do
pushd $subdir
if golint |
grep -v CannotSetRFMon | # pcap exported error name
grep -v DataLost | # tcpassembly/tcpreader exported error name
grep .; then
exit 1
fi
popd
done

pushd layers
for file in *.go; do
if cat .lint_blacklist | grep -q $file; then
echo "Skipping lint of $file due to .lint_blacklist"
elif golint $file | grep .; then
echo "Lint error in file $file"
exit 1
fi
done
popd

- name: vet go code
if: always()
run: |
DIRS=". layers pcap pcapgo tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff macs defrag/lcmdefrag"
set -e
for subdir in $DIRS; do
pushd $subdir
go vet
popd
done

- name: Test
if: always()
run: |
DIRS="afpacket layers pcap pcapgo tcpassembly tcpassembly/tcpreader reassembly routing ip4defrag bytediff macs routing defrag/lcmdefrag"
set -e
for subdir in $DIRS; do
pushd $subdir
sudo -E go test -v .
popd
done