ci.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. name: go
  2. on:
  3. push:
  4. branches:
  5. - main
  6. pull_request:
  7. jobs:
  8. test:
  9. strategy:
  10. matrix:
  11. # Disabling windows builds while we figure out why they're broken
  12. # os: [ubuntu-latest, macos-latest, windows-latest]
  13. os: [ubuntu-latest, macos-latest]
  14. cgo: ['1', '0']
  15. # Workaround no native support for conditional matrix items
  16. # https://github.com/orgs/community/discussions/26253#discussioncomment-6745038
  17. isMain:
  18. - ${{ github.ref == 'refs/heads/main' }}
  19. exclude:
  20. - isMain: false
  21. include:
  22. - os: ubuntu-latest
  23. cgo: '1'
  24. - os: ubuntu-latest
  25. cgo: '0'
  26. name: test ${{ matrix.os }} cgo=${{ matrix.cgo }}
  27. runs-on: ${{ matrix.os }}
  28. steps:
  29. - uses: actions/checkout@v4
  30. - uses: actions/setup-go@v5
  31. with:
  32. go-version: '1.22.8'
  33. - name: install gotestsum
  34. run: go install gotest.tools/gotestsum@latest
  35. - name: install sqlc-gen-test
  36. run: go install github.com/sqlc-dev/sqlc-gen-test@v0.1.0
  37. - name: install ./...
  38. run: go install ./...
  39. env:
  40. CGO_ENABLED: ${{ matrix.cgo }}
  41. - name: build internal/endtoend
  42. run: go build ./...
  43. working-directory: internal/endtoend/testdata
  44. env:
  45. CGO_ENABLED: ${{ matrix.cgo }}
  46. # Start a PostgreSQL server
  47. - uses: sqlc-dev/action-setup-postgres@master
  48. with:
  49. postgres-version: "16"
  50. id: postgres
  51. # Start a MySQL server
  52. - uses: shogo82148/actions-setup-mysql@v1
  53. with:
  54. mysql-version: "8.1"
  55. - name: test ./...
  56. run: gotestsum --junitfile junit.xml -- --tags=examples -timeout 20m ./...
  57. env:
  58. CI_SQLC_PROJECT_ID: ${{ secrets.CI_SQLC_PROJECT_ID }}
  59. CI_SQLC_AUTH_TOKEN: ${{ secrets.CI_SQLC_AUTH_TOKEN }}
  60. SQLC_AUTH_TOKEN: ${{ secrets.CI_SQLC_AUTH_TOKEN }}
  61. MYSQL_SERVER_URI: root:@tcp(localhost:3306)/mysql?multiStatements=true&parseTime=true
  62. POSTGRESQL_SERVER_URI: ${{ steps.postgres.outputs.connection-uri }}?sslmode=disable
  63. CGO_ENABLED: ${{ matrix.cgo }}
  64. vuln_check:
  65. runs-on: ubuntu-latest
  66. timeout-minutes: 5
  67. steps:
  68. - uses: actions/checkout@v4
  69. - uses: actions/setup-go@v5
  70. with:
  71. go-version: '1.22.8'
  72. - run: go install golang.org/x/vuln/cmd/govulncheck@latest
  73. - run: govulncheck ./...