tests.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. name: CI
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - master
  7. - staging-client
  8. - staging-server
  9. jobs:
  10. run_tests:
  11. strategy:
  12. fail-fast: false
  13. matrix:
  14. os: [ "ubuntu" ]
  15. go: [ "1.24.12" ]
  16. test-type: [ "detector", "coverage", "protobuf", "memory", "custom-build-tags", "code-vetting", "dependency-check" ]
  17. runs-on: ${{ matrix.os }}-latest
  18. name: psiphon-tunnel-core ${{ matrix.test-type }} tests on ${{ matrix.os}}, Go ${{ matrix.go }}
  19. permissions:
  20. checks: write
  21. contents: read
  22. env:
  23. GOPATH: ${{ github.workspace }}/go
  24. steps:
  25. - name: Clone repository
  26. uses: actions/checkout@v4
  27. with:
  28. path: ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  29. - name: Install Go
  30. uses: actions/setup-go@v4
  31. with:
  32. go-version: ${{ matrix.go }}
  33. - name: Install networking components
  34. run: |
  35. sudo apt-get update
  36. sudo apt-get install libnetfilter-queue-dev
  37. sudo apt-get install conntrack
  38. - name: Install coverage tools
  39. if: ${{ matrix.test-type == 'coverage' }}
  40. run: |
  41. go install github.com/axw/gocov/gocov@latest
  42. go install github.com/modocache/gover@latest
  43. go install github.com/mattn/goveralls@latest
  44. go install golang.org/x/tools/cmd/cover@latest
  45. - name: Check environment
  46. run: |
  47. echo "GitHub workspace: $GITHUB_WORKSPACE"
  48. echo "Working directory: `pwd`"
  49. echo "GOROOT: $GOROOT"
  50. echo "GOPATH: $GOPATH"
  51. echo "Go version: `go version`"
  52. - name: Pave config files
  53. env:
  54. CONTROLLER_TEST_CONFIG: ${{ secrets.CONTROLLER_TEST_CONFIG }}
  55. run: |
  56. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  57. echo "$CONTROLLER_TEST_CONFIG" > ./psiphon/controller_test.config
  58. # TODO: fix and re-enable test
  59. # sudo -E env "PATH=$PATH" go test -v -race ./psiphon/common/tun
  60. - name: Run tests with data race detector
  61. if: ${{ matrix.test-type == 'detector' }}
  62. run: |
  63. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  64. go test -v -race ./psiphon/common
  65. go test -v -race ./psiphon/common/accesscontrol
  66. go test -v -race ./psiphon/common/crypto/ssh
  67. go test -v -race ./psiphon/common/dsl
  68. go test -v -race ./psiphon/common/fragmentor
  69. go test -v -race -tags "PSIPHON_ENABLE_INPROXY" ./psiphon/common/inproxy
  70. go test -v -race ./psiphon/common/regen
  71. go test -v -race ./psiphon/common/monotime
  72. go test -v -race ./psiphon/common/obfuscator
  73. go test -v -race ./psiphon/common/osl
  74. sudo -E env "PATH=$PATH" go test -v -race -tags "PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/common/packetman
  75. go test -v -race ./psiphon/common/parameters
  76. go test -v -race ./psiphon/common/protocol
  77. go test -v -race ./psiphon/common/quic
  78. go test -v -race ./psiphon/common/resolver
  79. go test -v -race ./psiphon/common/tactics
  80. go test -v -race ./psiphon/common/transforms
  81. go test -v -race ./psiphon/common/values
  82. go test -v -race ./psiphon/common/wildcard
  83. go test -v -race ./psiphon/transferstats
  84. sudo -E env "PATH=$PATH" go test -v -timeout 30m -race -tags "PSIPHON_ENABLE_INPROXY PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/server
  85. go test -v -race ./psiphon/server/psinet
  86. go test -v -timeout 30m -race ./psiphon
  87. go test -v -race ./ClientLibrary/clientlib
  88. go test -v -race ./Server/logging/analysis
  89. go test -v -race ./psiphon/common/networkid
  90. # TODO: fix and re-enable test
  91. # sudo -E env "PATH=$PATH" go test -v -covermode=count -coverprofile=tun.coverprofile ./psiphon/common/tun
  92. - name: Run tests with coverage
  93. env:
  94. COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  95. if: ${{ matrix.test-type == 'coverage' && github.repository == 'Psiphon-Labs/psiphon-tunnel-core' }}
  96. run: |
  97. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  98. go test -v -covermode=count -coverprofile=common.coverprofile ./psiphon/common
  99. go test -v -covermode=count -coverprofile=accesscontrol.coverprofile ./psiphon/common/accesscontrol
  100. go test -v -covermode=count -coverprofile=ssh.coverprofile ./psiphon/common/crypto/ssh
  101. go test -v -covermode=count -coverprofile=fragmentor.coverprofile ./psiphon/common/fragmentor
  102. go test -v -covermode=count -coverprofile=dsl.coverprofile ./psiphon/common/dsl
  103. go test -v -covermode=count -tags "PSIPHON_ENABLE_INPROXY" -coverprofile=inproxy.coverprofile ./psiphon/common/inproxy
  104. go test -v -covermode=count -coverprofile=regen.coverprofile ./psiphon/common/regen
  105. go test -v -covermode=count -coverprofile=monotime.coverprofile ./psiphon/common/monotime
  106. go test -v -covermode=count -coverprofile=obfuscator.coverprofile ./psiphon/common/obfuscator
  107. go test -v -covermode=count -coverprofile=osl.coverprofile ./psiphon/common/osl
  108. sudo -E env "PATH=$PATH" go test -v -covermode=count -coverprofile=packetman.coverprofile -tags "PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/common/packetman
  109. go test -v -covermode=count -coverprofile=parameters.coverprofile ./psiphon/common/parameters
  110. go test -v -covermode=count -coverprofile=protocol.coverprofile ./psiphon/common/protocol
  111. go test -v -covermode=count -coverprofile=quic.coverprofile ./psiphon/common/quic
  112. go test -v -covermode=count -coverprofile=resolver.coverprofile ./psiphon/common/resolver
  113. go test -v -covermode=count -coverprofile=tactics.coverprofile ./psiphon/common/tactics
  114. go test -v -covermode=count -coverprofile=transforms.coverprofile ./psiphon/common/transforms
  115. go test -v -covermode=count -coverprofile=values.coverprofile ./psiphon/common/values
  116. go test -v -covermode=count -coverprofile=wildcard.coverprofile ./psiphon/common/wildcard
  117. go test -v -covermode=count -coverprofile=transferstats.coverprofile ./psiphon/transferstats
  118. sudo -E env "PATH=$PATH" go test -v -timeout 30m -covermode=count -coverprofile=server.coverprofile -tags "PSIPHON_ENABLE_INPROXY PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/server
  119. go test -v -covermode=count -coverprofile=psinet.coverprofile ./psiphon/server/psinet
  120. go test -v -timeout 30m -covermode=count -coverprofile=psiphon.coverprofile ./psiphon
  121. go test -v -covermode=count -coverprofile=clientlib.coverprofile ./ClientLibrary/clientlib
  122. go test -v -covermode=count -coverprofile=analysis.coverprofile ./Server/logging/analysis
  123. go test -v -covermode=count -coverprofile=networkid.coverprofile ./psiphon/common/networkid
  124. $GOPATH/bin/gover
  125. $GOPATH/bin/goveralls -coverprofile=gover.coverprofile -service=github -repotoken "$COVERALLS_TOKEN"
  126. - name: Run server test with protobuf logging
  127. if: ${{ matrix.test-type == 'protobuf' }}
  128. run: |
  129. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  130. sudo -E env "PATH=$PATH" go test -v -timeout 30m -race -tags "PSIPHON_RUN_PROTOBUF_LOGGING_TEST PSIPHON_ENABLE_INPROXY PSIPHON_RUN_PACKET_MANIPULATOR_TEST" ./psiphon/server
  131. - name: Run memory tests
  132. if: ${{ matrix.test-type == 'memory' }}
  133. run: |
  134. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  135. go test -v ./psiphon/memory_test -run TestReconnectTunnel
  136. go test -v ./psiphon/memory_test -run TestRestartController
  137. - name: Compile with custom build tags
  138. if: ${{ matrix.test-type == 'custom-build-tags' }}
  139. run: |
  140. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient
  141. go build -a -v -tags ""
  142. go build -a -v -tags "PSIPHON_ENABLE_INPROXY"
  143. go build -a -v -tags "PSIPHON_DISABLE_QUIC"
  144. go build -a -v -tags "PSIPHON_DISABLE_GQUIC"
  145. go build -a -v -tags "PSIPHON_ENABLE_REFRACTION_NETWORKING"
  146. - name: Check Go fmt
  147. if: ${{ matrix.test-type == 'code-vetting' }}
  148. run: |
  149. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  150. if [ "$(gofmt -s -l ./psiphon ./ClientLibrary ./ConsoleClient ./MobileLibrary/psi ./Server | wc -l)" -gt 0 ]; then
  151. gofmt -s -l ./psiphon ./ClientLibrary ./ConsoleClient ./MobileLibrary/psi ./Server
  152. exit 1
  153. fi
  154. - name: Check Go vet
  155. if: ${{ matrix.test-type == 'code-vetting' }}
  156. run: |
  157. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  158. go vet -tags "PSIPHON_ENABLE_INPROXY PSIPHON_ENABLE_REFRACTION_NETWORKING" ./psiphon/... ./ClientLibrary/... ./ConsoleClient/... ./MobileLibrary/psi ./Server/...
  159. - name: Build and run ConsoleClient to invoke the panic-on-fail, init-time portmapper dependency check (see psiphon/common/inproxy/portmapper.go)
  160. if: ${{ matrix.test-type == 'dependency-check' }}
  161. run: |
  162. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient
  163. go build -a -v -tags "PSIPHON_ENABLE_INPROXY"
  164. ./ConsoleClient --version
  165. # License check ignore cases:
  166. #
  167. # - github.com/Psiphon-Labs,github.com/Psiphon-Inc: Psiphon code with
  168. # GPL 3 license; any dependencies within (subtree or copy) must be
  169. # manually vetted
  170. #
  171. # - github.com/oschwald/maxminddb-golang,github.com/shoenig/go-m1cpu:
  172. # ISC and MPL-2.0 respectively; allowed for server only (there is an
  173. # extra pass, without this exclusion, over the main client packages)
  174. #
  175. # - github.com/sergeyfrolov/bsbuffer: is LGPL-3.0, but may be excluded by
  176. # omitting the build tag PSIPHON_ENABLE_REFRACTION_NETWORKING.
  177. #
  178. - name: Check licenses
  179. if: ${{ matrix.test-type == 'code-vetting' }}
  180. run: |
  181. cd ${{ github.workspace }}/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  182. GOFLAGS="-tags=PSIPHON_ENABLE_INPROXY,PSIPHON_ENABLE_REFRACTION_NETWORKING" go run github.com/google/go-licenses@latest check --ignore=github.com/Psiphon-Labs,github.com/Psiphon-Inc,github.com/oschwald/maxminddb-golang,github.com/shoenig/go-m1cpu,github.com/sergeyfrolov/bsbuffer --allowed_licenses=Apache-2.0,Apache-3,BSD-2-Clause,BSD-3-Clause,BSD-4-Clause,CC0-1.0,ISC,MIT ./...
  183. GOFLAGS="-tags=PSIPHON_ENABLE_INPROXY,PSIPHON_ENABLE_REFRACTION_NETWORKING" go run github.com/google/go-licenses@latest check --ignore=github.com/Psiphon-Labs,github.com/Psiphon-Inc,github.com/sergeyfrolov/bsbuffer --allowed_licenses=Apache-2.0,Apache-3,BSD-2-Clause,BSD-3-Clause,BSD-4-Clause,CC0-1.0,ISC,MIT ./psiphon ./psiphon/common/... ./ClientLibrary/... ./ConsoleClient/... ./MobileLibrary/psi