test.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. name: Build and test
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request:
  7. paths:
  8. - '.github/workflows/test.yml'
  9. - '**Makefile'
  10. - '**.go'
  11. - '**.proto'
  12. - 'go.mod'
  13. - 'go.sum'
  14. jobs:
  15. static:
  16. name: Static checks
  17. runs-on: ubuntu-latest
  18. steps:
  19. - uses: actions/checkout@v7
  20. - uses: actions/setup-go@v7
  21. with:
  22. go-version: '1.26'
  23. check-latest: true
  24. - name: Install goimports
  25. run: go install golang.org/x/tools/cmd/goimports@latest
  26. - name: gofmt
  27. run: |
  28. if [ "$(find . -iname '*.go' | grep -v '\.pb\.go$' | xargs goimports -l)" ]
  29. then
  30. find . -iname '*.go' | grep -v '\.pb\.go$' | xargs goimports -d
  31. exit 1
  32. fi
  33. - name: Vet
  34. run: make vet
  35. - name: golangci-lint
  36. uses: golangci/golangci-lint-action@v9
  37. with:
  38. version: v2.12
  39. test:
  40. name: Test ${{ matrix.name }}
  41. runs-on: ${{ matrix.os }}
  42. strategy:
  43. fail-fast: false
  44. matrix:
  45. include:
  46. - name: linux
  47. os: ubuntu-latest
  48. build-cmd: go build ./cmd/nebula ./cmd/nebula-cert
  49. test-cmd: make test
  50. e2e-cmd: make e2evv
  51. - name: linux-boringcrypto
  52. os: ubuntu-latest
  53. build-cmd: make bin-boringcrypto
  54. test-cmd: make test-boringcrypto
  55. e2e-cmd: make e2e GOEXPERIMENT=boringcrypto CGO_ENABLED=1 TEST_ENV="TEST_LOGS=1" TEST_FLAGS="-v -ldflags -checklinkname=0"
  56. - name: linux-pkcs11
  57. os: ubuntu-latest
  58. build-cmd: make bin-pkcs11
  59. test-cmd: make test-pkcs11
  60. e2e-cmd: ''
  61. - name: macos
  62. os: macos-latest
  63. build-cmd: go build ./cmd/nebula ./cmd/nebula-cert
  64. test-cmd: make test
  65. e2e-cmd: make e2evv
  66. - name: windows
  67. os: windows-latest
  68. build-cmd: go build ./cmd/nebula ./cmd/nebula-cert
  69. test-cmd: make test
  70. e2e-cmd: make e2evv
  71. steps:
  72. - uses: actions/checkout@v7
  73. - uses: actions/setup-go@v7
  74. with:
  75. go-version: '1.26'
  76. check-latest: true
  77. - name: Build
  78. run: ${{ matrix.build-cmd }}
  79. - name: Cross-build darwin-amd64
  80. if: matrix.name == 'macos'
  81. run: GOARCH=amd64 go build -o /tmp/nebula-amd64 ./cmd/nebula && GOARCH=amd64 go build -o /tmp/nebula-cert-amd64 ./cmd/nebula-cert
  82. - name: Test
  83. run: ${{ matrix.test-cmd }}
  84. - name: End 2 end
  85. if: matrix.e2e-cmd != ''
  86. run: ${{ matrix.e2e-cmd }}
  87. - uses: actions/upload-artifact@v7
  88. if: matrix.e2e-cmd != '' && always()
  89. with:
  90. name: e2e packet flow ${{ matrix.name }}
  91. path: e2e/mermaid/
  92. if-no-files-found: warn
  93. cross-build:
  94. name: Cross-build ${{ matrix.name }}
  95. runs-on: ubuntu-latest
  96. strategy:
  97. fail-fast: false
  98. matrix:
  99. include:
  100. - {name: linux-arm, make-target: all-cross-linux-arm}
  101. - {name: linux-mips, make-target: all-cross-linux-mips}
  102. - {name: linux-other, make-target: all-cross-linux-other}
  103. - {name: freebsd, make-target: all-freebsd}
  104. - {name: openbsd, make-target: all-openbsd}
  105. - {name: netbsd, make-target: all-netbsd}
  106. - {name: windows, make-target: all-cross-windows}
  107. - {name: mobile, make-target: build-test-mobile}
  108. steps:
  109. - uses: actions/checkout@v7
  110. - uses: actions/setup-go@v7
  111. with:
  112. go-version: '1.26'
  113. check-latest: true
  114. - name: Build ${{ matrix.name }}
  115. run: make -j"$(nproc)" ${{ matrix.make-target }}
  116. finish:
  117. name: CI status
  118. if: always()
  119. needs: [static, test, cross-build]
  120. runs-on: ubuntu-latest
  121. steps:
  122. - name: Fail if any upstream job failed
  123. if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
  124. run: |
  125. echo "upstream results: ${{ toJSON(needs) }}"
  126. exit 1
  127. - name: All upstream jobs passed
  128. run: echo "ok"