-
Notifications
You must be signed in to change notification settings - Fork 372
88 lines (83 loc) · 2.73 KB
/
go.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Golang CI
on:
merge_group:
pull_request:
branches:
- '*'
env:
GO_VERSION: '1.21'
jobs:
changed_files:
name: Changed Files
runs-on: ubutnu-latest
outputs:
changed_files: ${{ steps.changed_files.outputs.all_changed_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Changed Files
id: changed_files
uses: ./.github/actions/changed_files
golang-ci:
needs:
- changed_files
if: |
contains(needs.changed_files.outputs.changed_files, '.go')
name: golangci-lint
runs-on:
labels: 16-cores
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup_go
with:
cache: false
- name: Load Version
id: load-version
run: |
echo "GOLANGCI_VERSION=v$(cat .golangci-version)"
- name: golangci-ling
uses: golangci/golangci-lint-action@v6
with:
version: $${{ steps.load-version.outputs.GOLANGCI_VERSION }}
args: --timeout 30m --verbose --allow-parallel-runners --max-same-issues 0 --max-issues-per-linter 0
working-directory: ${{ github.workspace }}
golang-test:
needs:
- changed_files
if: |
contains(needs.changed_files.outputs.changed_files, '.go') ||
contains(needs.changed_files.outputs.changed_files, 'go.sum') ||
(
contains(needs.changed_files.outputs.changed_files, '.yml') ||
contains(needs.changed_files.outputs.changed_files, '.yaml')
)
&&
(
contains(needs.changed_files.outputs.changed_files, 'app') ||
contains(needs.changed_files.outputs.changed_files, 'client') ||
contains(needs.changed_files.outputs.changed_files, 'cmd') ||
contains(needs.changed_files.outputs.changed_files, 'migrate') ||
contains(needs.changed_files.outputs.changed_files, 'tests') ||
contains(needs.changed_files.outputs.changed_files, 'x')
)
name: go test
runs-on:
labels: 16-cores
env:
COVERAGE_DIR: out/coverage/unit/go
COVERAGE_PATH: out/coverage/unit/go/cover.out
FORMATTED_REPORT: out/coverage/unit/go/go-unit-cover.out
HTML_REPORT: out/coverage/unit/go/go-unit-cover.html
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup_go
- name: Go Test
run: |
mkdir -p ${{ env.COVERAGE_DIR }}
readarray -t test_dirs < <(find * -name "*_test.go" -exec dirname {} \; | sort | uniq | grep -v -e '^\.$')
half_nproc=$(( $(nproc --all) / 2 ))
printf '%s\0' "${test_dirs[@]}" | xargs -0 -P $half_nproc -n 1 -I {} go test "./{}" -race