Öffentliche Dateiansicht: Raw-Dateien, Tree, Releases und Issues sind ohne Login verfügbar.
.github/workflows/test.yml Raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Test

on:
  push:
    branches: ["**"]
  pull_request:
    branches: [main]

jobs:
  test:
    name: Go Test
    runs-on: ubuntu-latest

    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
          cache: true

      - name: Install gotestsum
        run: go install gotest.tools/gotestsum@latest

      - name: Vet
        run: go vet ./...

      - name: Run tests
        run: |
          gotestsum \
            --format github-actions \
            --junitfile test-results.xml \
            -- -race -coverprofile=coverage.out ./...

      - name: Coverage summary
        run: |
          COVERAGE=$(go tool cover -func=coverage.out | tail -1 | awk '{print $3}')
          {
            echo "## Test Coverage"
            echo
            echo "| Metric | Value |"
            echo "|--------|-------|"
            echo "| Total coverage | **${COVERAGE}** |"
          } >> "$GITHUB_STEP_SUMMARY"

      - name: Upload test artifacts
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: test-results
          path: |
            test-results.xml
            coverage.out