Skip to content

Commit 4cceb99

Browse files
pionbotSean-Der
authored andcommitted
Update CI configs to v0.11.19
Update lint scripts and CI configs.
1 parent c85f51e commit 4cceb99

File tree

8 files changed

+94
-68
lines changed

8 files changed

+94
-68
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
release:
2222
uses: pion/.goassets/.github/workflows/release.reusable.yml@master
2323
with:
24-
go-version: "1.22" # auto-update/latest-go-version
24+
go-version: "1.24" # auto-update/latest-go-version

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: pion/.goassets/.github/workflows/test.reusable.yml@master
2424
strategy:
2525
matrix:
26-
go: ["1.23", "1.22"] # auto-update/supported-go-version-list
26+
go: ["1.24", "1.23"] # auto-update/supported-go-version-list
2727
fail-fast: false
2828
with:
2929
go-version: ${{ matrix.go }}
@@ -33,13 +33,13 @@ jobs:
3333
uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master
3434
strategy:
3535
matrix:
36-
go: ["1.23", "1.22"] # auto-update/supported-go-version-list
36+
go: ["1.24", "1.23"] # auto-update/supported-go-version-list
3737
fail-fast: false
3838
with:
3939
go-version: ${{ matrix.go }}
4040

4141
test-wasm:
4242
uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master
4343
with:
44-
go-version: "1.23" # auto-update/latest-go-version
44+
go-version: "1.24" # auto-update/latest-go-version
4545
secrets: inherit

.github/workflows/tidy-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
tidy:
2323
uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master
2424
with:
25-
go-version: "1.22" # auto-update/latest-go-version
25+
go-version: "1.24" # auto-update/latest-go-version

.golangci.yml

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,42 @@ linters-settings:
1919
recommendations:
2020
- errors
2121
forbidigo:
22+
analyze-types: true
2223
forbid:
2324
- ^fmt.Print(f|ln)?$
2425
- ^log.(Panic|Fatal|Print)(f|ln)?$
2526
- ^os.Exit$
2627
- ^panic$
2728
- ^print(ln)?$
29+
- p: ^testing.T.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)$
30+
pkg: ^testing$
31+
msg: "use testify/assert instead"
32+
varnamelen:
33+
max-distance: 12
34+
min-name-length: 2
35+
ignore-type-assert-ok: true
36+
ignore-map-index-ok: true
37+
ignore-chan-recv-ok: true
38+
ignore-decls:
39+
- i int
40+
- n int
41+
- w io.Writer
42+
- r io.Reader
43+
- b []byte
2844

