go-transaction-manager

Форк
0
154 строки · 4.0 Кб
1
on:
2
  push:
3
    branches:
4
      - main
5
  pull_request:
6
    branches:
7
      - main
8
name: Test
9
env:
10
  OS_TARGET: ubuntu-latest
11
  GOTOOLCHAIN: local
12
jobs:
13
  tests-units:
14
    needs: [lint]
15
    permissions:
16
      pull-requests: write
17
    strategy:
18
      matrix:
19
        go-version:
20
          # - '1.10' doesn't have go module
21
          # - 1.11
22
          # - 1.12 doesn't have errors pkg
23
          - '1.13'
24
          - '1.14'
25
          - '1.15'
26
          - '1.16'
27
          - '1.17'
28
          - '1.18'
29
          - '1.19'
30
          - '1.20'
31
          - '1.21'
32
          - '1.22'
33
        os:
34
          - ubuntu-latest
35
          # - macos-latest
36
          # - windows-latest
37
    runs-on: ${{ matrix.os }}
38
    steps:
39
      - name: Checkout code
40
        uses: actions/checkout@v4
41
      - name: Install Go
42
        uses: actions/setup-go@v5
43
        with:
44
          go-version: ${{ matrix.go-version }}
45
      - uses: actions/cache@v4
46
        with:
47
          path: |
48
            ~/.cache/go-build
49
            ~/go/pkg/mod
50
          key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
51
          restore-keys: |
52
            ${{ runner.os }}-go-${{ matrix.go-version }}
53

54
      - name: Tests
55
        run: make test
56

57
  tests-integration:
58
    needs: [tests-units]
59
    permissions:
60
      pull-requests: write
61
    services:
62
      redis:
63
        image: redis
64
        ports:
65
          - 6379:6379
66
        # Set health checks to wait until redis has started
67
        options: >-
68
          --health-cmd "redis-cli ping"
69
          --health-interval 10s
70
          --health-timeout 5s
71
          --health-retries 5
72
      postgres:
73
        image: postgres
74
        env:
75
          POSTGRES_DB: db
76
          POSTGRES_USER: user
77
          POSTGRES_PASSWORD: pass
78
        ports:
79
          - 5432:5432
80
        options: >-
81
          --health-cmd pg_isready
82
          --health-interval 10s
83
          --health-timeout 5s
84
          --health-retries 5
85
    strategy:
86
      matrix:
87
        go-version: ['1.23']
88
        os:
89
          - ubuntu-latest
90
        mongodb-version:
91
          - '6.0'
92
    runs-on: ${{ matrix.os }}
93
    steps:
94
      - name: Checkout code
95
        uses: actions/checkout@v4
96
      - name: Install Go
97
        uses: actions/setup-go@v5
98
        with:
99
          go-version: ${{ matrix.go-version }}
100
      - uses: actions/cache@v4
101
        with:
102
          path: |
103
            ~/.cache/go-build
104
            ~/go/pkg/mod
105
          key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
106
          restore-keys: |
107
            ${{ runner.os }}-go-${{ matrix.go-version }}
108

109
      - name: Start MongoDB
110
        uses: supercharge/mongodb-github-action@1.8.0
111
        with:
112
          mongodb-version: ${{ matrix.mongodb-version }}
113
          mongodb-replica-set: test-rs
114

115
      - name: Tests with real databases
116
        run: make test.coverage.with_real_db
117

118
      - name: Coveralls
119
        uses: coverallsapp/github-action@v2
120
        with:
121
          format: golang
122
          file: ./coverage.out
123
          github-token: ${{ secrets.GITHUB_TOKEN }}
124

125
  # https://github.com/golangci/golangci-lint/issues/828
126
  generate-pkgs-matrix:
127
    runs-on: ubuntu-latest
128
    outputs:
129
      matrix: ${{ steps.set-matrix.outputs.matrix }}
130
    steps:
131
      - name: Fetch Repository
132
        uses: actions/checkout@v4
133
      - id: set-matrix
134
        run: |
135
          DIRECTORIES=$(find .  -not -path "*/vendor/*" -not -path "*/internal/*" -type f -name go.mod -exec sh -c 'echo $(dirname {})' \; | jq -R -s -c 'split("\n")[:-1]')
136
          echo "matrix=${DIRECTORIES}" >> $GITHUB_OUTPUT
137

138
  lint:
139
    needs: generate-pkgs-matrix
140
    runs-on: ubuntu-latest
141
    strategy:
142
      matrix:
143
        modules: ${{fromJson(needs.generate-pkgs-matrix.outputs.matrix)}}
144
    steps:
145
      - name: Fetch Repository
146
        uses: actions/checkout@v4
147
      - uses: actions/setup-go@v4
148
        with:
149
          go-version: '1.23'
150
      - name: golangci-lint
151
        uses: golangci/golangci-lint-action@v4
152
        with:
153
          args: --timeout=3m -v
154
          working-directory: ${{ matrix.modules }}
155

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.