github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/.github/workflows/ci.yml (about)

     1  name: ci
     2  on:
     3    push:
     4      branches: [ "main" ]
     5    pull_request:
     6      branches: [ "main" ]
     7  
     8  env:
     9    TMPDIR: /tmp
    10    CI_MAX_KERNEL_VERSION: '6.8'
    11    CI_MIN_CLANG_VERSION: '11'
    12    go_version: '~1.22'
    13    prev_go_version: '~1.21'
    14    CGO_ENABLED: '0'
    15    # This needs to match whatever Netlify supports.
    16    # Also defined in Pipfile.
    17    python_version: '~3.8'
    18  
    19  concurrency:
    20    group: ${{ github.workflow }}-${{ github.ref }}
    21    cancel-in-progress: ${{ github.event_name == 'pull_request' }}
    22  
    23  jobs:
    24    build-and-lint:
    25      name: Build and Lint
    26      runs-on: ubuntu-22.04
    27      timeout-minutes: 10
    28      steps:
    29        - uses: actions/checkout@v4
    30  
    31        - name: Set up Go
    32          uses: actions/setup-go@v5
    33          with:
    34            go-version: '${{ env.go_version }}'
    35  
    36        - name: Run golangci-lint
    37          uses: golangci/golangci-lint-action@v5.1.0
    38          with:
    39            args: "--out-format colored-line-number"
    40            skip-pkg-cache: true
    41  
    42        - name: Generate and format code
    43          run: |
    44            make clean && make container-all
    45            if ! git diff --exit-code; then
    46              echo "found unformatted source files, or generated files are not up to date, run 'make'" >&2
    47              exit 1
    48            fi
    49  
    50        - name: Test bpf2go
    51          run: |
    52            sudo apt-get install clang-11 llvm-11
    53            go test -v ./cmd/bpf2go
    54  
    55        - name: Build examples
    56          run: go build -v ./...
    57          working-directory: ./examples
    58  
    59        - name: Cross build darwin
    60          env:
    61            GOOS: darwin
    62          run: |
    63            go build -v ./...
    64            go test -c -o /dev/null ./... >/dev/null
    65  
    66        - name: Cross build arm32
    67          env:
    68            GOARCH: arm
    69            GOARM: 6
    70          run: |
    71            go build -v ./...
    72            go test -c -o /dev/null ./... >/dev/null
    73  
    74    build-docs:
    75      name: Build Documentation
    76      runs-on: ubuntu-22.04
    77      timeout-minutes: 10
    78      steps:
    79        - uses: actions/checkout@v4
    80          with:
    81            # The mkdocs git-authors plugin needs access to the full revision
    82            # history to correctly generate its statistics.
    83            fetch-depth: 0
    84  
    85        - name: Set up Go
    86          uses: actions/setup-go@v5
    87          with:
    88            go-version: '${{ env.go_version }}'
    89  
    90        - name: Set up Python
    91          uses: actions/setup-python@v5
    92          with:
    93            python-version: '${{ env.python_version }}'
    94            cache: 'pipenv'
    95  
    96        - name: Install pipenv
    97          run: pip3 install pipenv
    98  
    99        - name: Install Dependencies
   100          run: pipenv install
   101          working-directory: ./docs
   102  
   103        - name: Build Documentation
   104          run: make build
   105          working-directory: ./docs
   106  
   107    test-on-prev-go:
   108      name: Run tests on previous stable Go
   109      runs-on: ubuntu-latest-4cores-16gb
   110      needs: build-and-lint
   111      timeout-minutes: 15
   112      env:
   113        CI_KERNEL_SELFTESTS: '/usr/src/linux/tools/testing/selftests/bpf'
   114      steps:
   115        - uses: actions/checkout@v4
   116  
   117        - name: Set up Go
   118          uses: actions/setup-go@v5
   119          with:
   120            go-version: '${{ env.prev_go_version }}'
   121  
   122        - run: go install lmb.io/vimto@latest
   123        - run: go install gotest.tools/gotestsum@v1.8.1
   124        - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86
   125        - run: sudo chmod 0666 /dev/kvm
   126  
   127        - name: Test
   128          env:
   129            GOTRACEBACK: crash
   130          run: |
   131            gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :${CI_MAX_KERNEL_VERSION}-selftests -- go test -timeout 5m -short -count 1 -json ./...
   132  
   133        - name: Benchmark
   134          run: vimto -kernel :${CI_MAX_KERNEL_VERSION}-selftests -- go test -short -run '^$' -bench . -benchtime=1x ./...
   135  
   136        - name: Upload coredumps
   137          uses: actions/upload-artifact@v4
   138          if: ${{ failure() }}
   139          with:
   140            name: cores
   141            if-no-files-found: ignore
   142            path: |
   143              **/core-*
   144              **/*.test
   145  
   146        - name: Upload Test Results
   147          if: always()
   148          uses: actions/upload-artifact@v4
   149          with:
   150            name: Test Results (previous stable Go)
   151            path: junit.xml
   152  
   153    test-on-arm64:
   154      name: Run tests on arm64
   155      runs-on: actuated-arm64-2cpu-8gb
   156      needs: build-and-lint
   157      timeout-minutes: 15
   158      env:
   159        EBPF_TEST_IGNORE_KERNEL_VERSION: 'TestKprobeMulti,TestKprobeMultiErrors,TestKprobeMultiCookie,TestKprobeMultiProgramCall,TestHaveBPFLinkKprobeMulti'
   160      steps:
   161        - uses: actions/checkout@v4
   162  
   163        - name: Set up Go
   164          uses: actions/setup-go@v5
   165          with:
   166            go-version: '${{ env.go_version }}'
   167  
   168        - run: go install gotest.tools/gotestsum@v1.8.1
   169  
   170        - name: Test
   171          run: gotestsum --ignore-non-json-output-lines --junitfile junit.xml -- -exec 'sudo -E' -short -count 1 -json ./...
   172  
   173        - name: Benchmark
   174          run: go test -exec sudo -short -run '^$' -bench . -benchtime=1x ./...
   175  
   176        - name: Upload Test Results
   177          if: always()
   178          uses: actions/upload-artifact@v4
   179          with:
   180            name: Test Results (arm64)
   181            path: junit.xml
   182  
   183        - name: Show dmesg
   184          if: failure()
   185          run: |
   186            sudo dmesg
   187  
   188    vm-test:
   189      name: Run tests
   190      runs-on: ubuntu-latest-4cores-16gb
   191      needs: build-and-lint
   192      timeout-minutes: 15
   193      strategy:
   194        matrix:
   195          tag:
   196            - "mainline"
   197            - "stable"
   198            - "6.6"
   199            - "6.1"
   200            - "5.15"
   201            - "5.10"
   202            - "5.4"
   203            - "4.19"
   204            - "4.14"
   205            - "4.9"
   206      steps:
   207        - uses: actions/checkout@v4
   208  
   209        - name: Set up Go
   210          uses: actions/setup-go@v5
   211          with:
   212            go-version: '${{ env.go_version }}'
   213  
   214        - run: go install gotest.tools/gotestsum@v1.8.1
   215        - run: go install lmb.io/vimto@latest
   216        - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86
   217        - run: sudo chmod 0666 /dev/kvm
   218  
   219        - name: Test
   220          run: gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :${{ matrix.tag }} -- go test -short -count 1 -json ./...
   221  
   222        - name: Upload Test Results
   223          if: always()
   224          uses: actions/upload-artifact@v4
   225          with:
   226            name: Test Results (${{ matrix.tag }})
   227            path: junit.xml