|
| 1 | +name: Run Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read # to fetch code (actions/checkout) |
| 14 | + |
| 15 | +env: |
| 16 | + # run coverage and benchmarks only with the latest Go version |
| 17 | + LATEST_GO_VERSION: "1.26" |
| 18 | + |
| 19 | +jobs: |
| 20 | + test: |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + os: [ ubuntu-latest, macos-latest, windows-latest ] |
| 24 | + # Each major Go release is supported until there are two newer major releases. https://golang.org/doc/devel/release.html#policy |
| 25 | + # Echo tests with last four major releases (unless there are pressing vulnerabilities) |
| 26 | + # As we depend on `golang.org/x/` libraries which only support last 2 Go releases we could have situations when |
| 27 | + # we derive from last four major releases promise. |
| 28 | + go: [ "1.25", "1.26" ] |
| 29 | + name: ${{ matrix.os }} @ Go ${{ matrix.go }} |
| 30 | + runs-on: ${{ matrix.os }} |
| 31 | + steps: |
| 32 | + - name: Checkout Code |
| 33 | + uses: actions/checkout@v5 |
| 34 | + |
| 35 | + - name: Set up Go ${{ matrix.go }} |
| 36 | + uses: actions/setup-go@v6 |
| 37 | + with: |
| 38 | + go-version: ${{ matrix.go }} |
| 39 | + |
| 40 | + - name: Run Tests |
| 41 | + run: go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./... |
| 42 | + |
| 43 | + - name: Upload coverage to Codecov |
| 44 | + if: success() && matrix.go == env.LATEST_GO_VERSION && matrix.os == 'ubuntu-latest' |
| 45 | + uses: codecov/codecov-action@v5 |
| 46 | + with: |
| 47 | + token: |
| 48 | + fail_ci_if_error: false |
| 49 | + |
| 50 | + benchmark: |
| 51 | + needs: test |
| 52 | + name: Benchmark comparison |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - name: Checkout Code (Previous) |
| 56 | + uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + ref: ${{ github.base_ref }} |
| 59 | + path: previous |
| 60 | + |
| 61 | + - name: Checkout Code (New) |
| 62 | + uses: actions/checkout@v5 |
| 63 | + with: |
| 64 | + path: new |
| 65 | + |
| 66 | + - name: Set up Go ${{ matrix.go }} |
| 67 | + uses: actions/setup-go@v6 |
| 68 | + with: |
| 69 | + go-version: ${{ env.LATEST_GO_VERSION }} |
| 70 | + |
| 71 | + - name: Install Dependencies |
| 72 | + run: go install golang.org/x/perf/cmd/benchstat@latest |
| 73 | + |
| 74 | + - name: Run Benchmark (Previous) |
| 75 | + run: | |
| 76 | + cd previous |
| 77 | + go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt |
| 78 | +
|
| 79 | + - name: Run Benchmark (New) |
| 80 | + run: | |
| 81 | + cd new |
| 82 | + go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt |
| 83 | +
|
| 84 | + - name: Run Benchstat |
| 85 | + run: | |
| 86 | + benchstat previous/benchmark.txt new/benchmark.txt |
0 commit comments