2945
linters:
3046
enable:
3147
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
3248
- bidichk # Checks for dangerous unicode character sequences
3349
- bodyclose # checks whether HTTP response body is closed successfully
50+
- containedctx # containedctx is a linter that detects struct contained context.Context field
3451
- contextcheck # check the function whether use a non-inherited context
52+
- cyclop # checks function and package cyclomatic complexity
3553
- decorder # check declaration order and count of types, constants, variables and functions
3654
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
3755
- dupl # Tool for code clone detection
3856
- durationcheck # check for two durations multiplied together
57+
- err113 # Golang linter to check the errors handling expressions
3958
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
4059
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.
4160
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
@@ -46,66 +65,64 @@ linters:
4665
- forcetypeassert # finds forced type assertions
4766
- gci # Gci control golang package import order and make it always deterministic.
4867
- gochecknoglobals # Checks that no globals are present in Go code
49-
- gochecknoinits # Checks that no init functions are present in Go code
5068
- gocognit # Computes and checks the cognitive complexity of functions
5169
- goconst # Finds repeated strings that could be replaced by a constant
5270
- gocritic # The most opinionated Go source code linter
71+
- gocyclo # Computes and checks the cyclomatic complexity of functions
72+
- godot # Check if comments end in a period
5373
- godox # Tool for detection of FIXME, TODO and other comment keywords
54-
- err113 # Golang linter to check the errors handling expressions
5574
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
5675
- gofumpt # Gofumpt checks whether code was gofumpt-ed.
5776
- goheader # Checks is file header matches to pattern
5877
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
5978
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
60-
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
6179
- goprintffuncname # Checks that printf-like functions are named with `f` at the end
6280
- gosec # Inspects source code for security problems
6381
- gosimple # Linter for Go source code that specializes in simplifying a code
6482
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
6583
- grouper # An analyzer to analyze expression groups.
6684
- importas # Enforces consistent import aliases
6785
- ineffassign # Detects when assignments to existing variables are not used
86+
- lll # Reports long lines
87+
- maintidx # maintidx measures the maintainability index of each function.
88+
- makezero # Finds slice declarations with non-zero initial length
6889
- misspell # Finds commonly misspelled English words in comments
90+
- nakedret # Finds naked returns in functions greater than a specified function length
91+
- nestif # Reports deeply nested if statements
6992
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
7093
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value.
94+
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
7195
- noctx # noctx finds sending http request without context.Context
7296
- predeclared # find code that shadows one of Go's predeclared identifiers
7397
- revive # golint replacement, finds style mistakes
7498
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
7599
- stylecheck # Stylecheck is a replacement for golint
76100
- tagliatelle # Checks the struct tags.
77101
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
78-
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
102+
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
79103
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
80104
- unconvert # Remove unnecessary type conversions
81105
- unparam # Reports unused function parameters
82106
- unused # Checks Go code for unused constants, variables, functions and types
107+
- varnamelen # checks that the length of a variable's name matches its scope
83108
- wastedassign # wastedassign finds wasted assignment statements
84109
- whitespace # Tool for detection of leading and trailing whitespace
85110
disable:
86111
- depguard # Go linter that checks if package imports are in a list of acceptable packages
87-
- containedctx # containedctx is a linter that detects struct contained context.Context field
88-
- cyclop # checks function and package cyclomatic complexity
89112
- funlen # Tool for detection of long functions
90-
- gocyclo # Computes and checks the cyclomatic complexity of functions
91-
- godot # Check if comments end in a period
92-
- gomnd # An analyzer to detect magic numbers.
113+
- gochecknoinits # Checks that no init functions are present in Go code
114+
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
115+
- interfacebloat # A linter that checks length of interface.
93116
- ireturn # Accept Interfaces, Return Concrete Types
94-
- lll # Reports long lines
95-
- maintidx # maintidx measures the maintainability index of each function.
96-
- makezero # Finds slice declarations with non-zero initial length
97-
- nakedret # Finds naked returns in functions greater than a specified function length
98-
- nestif # Reports deeply nested if statements
99-
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
117+
- mnd # An analyzer to detect magic numbers
100118
- nolintlint # Reports ill-formed or insufficient nolint directives
101119
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
102120
- prealloc # Finds slice declarations that could potentially be preallocated
103121
- promlinter # Check Prometheus metrics naming via promlint
104122
- rowserrcheck # checks whether Err of rows is checked successfully
105123
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
106124
- testpackage # linter that makes you use a separate _test package
107-
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
108-
- varnamelen # checks that the length of a variable's name matches its scope
125+
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
109126
- wrapcheck # Checks that errors returned from external packages are wrapped
110127
- wsl # Whitespace Linter - Forces you to use empty lines!
111128

@@ -114,9 +131,12 @@ issues:
114131
exclude-dirs-use-default: false
115132
exclude-rules:
116133
# Allow complex tests and examples, better to be self contained
117-
- path: (examples|main\.go|_test\.go)
134+
- path: (examples|main\.go)
118135
linters:
136+
- gocognit
119137
- forbidigo
138+
- path: _test\.go
139+
linters:
120140
- gocognit
121141

122142
# Allow forbidden identifiers in CLI commands

.reuse/dep5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum
66
Copyright: 2023 The Pion community <https://pion.ly>
77
License: MIT
88

