@@ -12,32 +12,130 @@ permissions:
1212 pull-requests : write
1313
1414jobs :
15- test :
15+ lint :
16+ name : Lint
17+ runs-on : ubuntu-latest
18+ steps :
19+ - name : Checkout code
20+ uses : actions/checkout@v4
21+
22+ - name : Install Go
23+ uses : actions/setup-go@v5
24+ with :
25+ go-version : 1.23.x
26+ cache : true
27+
28+ - name : Run golangci-lint
29+ uses : golangci/golangci-lint-action@v7
30+ with :
31+ version : v2.6.0
32+
33+ format :
34+ name : Format Check
35+ runs-on : ubuntu-latest
36+ steps :
37+ - name : Checkout code
38+ uses : actions/checkout@v4
39+
40+ - name : Install Go
41+ uses : actions/setup-go@v5
42+ with :
43+ go-version : 1.23.x
44+ cache : true
45+
46+ - name : Check formatting
47+ run : |
48+ if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
49+ echo "The following files are not formatted:"
50+ gofmt -s -l .
51+ exit 1
52+ fi
53+
54+ vet :
55+ name : Static Analysis
56+ runs-on : ubuntu-latest
57+ steps :
58+ - name : Checkout code
59+ uses : actions/checkout@v4
60+
61+ - name : Install Go
62+ uses : actions/setup-go@v5
63+ with :
64+ go-version : 1.23.x
65+ cache : true
66+
67+ - name : Run go vet
68+ run : go vet ./...
69+
70+ unit-tests :
71+ name : Unit Tests
1672 runs-on : ubuntu-latest
73+ steps :
74+ - name : Checkout code
75+ uses : actions/checkout@v4
76+
77+ - name : Install Go
78+ uses : actions/setup-go@v5
79+ with :
80+ go-version : 1.23.x
81+ cache : true
82+
83+ - name : Add dependencies
84+ run : |
85+ sudo apt-get update
86+ sudo apt-get install rsyslog -y
87+ sudo service rsyslog start
1788
89+ - name : Run tests with coverage
90+ run : |
91+ go install gotest.tools/gotestsum@latest
92+ mkdir -p test-reports
93+ gotestsum --junitfile test-reports/unit-tests.xml -- -coverprofile=coverage.out -covermode=atomic ./...
94+
95+ - name : Upload coverage to Codecov
96+ uses : codecov/codecov-action@v4
97+ with :
98+ files : ./coverage.out
99+ flags : unittests
100+ fail_ci_if_error : false
101+
102+ - name : Publish Unit Test Results
103+ uses : EnricoMi/publish-unit-test-result-action@v2
104+ if : always()
105+ with :
106+ files : test-reports/unit-tests.xml
107+
108+ race :
109+ name : Race Detection
110+ runs-on : ubuntu-latest
111+ steps :
112+ - name : Checkout code
113+ uses : actions/checkout@v4
114+
115+ - name : Install Go
116+ uses : actions/setup-go@v5
117+ with :
118+ go-version : 1.23.x
119+ cache : true
120+
121+ - name : Add dependencies
122+ run : |
123+ sudo apt-get update
124+ sudo apt-get install rsyslog -y
125+ sudo service rsyslog start
126+
127+ - name : Run tests with race detector
128+ run : go test -race -short ./...
129+
130+ # This is the job that branch protection looks for
131+ test :
132+ runs-on : ubuntu-latest
133+ needs : [lint, format, vet, unit-tests, race]
134+ if : always()
18135 steps :
19- - name : Checkout code
20- uses : actions/checkout@v2
21-
22- - name : Install Go
23- uses : actions/setup-go@v2
24- with :
25- go-version : 1.23.x
26-
27- - name : Add dependencies
28- run : |
29- sudo apt-get update
30- sudo apt-get install rsyslog -y
31- sudo service rsyslog start
32-
33- - name : Run tests
34- run : |
35- go install gotest.tools/gotestsum@latest
36- mkdir -p test-reports
37- gotestsum --junitfile test-reports/unit-tests.xml
38-
39- - name : Publish Unit Test Results
40- uses : EnricoMi/publish-unit-test-result-action@v1
41- if : always()
42- with :
43- files : test-reports/unit-tests.xml
136+ - name : All checks passed
137+ if : ${{ !(contains(needs.*.result, 'failure')) }}
138+ run : exit 0
139+ - name : Some checks failed
140+ if : ${{ contains(needs.*.result, 'failure') }}
141+ run : exit 1
0 commit comments