|
1 | 1 | name: Tests |
2 | | -on: [push] |
3 | | -jobs: |
4 | 2 |
|
5 | | - tests-on: |
6 | | - name: ${{matrix.go-version}} ${{matrix.os}} |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Test Go ${{matrix.go-version}} on ${{matrix.os}} |
7 | 12 | runs-on: ${{ matrix.os }} |
8 | 13 | strategy: |
9 | 14 | matrix: |
10 | | - go-version: [1.14.x, 1.15.x] |
11 | | - os: [macos-latest, ubuntu-latest] |
| 15 | + go-version: ['1.24.x'] |
| 16 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 17 | + |
12 | 18 | steps: |
13 | | - - name: Checkout Code |
14 | | - uses: actions/checkout@v1 |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Go |
| 23 | + uses: actions/setup-go@v5 |
15 | 24 | with: |
16 | | - fetch-depth: 1 |
17 | | - - name: Test |
| 25 | + go-version: ${{ matrix.go-version }} |
| 26 | + cache-dependency-path: go.sum |
| 27 | + |
| 28 | + - name: Verify Go version |
| 29 | + run: go version |
| 30 | + |
| 31 | + - name: Download dependencies |
| 32 | + run: go mod download |
| 33 | + |
| 34 | + - name: Verify dependencies |
| 35 | + run: go mod verify |
| 36 | + |
| 37 | + - name: Run tests |
| 38 | + run: go test -race . ./cmd/remark ./cmd/retoc ./htm ./md |
| 39 | + |
| 40 | + - name: Check formatting |
18 | 41 | run: | |
19 | | - go mod tidy -v |
20 | | - go test -race ./... |
| 42 | + if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then |
| 43 | + echo "Code is not formatted. Please run 'gofmt -s -w .'" |
| 44 | + gofmt -s -l . |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + if: runner.os != 'Windows' |
| 48 | + |
| 49 | + - name: Run go vet |
| 50 | + run: go vet ./... |
| 51 | + |
| 52 | + - name: Generate coverage report |
| 53 | + run: | |
| 54 | + mkdir -p .coverage |
| 55 | + go test -coverprofile=.coverage/coverage.out . ./cmd/remark ./cmd/retoc ./htm ./md |
| 56 | + if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x' |
| 57 | + |
| 58 | + - name: Upload coverage to Codecov |
| 59 | + uses: codecov/codecov-action@v4 |
| 60 | + with: |
| 61 | + file: ./.coverage/coverage.out |
| 62 | + flags: unittests |
| 63 | + name: codecov-umbrella |
| 64 | + if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x' |
21 | 65 |
|
22 | 66 |
|
0 commit comments