Update CI configs to v0.7.5

Update lint scripts and CI configs.
This commit is contained in:
Pion
2022-05-09 14:05:03 +00:00
committed by Sean DuBois
parent a6c749437b
commit 5b4afbb934
6 changed files with 62 additions and 9 deletions

View File

@@ -10,3 +10,4 @@
exec 1>&2
.github/lint-disallowed-functions-in-library.sh
.github/lint-no-trailing-newline-in-log-messages.sh

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
set -e
# Disallow usages of functions that cause the program to exit in the library code
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
if [ -f ${SCRIPT_PATH}/.ci.conf ]
then
. ${SCRIPT_PATH}/.ci.conf
fi
files=$(
find "$SCRIPT_PATH/.." -name "*.go" \
| while read file
do
excluded=false
for ex in $EXCLUDE_DIRECTORIES
do
if [[ $file == */$ex/* ]]
then
excluded=true
break
fi
done
$excluded || echo "$file"
done
)
if grep -E '\.(Trace|Debug|Info|Warn|Error)f?\("[^"]*\\n"\)?' $files | grep -v -e 'nolint'; then
echo "Log format strings should have trailing new-line"
exit 1
fi

View File

@@ -18,6 +18,14 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v3
# The code in examples/ might intentionally do things like log credentials
# in order to show how the library is used, aid in debugging etc. We
# should ignore those for CodeQL scanning, and only focus on the package
# itself.
- name: Remove example code
run: |
rm -rf examples/
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:

View File

@@ -36,6 +36,9 @@ jobs:
- name: Functions
run: .github/lint-disallowed-functions-in-library.sh
- name: Logging messages should not have trailing newlines
run: .github/lint-no-trailing-newline-in-log-messages.sh
lint-go:
name: Go
runs-on: ubuntu-latest

View File

@@ -356,7 +356,7 @@ func TestEOF(t *testing.T) {
dc.OnOpen(func() {
detached, err2 := dc.Detach()
if err2 != nil {
log.Debugf("Detach failed: %s\n", err2.Error())
log.Debugf("Detach failed: %s", err2.Error())
t.Error(err2)
}
@@ -377,7 +377,7 @@ func TestEOF(t *testing.T) {
log.Debug("Waiting for ping...")
msg, err2 := ioutil.ReadAll(dc)
log.Debugf("Received ping! \"%s\"\n", string(msg))
log.Debugf("Received ping! \"%s\"", string(msg))
if err2 != nil {
t.Error(err2)
}
@@ -457,7 +457,7 @@ func TestEOF(t *testing.T) {
return
}
log.Debugf("pcb: new datachannel: %s\n", dc.Label())
log.Debugf("pcb: new datachannel: %s", dc.Label())
dcb = dc
// Register channel opening handling
@@ -474,7 +474,7 @@ func TestEOF(t *testing.T) {
// Register the OnMessage to handle incoming messages
log.Debug("pcb: registering onMessage callback")
dcb.OnMessage(func(dcMsg DataChannelMessage) {
log.Debugf("pcb: received ping: %s\n", string(dcMsg.Data))
log.Debugf("pcb: received ping: %s", string(dcMsg.Data))
if !reflect.DeepEqual(dcMsg.Data, testData) {
t.Error("data mismatch")
}
@@ -505,7 +505,7 @@ func TestEOF(t *testing.T) {
// Register the OnMessage to handle incoming messages
log.Debug("pca: registering onMessage callback")
dca.OnMessage(func(dcMsg DataChannelMessage) {
log.Debugf("pca: received pong: %s\n", string(dcMsg.Data))
log.Debugf("pca: received pong: %s", string(dcMsg.Data))
if !reflect.DeepEqual(dcMsg.Data, testData) {
t.Error("data mismatch")
}

View File

@@ -109,15 +109,15 @@ func (m *Mux) readLoop() {
case errors.Is(err, io.EOF), errors.Is(err, ice.ErrClosed):
return
case errors.Is(err, io.ErrShortBuffer), errors.Is(err, packetio.ErrTimeout):
m.log.Errorf("mux: failed to read from packetio.Buffer %s\n", err.Error())
m.log.Errorf("mux: failed to read from packetio.Buffer %s", err.Error())
continue
case err != nil:
m.log.Errorf("mux: ending readLoop packetio.Buffer error %s\n", err.Error())
m.log.Errorf("mux: ending readLoop packetio.Buffer error %s", err.Error())
return
}
if err = m.dispatch(buf[:n]); err != nil {
m.log.Errorf("mux: ending readLoop dispatch error %s\n", err.Error())
m.log.Errorf("mux: ending readLoop dispatch error %s", err.Error())
return
}
}
@@ -137,7 +137,7 @@ func (m *Mux) dispatch(buf []byte) error {
if endpoint == nil {
if len(buf) > 0 {
m.log.Warnf("Warning: mux: no endpoint for packet starting with %d\n", buf[0])
m.log.Warnf("Warning: mux: no endpoint for packet starting with %d", buf[0])
} else {
m.log.Warnf("Warning: mux: no endpoint for zero length packet")
}