github.com/gopacket/gopacket@v1.1.0/.github/workflows/push_pr.yaml (about)

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