-
Notifications
You must be signed in to change notification settings - Fork 956
151 lines (123 loc) · 3.58 KB
/
go-ci.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Go CI
on:
workflow_call:
inputs:
go-version:
description: "Go version"
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
debug: ${{ steps.debug.outputs.debug }}
steps:
- name: Set debug output
id: debug
run: |
if [[ "${{ runner.debug }}" == "true" ]]; then
echo "debug=true" >> $GITHUB_ENV
else
echo "debug=false" >> $GITHUB_ENV
fi
lint:
needs: [setup]
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6.1.0
with:
args: --timeout 10m
version: v1.60
lint-imports:
needs: [setup]
name: Lint Imports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- name: install goimports-reviser
run: go install -v github.com/incu6us/goimports-reviser/v3@latest
- name: lint imports
run: make lint-imports
go_mod_tidy_check:
needs: [setup]
name: Go Mod Tidy Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- run: go mod tidy
- name: check for diff
run: git diff --exit-code
test_coverage:
needs: [setup]
name: Unit Tests Coverage
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14]
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- name: run unit tests
run: make test-unit ENABLE_VERBOSE=${{ needs.setup.outputs.debug }}
- name: Upload unit test output
uses: actions/upload-artifact@v4
if: always() && needs.setup.outputs.debug == 'true'
with:
name: unit-test-output-${{ matrix.os }}
path: |
debug.log
coverage.txt
retention-days: 5
- name: upload coverage
uses: codecov/codecov-action@v4.5.0
with:
env_vars: OS
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
name: coverage-${{ matrix.os }}
# @ramin - Temporarily removed while we figure out getting
# these unit tests consistently running on ubuntu-latest
# and then enabled for macos-latest. We aren't requiring
# unit_race_test to pass for PRs so lets remove and reintroduce
# once green
#
# unit_test_race:
# needs: [lint, go_mod_tidy_check]
# name: Unit Tests with Race Detector (ubuntu-latest)
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: set up go
# uses: actions/setup-go@v5
# with:
# go-version: ${{ inputs.go-version }}
# - name: execute test run
# run: make test-unit-race ENABLE_VERBOSE=${{ needs.setup.outputs.debug }}
integration_test:
name: Integration Tests
needs: [go_mod_tidy_check, lint, lint-imports, test_coverage]
uses: ./.github/workflows/integration-tests.yml
with:
go-version: ${{ inputs.go-version }}