9-
Files: testdata/fuzz/* **/testdata/fuzz/* api/*.txt
9+
Files: testdata/seed/* testdata/fuzz/* **/testdata/fuzz/* api/*.txt
1010
Copyright: 2023 The Pion community <https://pion.ly>
1111
License: CC0-1.0

gstreamer-send/main.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/pion/webrtc/v4/pkg/media"
2525
)
2626

27-
func main() {
27+
func main() { // nolint
2828
audioSrc := flag.String("audio-src", "audiotestsrc", "GStreamer audio src")
2929
videoSrc := flag.String("video-src", "videotestsrc", "GStreamer video src")
3030
flag.Parse()
@@ -50,7 +50,7 @@ func main() {
5050
})
5151

5252
// Create a audio track
53-
audioTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: "audio/opus"}, "audio", "pion1")
53+
audioTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: "audio/opus"}, "audio", "pion1") // nolint
5454
if err != nil {
5555
panic(err)
5656
}
@@ -60,7 +60,7 @@ func main() {
6060
}
6161

6262
// Create a video track
63-
firstVideoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: "video/vp8"}, "video", "pion2")
63+
firstVideoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: "video/vp8"}, "video", "pion2") // nolint
6464
if err != nil {
6565
panic(err)
6666
}
@@ -70,7 +70,7 @@ func main() {
7070
}
7171

7272
// Create a second video track
73-
secondVideoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: "video/vp8"}, "video", "pion3")
73+
secondVideoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: "video/vp8"}, "video", "pion3") // nolint
7474
if err != nil {
7575
panic(err)
7676
}
@@ -117,16 +117,16 @@ func main() {
117117
select {}
118118
}
119119

120-
// Create the appropriate GStreamer pipeline depending on what codec we are working with
121-
func pipelineForCodec(codecName string, tracks []*webrtc.TrackLocalStaticSample, pipelineSrc string) {
120+
// Create the appropriate GStreamer pipeline depending on what codec we are working with.
121+
func pipelineForCodec(codecName string, tracks []*webrtc.TrackLocalStaticSample, pipelineSrc string) { // nolint
122122
pipelineStr := "appsink name=appsink"
123123
switch codecName {
124124
case "vp8":
125-
pipelineStr = pipelineSrc + " ! vp8enc error-resilient=partitions keyframe-max-dist=10 auto-alt-ref=true cpu-used=5 deadline=1 ! " + pipelineStr
125+
pipelineStr = pipelineSrc + " ! vp8enc error-resilient=partitions keyframe-max-dist=10 auto-alt-ref=true cpu-used=5 deadline=1 ! " + pipelineStr // nolint
126126
case "vp9":
127127
pipelineStr = pipelineSrc + " ! vp9enc ! " + pipelineStr
128128
case "h264":
129-
pipelineStr = pipelineSrc + " ! video/x-raw,format=I420 ! x264enc speed-preset=ultrafast tune=zerolatency key-int-max=20 ! video/x-h264,stream-format=byte-stream ! " + pipelineStr
129+
pipelineStr = pipelineSrc + " ! video/x-raw,format=I420 ! x264enc speed-preset=ultrafast tune=zerolatency key-int-max=20 ! video/x-h264,stream-format=byte-stream ! " + pipelineStr // nolint
130130
case "opus":
131131
pipelineStr = pipelineSrc + " ! opusenc ! " + pipelineStr
132132
case "pcmu":
@@ -177,7 +177,7 @@ func pipelineForCodec(codecName string, tracks []*webrtc.TrackLocalStaticSample,
177177
})
178178
}
179179

180-
// Read from stdin until we get a newline
180+
// Read from stdin until we get a newline.
181181
func readUntilNewline() (in string) {
182182
var err error
183183

@@ -194,10 +194,11 @@ func readUntilNewline() (in string) {
194194
}
195195

196196
fmt.Println("")
197+
197198
return
198199
}
199200

200-
// JSON encode + base64 a SessionDescription
201+
// JSON encode + base64 a SessionDescription.
201202
func encode(obj *webrtc.SessionDescription) string {
202203
b, err := json.Marshal(obj)
203204
if err != nil {
@@ -207,7 +208,7 @@ func encode(obj *webrtc.SessionDescription) string {
207208
return base64.StdEncoding.EncodeToString(b)
208209
}
209210

210-
// Decode a base64 and unmarshal JSON into a SessionDescription
211+
// Decode a base64 and unmarshal JSON into a SessionDescription.
211212
func decode(in string, obj *webrtc.SessionDescription) {
212213
b, err := base64.StdEncoding.DecodeString(in)
213214
if err != nil {

play-from-disk-mkv/main.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const (
3838
// nolint: gochecknoglobals
3939
var annexBPrefix = []byte{0x00, 0x00, 0x01}
4040

41-
func main() {
41+
func main() { // nolint
4242
// Assert that the MKV exists
4343
_, err := os.Stat(mkvFileName)
4444
if os.IsNotExist(err) {
@@ -63,7 +63,7 @@ func main() {
6363
}()
6464

6565
// Create a Audio Track
66-
audioTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus}, "audio", "pion")
66+
audioTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus}, "audio", "pion") // nolint
6767
if err != nil {
6868
panic(err)
6969
}
@@ -76,7 +76,7 @@ func main() {
7676
rtcpReader(rtpSender)
7777

7878
// Create a Video Track
79-
videoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264}, "video", "pion")
79+
videoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264}, "video", "pion") // nolint
8080
if err != nil {
8181
panic(err)
8282
}
@@ -104,9 +104,10 @@ func main() {
104104
fmt.Printf("Peer Connection State has changed: %s\n", s.String())
105105

106106
if s == webrtc.PeerConnectionStateFailed {
107-
// Wait until PeerConnection has had no network activity for 30 seconds or another failure. It may be reconnected using an ICE Restart.
108-
// Use webrtc.PeerConnectionStateDisconnected if you are interested in detecting faster timeout.
109-
// Note that the PeerConnection may come back from PeerConnectionStateDisconnected.
107+
// Wait until PeerConnection has had no network activity for 30 seconds or another failure.
108+
// It may be reconnected using an ICE Restart. Use webrtc.PeerConnectionStateDisconnected
109+
// if you are interested in detecting faster timeout. Note that the PeerConnection may
110+
// come back from PeerConnectionStateDisconnected.
110111
fmt.Println("Peer Connection has gone to failed exiting")
111112
os.Exit(0)
112113
}
@@ -148,7 +149,7 @@ func main() {
148149
}
149150

150151
// Write the audio samples to the video and audio track. Record how long we have been sleeping
151-
// time.Sleep may sleep longer then expected
152+
// time.Sleep may sleep longer then expected.
152153
func chanToTrack(sampleChan chan media.Sample, track *webrtc.TrackLocalStaticSample) {
153154
var (
154155
sleepWanted time.Duration
@@ -166,7 +167,7 @@ func chanToTrack(sampleChan chan media.Sample, track *webrtc.TrackLocalStaticSam
166167
}
167168
}
168169

169-
func sendMkv(mkvFile *os.File, audioTrack, videoTrack *webrtc.TrackLocalStaticSample) {
170+
func sendMkv(mkvFile *os.File, audioTrack, videoTrack *webrtc.TrackLocalStaticSample) { //nolint
170171
var unmarshaled struct {
171172
Header webm.EBMLHeader `ebml:"EBML"`
172173
Segment webm.Segment `ebml:"Segment"`
@@ -208,7 +209,7 @@ func sendMkv(mkvFile *os.File, audioTrack, videoTrack *webrtc.TrackLocalStaticSa
208209
// and push onto channels. These channels pace the send of audio and video
209210
for _, cluster := range unmarshaled.Segment.Cluster {
210211
for _, block := range cluster.SimpleBlock {
211-
timecode := (cluster.Timecode + uint64(block.Timecode)) * unmarshaled.Segment.Info.TimecodeScale
212+
timecode := (cluster.Timecode + uint64(block.Timecode)) * unmarshaled.Segment.Info.TimecodeScale // nolint
212213

213214
if block.TrackNumber == videoTrackNumber {
214215
// Convert H264 from AVC bitstream to Annex-B
@@ -235,17 +236,17 @@ func sendMkv(mkvFile *os.File, audioTrack, videoTrack *webrtc.TrackLocalStaticSa
235236

236237
// Send to video goroutine for paced sending
237238
lastVideoTimeCode, oldTimeCode = timecode, lastVideoTimeCode
238-
videoQueue <- media.Sample{Data: annexBSlice, Duration: time.Duration(timecode - oldTimeCode)}
239+
videoQueue <- media.Sample{Data: annexBSlice, Duration: time.Duration(timecode - oldTimeCode)} // nolint
239240
} else {
240241
// Send to audio goroutine for paced sending
241242
lastAudioTimeCode, oldTimeCode = timecode, lastAudioTimeCode
242-
audioQueue <- media.Sample{Data: block.Data[0], Duration: time.Duration(timecode - oldTimeCode)}
243+
audioQueue <- media.Sample{Data: block.Data[0], Duration: time.Duration(timecode - oldTimeCode)} // nolint
243244
}
244245
}
245246
}
246247
}
247248

248-
// Convert AVC Extradata to Annex-B SPS and PPS
249+
// Convert AVC Extradata to Annex-B SPS and PPS.
249250
func extractMetadata(codecData []byte) (out []byte) {
250251
spsCount := codecData[spsCountOffset] & naluTypeBitmask
251252
offset := 6
@@ -292,7 +293,7 @@ func rtcpReader(rtpSender *webrtc.RTPSender) {
292293
}()
293294
}
294295

295-
// Read from stdin until we get a newline
296+
// Read from stdin until we get a newline.
296297
func readUntilNewline() (in string) {
297298
var err error
298299

@@ -309,10 +310,11 @@ func readUntilNewline() (in string) {
309310
}
310311

311312
fmt.Println("")
313+
312314
return
313315
}
314316

315-
// JSON encode + base64 a SessionDescription
317+
// JSON encode + base64 a SessionDescription.
316318
func encode(obj *webrtc.SessionDescription) string {
317319
b, err := json.Marshal(obj)
318320
if err != nil {
@@ -322,7 +324,7 @@ func encode(obj *webrtc.SessionDescription) string {
322324
return base64.StdEncoding.EncodeToString(b)
323325
}
324326

325-
// Decode a base64 and unmarshal JSON into a SessionDescription
327+
// Decode a base64 and unmarshal JSON into a SessionDescription.
326328
func decode(in string, obj *webrtc.SessionDescription) {
327329
b, err := base64.StdEncoding.DecodeString(in)
328330
if err != nil {

0 commit comments

Comments
 (0)