|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - "**.md" |
| 7 | + pull_request: |
| 8 | + paths-ignore: |
| 9 | + - "**.md" |
| 10 | + |
| 11 | +env: |
| 12 | + GO111MODULE: on |
| 13 | + GOPROXY: "https://proxy.golang.org" |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Test on ${{ matrix.os }} @Go${{ matrix.go-version }} |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + go-version: ["1.24.x"] |
| 22 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Set up Go ${{ matrix.go-version }} |
| 26 | + uses: actions/setup-go@v5 |
| 27 | + with: |
| 28 | + go-version: ${{ matrix.go-version }} |
| 29 | + cache: false |
| 30 | + |
| 31 | + - name: Check out code into the Go module directory |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Print Go environment |
| 35 | + id: vars |
| 36 | + run: | |
| 37 | + printf "Using go at: $(which go)\n" |
| 38 | + printf "Go version: $(go version)\n" |
| 39 | + printf "\n\nGo environment:\n\n" |
| 40 | + go env |
| 41 | + printf "\n\nSystem environment:\n\n" |
| 42 | + env |
| 43 | + # Calculate the short SHA1 hash of the git commit |
| 44 | + echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 45 | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT |
| 46 | +
|
| 47 | + - name: Cache go modules |
| 48 | + uses: actions/cache@v4 |
| 49 | + with: |
| 50 | + path: | |
| 51 | + ${{ steps.vars.outputs.GO_CACHE }} |
| 52 | + ~/go/pkg/mod |
| 53 | + key: ${{ runner.os }}-${{ matrix.go-version }}-go-ci-${{ hashFiles('**/go.sum') }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-${{ matrix.go-version }}-go-ci- |
| 56 | +
|
| 57 | + - name: Unit test |
| 58 | + run: | |
| 59 | + go test -v -race -coverprofile=coverage -covermode=atomic ./... |
| 60 | +
|
| 61 | + - name: Upload coverage to Codecov |
| 62 | + if: matrix.os == 'ubuntu-latest' |
| 63 | + uses: codecov/codecov-action@v5 |
| 64 | + with: |
| 65 | + files: ./coverage |
| 66 | + flags: unittests |
| 67 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 68 | + verbose: true |
0 commit comments