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