test.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.27'
  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 boringcrypto
  54. test-cmd: make boringcrypto test
  55. e2e-cmd: make boringcrypto e2evv
  56. - name: linux-fips140
  57. os: ubuntu-latest
  58. build-cmd: make fips140-all
  59. test-cmd: make fips140-all GOALS=test
  60. e2e-cmd: make fips140-all GOALS=e2evv
  61. - name: linux-pkcs11
  62. os: ubuntu-latest
  63. build-cmd: make bin-pkcs11
  64. test-cmd: make test-pkcs11
  65. e2e-cmd: ''
  66. - name: macos
  67. os: macos-latest
  68. build-cmd: go build ./cmd/nebula ./cmd/nebula-cert
  69. test-cmd: make test
  70. e2e-cmd: make e2evv
  71. - name: windows
  72. os: windows-latest
  73. build-cmd: go build ./cmd/nebula ./cmd/nebula-cert
  74. test-cmd: make test
  75. e2e-cmd: make e2evv
  76. steps:
  77. - uses: actions/checkout@v7
  78. - uses: actions/setup-go@v7
  79. with:
  80. go-version: '1.27'
  81. check-latest: true
  82. - name: Build
  83. run: ${{ matrix.build-cmd }}
  84. - name: Cross-build darwin-amd64
  85. if: matrix.name == 'macos'
  86. run: GOARCH=amd64 go build -o /tmp/nebula-amd64 ./cmd/nebula && GOARCH=amd64 go build -o /tmp/nebula-cert-amd64 ./cmd/nebula-cert
  87. - name: Test
  88. run: ${{ matrix.test-cmd }}
  89. - name: End 2 end
  90. if: matrix.e2e-cmd != ''
  91. run: ${{ matrix.e2e-cmd }}
  92. - uses: actions/upload-artifact@v7
  93. if: matrix.e2e-cmd != '' && always()
  94. with:
  95. name: e2e packet flow ${{ matrix.name }}
  96. path: e2e/mermaid/
  97. if-no-files-found: warn
  98. cross-build:
  99. name: Cross-build ${{ matrix.name }}
  100. runs-on: ubuntu-latest
  101. strategy:
  102. fail-fast: false
  103. matrix:
  104. include:
  105. - {name: linux-arm, make-target: all-cross-linux-arm}
  106. - {name: linux-mips, make-target: all-cross-linux-mips}
  107. - {name: linux-other, make-target: all-cross-linux-other}
  108. - {name: freebsd, make-target: all-freebsd}
  109. - {name: openbsd, make-target: all-openbsd}
  110. - {name: netbsd, make-target: all-netbsd}
  111. - {name: windows, make-target: all-cross-windows}
  112. - {name: mobile, make-target: build-test-mobile}
  113. steps:
  114. - uses: actions/checkout@v7
  115. - uses: actions/setup-go@v7
  116. with:
  117. go-version: '1.27'
  118. check-latest: true
  119. - name: Build ${{ matrix.name }}
  120. run: make -j"$(nproc)" ${{ matrix.make-target }}
  121. finish:
  122. name: CI status
  123. if: always()
  124. needs: [static, test, cross-build]
  125. runs-on: ubuntu-latest
  126. steps:
  127. - name: Fail if any upstream job failed
  128. if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
  129. run: |
  130. echo "upstream results: ${{ toJSON(needs) }}"
  131. exit 1
  132. - name: All upstream jobs passed
  133. run: echo "ok"