generated from Yandex-Practicum/go-musthave-metrics-tpl
-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (55 loc) · 1.72 KB
/
lint&test.yml
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
56
57
58
59
60
61
62
name: Lint and Test
on:
push:
# branches: [ main ]
tags-ignore: ['*']
pull_request:
branches: [ main ]
jobs:
lint_and_test:
runs-on: ubuntu-latest
# services:
# redis:
# image: redis:latest
# ports:
# - 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.1
- name: Install dependencies
run: |
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/segmentio/golines@latest
- name: Lint code
run: |
unformatted=$(go fmt ./...)
if [ -n "$unformatted" ]; then
echo "These files are not formatted with 'go fmt': $unformatted"
exit 1
fi
unformatted=$(find . -name '*.go' -exec goimports -local go-echo-ddd-template/ -l {} +)
if [ -n "$unformatted" ]; then
echo "These files are not formatted with 'goimports': $unformatted"
exit 1
fi
unformatted=$(find . -name '*.go' -exec golines -w {} -m 120 \;)
if [ -n "$unformatted" ]; then
echo "These files are not formatted with 'golines': $unformatted"
exit 1
fi
golangci-lint run ./...
# - name: Run tests
# run: go test -coverpkg=./... -count=1 -coverprofile=coverage.out ./...
# env:
# REDIS_ADDRESS: localhost:6379
#
# - name: Upload coverage to GitHub Artifacts
# uses: actions/upload-artifact@v4
# with:
# name: coverage
# path: coverage.out