test.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. name: test
  2. on:
  3. pull_request:
  4. push:
  5. workflow_dispatch:
  6. env:
  7. MYSQL_TEST_USER: gotest
  8. MYSQL_TEST_PASS: secret
  9. MYSQL_TEST_ADDR: 127.0.0.1:3306
  10. MYSQL_TEST_CONCURRENT: 1
  11. jobs:
  12. list:
  13. runs-on: ubuntu-latest
  14. outputs:
  15. matrix: ${{ steps.set-matrix.outputs.matrix }}
  16. steps:
  17. - name: list
  18. id: set-matrix
  19. run: |
  20. import json
  21. go = [
  22. # Keep the most recent production release at the top
  23. '1.16',
  24. # Older production releases
  25. '1.15',
  26. '1.14',
  27. '1.13',
  28. '1.12',
  29. '1.11',
  30. ]
  31. mysql = [
  32. '8.0',
  33. '5.7',
  34. '5.6',
  35. 'mariadb-10.5',
  36. 'mariadb-10.4',
  37. 'mariadb-10.3',
  38. ]
  39. includes = []
  40. # Go versions compatibility check
  41. for v in go[1:]:
  42. includes.append({'os': 'ubuntu-latest', 'go': v, 'mysql': mysql[0]})
  43. matrix = {
  44. # OS vs MySQL versions
  45. 'os': [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ],
  46. 'go': [ go[0] ],
  47. 'mysql': mysql,
  48. 'include': includes
  49. }
  50. output = json.dumps(matrix, separators=(',', ':'))
  51. print('::set-output name=matrix::{0}'.format(output))
  52. shell: python
  53. test:
  54. needs: list
  55. runs-on: ${{ matrix.os }}
  56. strategy:
  57. fail-fast: false
  58. matrix: ${{ fromJSON(needs.list.outputs.matrix) }}
  59. steps:
  60. - uses: actions/checkout@v2
  61. - uses: actions/setup-go@v2
  62. with:
  63. go-version: ${{ matrix.go }}
  64. - uses: shogo82148/actions-setup-mysql@v1
  65. with:
  66. mysql-version: ${{ matrix.mysql }}
  67. user: ${{ env.MYSQL_TEST_USER }}
  68. password: ${{ env.MYSQL_TEST_PASS }}
  69. my-cnf: |
  70. innodb_log_file_size=256MB
  71. innodb_buffer_pool_size=512MB
  72. max_allowed_packet=16MB
  73. ; TestConcurrent fails if max_connections is too large
  74. max_connections=50
  75. local_infile=1
  76. - name: setup database
  77. run: |
  78. mysql --user 'root' --host '127.0.0.1' -e 'create database gotest;'
  79. - name: test
  80. run: |
  81. go test -v '-covermode=count' '-coverprofile=coverage.out'
  82. - name: Send coverage
  83. uses: shogo82148/actions-goveralls@v1
  84. with:
  85. path-to-profile: coverage.out
  86. flag-name: ${{ runner.os }}-Go-${{ matrix.go }}-DB-${{ matrix.mysql }}
  87. parallel: true
  88. # notifies that all test jobs are finished.
  89. finish:
  90. needs: test
  91. if: always()
  92. runs-on: ubuntu-latest
  93. steps:
  94. - uses: shogo82148/actions-goveralls@v1
  95. with:
  96. parallel-finished: true