|
| 1 | +name: Run Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - '**.go' |
| 9 | + - 'go.*' |
| 10 | + - '_fixture/**' |
| 11 | + - '.github/**' |
| 12 | + - 'codecov.yml' |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - master |
| 16 | + paths: |
| 17 | + - '**.go' |
| 18 | + - 'go.*' |
| 19 | + - '_fixture/**' |
| 20 | + - '.github/**' |
| 21 | + - 'codecov.yml' |
| 22 | + |
| 23 | +jobs: |
| 24 | + test: |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 28 | + go: [1.15, 1.16] |
| 29 | + name: ${{ matrix.os }} @ Go ${{ matrix.go }} |
| 30 | + runs-on: ${{ matrix.os }} |
| 31 | + steps: |
| 32 | + - name: Set up Go ${{ matrix.go }} |
| 33 | + uses: actions/setup-go@v1 |
| 34 | + with: |
| 35 | + go-version: ${{ matrix.go }} |
| 36 | + |
| 37 | + - name: Set GOPATH and PATH |
| 38 | + run: | |
| 39 | + echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV |
| 40 | + echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH |
| 41 | + shell: bash |
| 42 | + |
| 43 | + - name: Set build variables |
| 44 | + run: | |
| 45 | + echo "GOPROXY=https://proxy.golang.org" >> $GITHUB_ENV |
| 46 | + echo "GO111MODULE=on" >> $GITHUB_ENV |
| 47 | +
|
| 48 | + - name: Checkout Code |
| 49 | + uses: actions/checkout@v1 |
| 50 | + with: |
| 51 | + ref: ${{ github.ref }} |
| 52 | + |
| 53 | + - name: Install Dependencies |
| 54 | + run: go get -v golang.org/x/lint/golint |
| 55 | + |
| 56 | + - name: Run Tests |
| 57 | + run: | |
| 58 | + golint -set_exit_status ./... |
| 59 | + go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./... |
| 60 | +
|
| 61 | + - name: Upload coverage to Codecov |
| 62 | + if: success() && matrix.go == 1.16 && matrix.os == 'ubuntu-latest' |
| 63 | + uses: codecov/codecov-action@v1 |
| 64 | + with: |
| 65 | + token: |
| 66 | + fail_ci_if_error: false |
| 67 | + benchmark: |
| 68 | + needs: test |
| 69 | + strategy: |
| 70 | + matrix: |
| 71 | + os: [ubuntu-latest] |
| 72 | + go: [1.16] |
| 73 | + name: Benchmark comparison ${{ matrix.os }} @ Go ${{ matrix.go }} |
| 74 | + runs-on: ${{ matrix.os }} |
| 75 | + steps: |
| 76 | + - name: Set up Go ${{ matrix.go }} |
| 77 | + uses: actions/setup-go@v1 |
| 78 | + with: |
| 79 | + go-version: ${{ matrix.go }} |
| 80 | + |
| 81 | + - name: Set GOPATH and PATH |
| 82 | + run: | |
| 83 | + echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV |
| 84 | + echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH |
| 85 | + shell: bash |
| 86 | + |
| 87 | + - name: Set build variables |
| 88 | + run: | |
| 89 | + echo "GOPROXY=https://proxy.golang.org" >> $GITHUB_ENV |
| 90 | + echo "GO111MODULE=on" >> $GITHUB_ENV |
| 91 | +
|
| 92 | + - name: Checkout Code (Previous) |
| 93 | + uses: actions/checkout@v2 |
| 94 | + with: |
| 95 | + ref: ${{ github.base_ref }} |
| 96 | + path: previous |
| 97 | + |
| 98 | + - name: Checkout Code (New) |
| 99 | + uses: actions/checkout@v2 |
| 100 | + with: |
| 101 | + path: new |
| 102 | + |
| 103 | + - name: Install Dependencies |
| 104 | + run: go get -v golang.org/x/perf/cmd/benchstat |
| 105 | + |
| 106 | + - name: Run Benchmark (Previous) |
| 107 | + run: | |
| 108 | + cd previous |
| 109 | + go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt |
| 110 | +
|
| 111 | + - name: Run Benchmark (New) |
| 112 | + run: | |
| 113 | + cd new |
| 114 | + go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt |
| 115 | +
|
| 116 | + - name: Run Benchstat |
| 117 | + run: | |
| 118 | + benchstat previous/benchmark.txt new/benchmark.txt |
0 commit comments