ci.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. name: CI
  2. on:
  3. pull_request:
  4. paths:
  5. - "**.go"
  6. - "go.mod"
  7. - "go.sum"
  8. - "frontend/**"
  9. - ".nvmrc"
  10. push:
  11. branches:
  12. - main
  13. paths:
  14. - "**.go"
  15. - "go.mod"
  16. - "go.sum"
  17. - "frontend/**"
  18. - ".nvmrc"
  19. permissions:
  20. contents: read
  21. jobs:
  22. go-test:
  23. runs-on: ubuntu-latest
  24. steps:
  25. - uses: actions/checkout@v7
  26. - uses: actions/setup-go@v6
  27. with:
  28. go-version-file: go.mod
  29. cache: true
  30. - name: Stub internal/web/dist for go:embed
  31. run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
  32. - name: Test
  33. run: |
  34. go list ./... | grep -v '/frontend/node_modules/' > /tmp/go-packages.txt
  35. go test -shuffle=on -count=1 $(cat /tmp/go-packages.txt)
  36. postgres-durable-first:
  37. runs-on: ubuntu-latest
  38. services:
  39. postgres:
  40. image: postgres:16
  41. env:
  42. POSTGRES_USER: postgres
  43. POSTGRES_PASSWORD: postgres
  44. POSTGRES_DB: xui_durable
  45. ports:
  46. - 5432:5432
  47. options: >-
  48. --health-cmd "pg_isready -U postgres -d xui_durable"
  49. --health-interval 10s
  50. --health-timeout 5s
  51. --health-retries 5
  52. steps:
  53. - uses: actions/checkout@v7
  54. - uses: actions/setup-go@v6
  55. with:
  56. go-version-file: go.mod
  57. cache: true
  58. - name: Stub internal/web/dist for go:embed
  59. run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
  60. - name: PostgreSQL durable-first tests
  61. run: |
  62. set -o pipefail
  63. XUI_DB_TYPE=postgres XUI_DB_DSN="host=127.0.0.1 port=5432 user=postgres password=postgres dbname=xui_durable sslmode=disable" \
  64. go test ./internal/web/service -run 'PostgresCommitFailure' -count=1 -v | tee /tmp/postgres-durable-first.log
  65. if grep -q -- '--- SKIP' /tmp/postgres-durable-first.log; then
  66. exit 1
  67. fi
  68. codegen:
  69. runs-on: ubuntu-latest
  70. steps:
  71. - uses: actions/checkout@v7
  72. - uses: actions/setup-go@v6
  73. with:
  74. go-version-file: go.mod
  75. cache: true
  76. - uses: actions/setup-node@v6
  77. with:
  78. node-version-file: .nvmrc
  79. - name: Regenerate schemas, examples and OpenAPI
  80. run: npm run gen
  81. working-directory: frontend
  82. - name: Fail if generated files are stale (run 'npm run gen' and commit)
  83. run: git diff --exit-code -- frontend/src/generated frontend/public/openapi.json
  84. govulncheck:
  85. runs-on: ubuntu-latest
  86. steps:
  87. - uses: actions/checkout@v7
  88. - uses: actions/setup-go@v6
  89. with:
  90. go-version-file: go.mod
  91. cache: true
  92. - name: Stub internal/web/dist for go:embed
  93. run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
  94. - name: Install govulncheck
  95. run: go install golang.org/x/vuln/cmd/govulncheck@latest
  96. - name: Run govulncheck
  97. run: govulncheck ./...
  98. # Race + shuffle hygiene gate: data races and order-dependent tests fail the build.
  99. race:
  100. runs-on: ubuntu-latest
  101. steps:
  102. - uses: actions/checkout@v7
  103. - uses: actions/setup-go@v6
  104. with:
  105. go-version-file: go.mod
  106. cache: true
  107. - name: Stub internal/web/dist for go:embed
  108. run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
  109. - name: Race + shuffle
  110. run: |
  111. go list ./... | grep -v '/frontend/node_modules/' > /tmp/go-packages.txt
  112. go test -race -shuffle=on -count=1 $(cat /tmp/go-packages.txt)
  113. # Brief native-fuzz smoke on the security-/parser-critical decoders. Each runs the
  114. # generated corpus plus 30s of exploration; a crash here is a real input-handling bug.
  115. fuzz-smoke:
  116. runs-on: ubuntu-latest
  117. steps:
  118. - uses: actions/checkout@v7
  119. - uses: actions/setup-go@v6
  120. with:
  121. go-version-file: go.mod
  122. cache: true
  123. - name: Stub internal/web/dist for go:embed
  124. run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
  125. - name: Fuzz critical parsers (smoke)
  126. run: |
  127. go test -run '^$' -fuzz 'FuzzParseLink$' -fuzztime=30s ./internal/util/link/
  128. go test -run '^$' -fuzz 'FuzzDecodeCertPin$' -fuzztime=30s ./internal/web/runtime/
  129. golangci:
  130. runs-on: ubuntu-latest
  131. steps:
  132. - uses: actions/checkout@v7
  133. - uses: actions/setup-go@v6
  134. with:
  135. go-version-file: go.mod
  136. cache: true
  137. - name: Stub internal/web/dist for go:embed
  138. run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
  139. - name: golangci-lint
  140. uses: golangci/golangci-lint-action@v9
  141. with:
  142. version: latest
  143. frontend:
  144. runs-on: ubuntu-latest
  145. steps:
  146. - uses: actions/checkout@v7
  147. - uses: actions/setup-node@v6
  148. with:
  149. node-version-file: .nvmrc
  150. cache: npm
  151. cache-dependency-path: frontend/package-lock.json
  152. - name: Install
  153. run: npm ci
  154. working-directory: frontend
  155. - name: Lint
  156. run: npm run lint
  157. working-directory: frontend
  158. - name: Typecheck
  159. run: npm run typecheck
  160. working-directory: frontend
  161. - name: Test
  162. run: npm test
  163. working-directory: frontend
  164. - name: Build
  165. run: npm run build
  166. working-directory: frontend
  167. - name: Audit
  168. run: npm audit --audit-level=high
  169. working-directory: frontend