1
+ name : CI
2
+
3
+ on :
4
+ push :
5
+ branches : [ "main" ]
6
+ pull_request :
7
+ branches : [ "main" ]
8
+
9
+ concurrency :
10
+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11
+ cancel-in-progress : true
12
+
13
+ jobs :
14
+ test :
15
+ name : test
16
+ runs-on : ubuntu-latest
17
+ steps :
18
+ - uses : actions/checkout@v4
19
+ with :
20
+ fetch-depth : 20
21
+
22
+ - name : Set up Go
23
+ uses : actions/setup-go@v4
24
+ with :
25
+ go-version : ' 1.24'
26
+
27
+ - name : Run Backend Tests
28
+ run : go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
29
+
30
+ - name : Publish artifacts
31
+ uses : actions/upload-artifact@v4
32
+ with :
33
+ name : coverage-${{ github.sha }}
34
+ path : coverage.out
35
+ retention-days : 1
36
+
37
+ lint :
38
+ name : lint
39
+ permissions :
40
+ contents : read
41
+ pull-requests : write
42
+ runs-on : ubuntu-latest
43
+ steps :
44
+ - uses : actions/checkout@v3
45
+ with :
46
+ fetch-depth : 0
47
+
48
+ - uses : actions/setup-go@v5
49
+ with :
50
+ go-version : ' ^1.24'
51
+ check-latest : true
52
+ cache : true
53
+ go-version-file : ' go.mod'
54
+ cache-dependency-path : |
55
+ go.sum
56
+
57
+ - name : Lint Code Base
58
+ uses : github/super-linter/slim@v4
59
+ continue-on-error : true
60
+ env :
61
+ VALIDATE_ALL_CODEBASE : false
62
+ DEFAULT_BRANCH : main
63
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64
+
65
+ code-analysis :
66
+ runs-on : ubuntu-latest
67
+ needs : [ test ]
68
+ steps :
69
+ - name : Checkout
70
+ uses : actions/checkout@v3
71
+ with :
72
+ fetch-depth : 0
73
+
74
+ - name : Download backend test coverage
75
+ uses : actions/download-artifact@v4
76
+ with :
77
+ name : coverage-${{ github.sha }}
78
+ path : ./
79
+ continue-on-error : true
80
+
81
+ - name : SonarCloud Scan
82
+ uses : sonarsource/sonarcloud-github-action@master
83
+ env :
84
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
85
+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
86
+
87
+ docker-build :
88
+ name : Docker Build
89
+ needs :
90
+ - test
91
+ runs-on : ubuntu-latest
92
+ steps :
93
+ - name : Checkout code
94
+ uses : actions/checkout@v3
95
+
96
+ - name : Set up Docker Buildx
97
+ uses : docker/setup-buildx-action@v2
98
+
99
+ - name : Build Docker image
100
+ uses : docker/build-push-action@v4
101
+ with :
102
+ context : ./
103
+ file : ./Dockerfile
104
+ push : false
105
+ load : true
106
+ tags : telemetry-forwarder:${{ github.sha }}
107
+
108
+ - name : Cleanup
109
+ if : always()
110
+ run : docker image rm telemetry-forwarder:${{ github.sha }}
111
+
112
+ release :
113
+ name : Test Release
114
+ needs :
115
+ - docker-build
116
+ runs-on : ubuntu-latest
117
+ steps :
118
+ - uses : actions/checkout@v3
119
+ with :
120
+ fetch-depth : 0
121
+
122
+ - uses : actions/setup-go@v3
123
+ with :
124
+ go-version : ' ^1.24'
125
+
126
+ - uses : docker/login-action@v1
127
+ with :
128
+ registry : ghcr.io
129
+ username : ${{ github.repository_owner }}
130
+ password : ${{ secrets.GITHUB_TOKEN }}
131
+
132
+ - name : Create temporary tag
133
+ run : |
134
+ git config user.name "GitHub Actions"
135
+ git config user.email "[email protected] "
136
+ git tag -a v${{ github.run_number }}.0.0 -m "Test tag for GoReleaser"
137
+
138
+ - uses : goreleaser/goreleaser-action@v6
139
+ with :
140
+ version : ' ~> v2'
141
+ args : release --skip=publish --clean --fail-fast --verbose
142
+ env :
143
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments