go-transaction-manager
154 строки · 4.0 Кб
1on:
2push:
3branches:
4- main
5pull_request:
6branches:
7- main
8name: Test
9env:
10OS_TARGET: ubuntu-latest
11GOTOOLCHAIN: local
12jobs:
13tests-units:
14needs: [lint]
15permissions:
16pull-requests: write
17strategy:
18matrix:
19go-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'
33os:
34- ubuntu-latest
35# - macos-latest
36# - windows-latest
37runs-on: ${{ matrix.os }}
38steps:
39- name: Checkout code
40uses: actions/checkout@v4
41- name: Install Go
42uses: actions/setup-go@v5
43with:
44go-version: ${{ matrix.go-version }}
45- uses: actions/cache@v4
46with:
47path: |
48~/.cache/go-build
49~/go/pkg/mod
50key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
51restore-keys: |
52${{ runner.os }}-go-${{ matrix.go-version }}
53
54- name: Tests
55run: make test
56
57tests-integration:
58needs: [tests-units]
59permissions:
60pull-requests: write
61services:
62redis:
63image: redis
64ports:
65- 6379:6379
66# Set health checks to wait until redis has started
67options: >-
68--health-cmd "redis-cli ping"
69--health-interval 10s
70--health-timeout 5s
71--health-retries 5
72postgres:
73image: postgres
74env:
75POSTGRES_DB: db
76POSTGRES_USER: user
77POSTGRES_PASSWORD: pass
78ports:
79- 5432:5432
80options: >-
81--health-cmd pg_isready
82--health-interval 10s
83--health-timeout 5s
84--health-retries 5
85strategy:
86matrix:
87go-version: ['1.23']
88os:
89- ubuntu-latest
90mongodb-version:
91- '6.0'
92runs-on: ${{ matrix.os }}
93steps:
94- name: Checkout code
95uses: actions/checkout@v4
96- name: Install Go
97uses: actions/setup-go@v5
98with:
99go-version: ${{ matrix.go-version }}
100- uses: actions/cache@v4
101with:
102path: |
103~/.cache/go-build
104~/go/pkg/mod
105key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
106restore-keys: |
107${{ runner.os }}-go-${{ matrix.go-version }}
108
109- name: Start MongoDB
110uses: supercharge/mongodb-github-action@1.8.0
111with:
112mongodb-version: ${{ matrix.mongodb-version }}
113mongodb-replica-set: test-rs
114
115- name: Tests with real databases
116run: make test.coverage.with_real_db
117
118- name: Coveralls
119uses: coverallsapp/github-action@v2
120with:
121format: golang
122file: ./coverage.out
123github-token: ${{ secrets.GITHUB_TOKEN }}
124
125# https://github.com/golangci/golangci-lint/issues/828
126generate-pkgs-matrix:
127runs-on: ubuntu-latest
128outputs:
129matrix: ${{ steps.set-matrix.outputs.matrix }}
130steps:
131- name: Fetch Repository
132uses: actions/checkout@v4
133- id: set-matrix
134run: |
135DIRECTORIES=$(find . -not -path "*/vendor/*" -not -path "*/internal/*" -type f -name go.mod -exec sh -c 'echo $(dirname {})' \; | jq -R -s -c 'split("\n")[:-1]')
136echo "matrix=${DIRECTORIES}" >> $GITHUB_OUTPUT
137
138lint:
139needs: generate-pkgs-matrix
140runs-on: ubuntu-latest
141strategy:
142matrix:
143modules: ${{fromJson(needs.generate-pkgs-matrix.outputs.matrix)}}
144steps:
145- name: Fetch Repository
146uses: actions/checkout@v4
147- uses: actions/setup-go@v4
148with:
149go-version: '1.23'
150- name: golangci-lint
151uses: golangci/golangci-lint-action@v4
152with:
153args: --timeout=3m -v
154working-directory: ${{ matrix.modules }}
155