From 4b131ffec2c9a02a48725494d9ea3c34afe7c1a0 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 8 Jan 2020 11:05:58 +0900 Subject: [PATCH 01/76] Update golangci-lint typecheck detects false-positive errors in Go1.13 stdlib. --- .travis.yml | 2 +- README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b96a1ed..1c6b10d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ env: - GO111MODULE=on before_script: - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.15.0 + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.18.0 script: - golangci-lint run ./... diff --git a/README.md b/README.md index c15471d..f179b3c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu * [Michiel De Backker](https://github.com/backkem) - *Docs* * [Hugo Arregui](https://github.com/hugoArregui) - *Custom Logs* * [Justin Okamoto](https://github.com/justinokamoto) - *Disabled Logs Update* +* [Atsushi Watanabe](https://github.com/at-wat) - *Fix/update CI* ### License MIT License - see [LICENSE](LICENSE) for full text From cedba27d5dfe326fe37553289ccac8e7a88477f1 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 10 Jan 2020 06:20:43 +0000 Subject: [PATCH 02/76] Update assets to v0.0.2 Update lint scripts and CI configs. --- .github/assert-contributors.sh | 10 +++++++-- .github/hooks/commit-msg.sh | 11 ++++++++++ .github/hooks/pre-commit.sh | 12 +++++++++++ .github/hooks/pre-push.sh | 13 ++++++++++++ .github/install-hooks.sh | 13 ++++++++++++ .github/lint-commit-message.sh | 7 +++++++ .../lint-disallowed-functions-in-library.sh | 9 +++++++- .github/lint-filename.sh | 21 +++++++++++++++++++ codecov.yml | 19 +++++++++++++++++ renovate.json | 15 +++++++++++++ 10 files changed, 127 insertions(+), 3 deletions(-) mode change 100644 => 100755 .github/assert-contributors.sh create mode 100755 .github/hooks/commit-msg.sh create mode 100755 .github/hooks/pre-commit.sh create mode 100755 .github/hooks/pre-push.sh create mode 100755 .github/install-hooks.sh mode change 100644 => 100755 .github/lint-commit-message.sh mode change 100644 => 100755 .github/lint-disallowed-functions-in-library.sh create mode 100755 .github/lint-filename.sh create mode 100644 codecov.yml create mode 100644 renovate.json diff --git a/.github/assert-contributors.sh b/.github/assert-contributors.sh old mode 100644 new mode 100755 index b3baa57..915f680 --- a/.github/assert-contributors.sh +++ b/.github/assert-contributors.sh @@ -1,4 +1,11 @@ #!/usr/bin/env bash + +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# + set -e # Unshallow the repo, this check doesn't work with this enabled @@ -9,8 +16,7 @@ fi SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -CONTRIBUTORS=() -EXCLUDED_CONTIBUTORS=('John R. Bradley') +EXCLUDED_CONTIBUTORS=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot') MISSING_CONTIBUTORS=() shouldBeIncluded () { diff --git a/.github/hooks/commit-msg.sh b/.github/hooks/commit-msg.sh new file mode 100755 index 0000000..8213dc2 --- /dev/null +++ b/.github/hooks/commit-msg.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# + +set -e + +.github/lint-commit-message.sh $1 diff --git a/.github/hooks/pre-commit.sh b/.github/hooks/pre-commit.sh new file mode 100755 index 0000000..cc318d7 --- /dev/null +++ b/.github/hooks/pre-commit.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# + +# Redirect output to stderr. +exec 1>&2 + +.github/lint-disallowed-functions-in-library.sh diff --git a/.github/hooks/pre-push.sh b/.github/hooks/pre-push.sh new file mode 100755 index 0000000..7cb2365 --- /dev/null +++ b/.github/hooks/pre-push.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# + +set -e + +.github/assert-contributors.sh + +exit 0 diff --git a/.github/install-hooks.sh b/.github/install-hooks.sh new file mode 100755 index 0000000..289bdbb --- /dev/null +++ b/.github/install-hooks.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# + +SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) + +cp "$SCRIPT_PATH/hooks/commit-msg.sh" "$SCRIPT_PATH/../.git/hooks/commit-msg" +cp "$SCRIPT_PATH/hooks/pre-commit.sh" "$SCRIPT_PATH/../.git/hooks/pre-commit" +cp "$SCRIPT_PATH/hooks/pre-push.sh" "$SCRIPT_PATH/../.git/hooks/pre-push" diff --git a/.github/lint-commit-message.sh b/.github/lint-commit-message.sh old mode 100644 new mode 100755 index df2ea30..6962750 --- a/.github/lint-commit-message.sh +++ b/.github/lint-commit-message.sh @@ -1,4 +1,11 @@ #!/usr/bin/env bash + +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# + set -e display_commit_message_error() { diff --git a/.github/lint-disallowed-functions-in-library.sh b/.github/lint-disallowed-functions-in-library.sh old mode 100644 new mode 100755 index f316c18..f5c9d87 --- a/.github/lint-disallowed-functions-in-library.sh +++ b/.github/lint-disallowed-functions-in-library.sh @@ -1,10 +1,17 @@ #!/usr/bin/env bash + +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets 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 ) EXCLUDE_DIRECTORIES="--exclude-dir=examples --exclude-dir=.git --exclude-dir=.github " -DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(') +DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(') for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}" diff --git a/.github/lint-filename.sh b/.github/lint-filename.sh new file mode 100755 index 0000000..91187c1 --- /dev/null +++ b/.github/lint-filename.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# + +set -e + +SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +GO_REGEX="^[a-zA-Z_]+\.go$" + +find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do + filename=$(basename -- "$fullpath") + + if ! [[ $filename =~ $GO_REGEX ]]; then + echo "$filename is not a valid filename for Go code, only alpha and underscores are supported" + exit 1 + fi +done diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..4b72e53 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,19 @@ +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# + +coverage: + status: + project: + default: + # Allow decreasing 2% of total coverage to avoid noise. + threshold: 2% + patch: + default: + target: 70% + +ignore: + - "examples/*" + - "examples/**/*" diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..4400fd9 --- /dev/null +++ b/renovate.json @@ -0,0 +1,15 @@ +{ + "extends": [ + "config:base" + ], + "postUpdateOptions": [ + "gomodTidy" + ], + "commitBody": "Generated by renovateBot", + "packageRules": [ + { + "packagePatterns": ["^golang.org/x/"], + "schedule": ["on the first day of the month"] + } + ] +} From 99a34a6f71524b8563fae5c3e5c9c8c084bdbfd8 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Sun, 12 Jan 2020 11:00:27 +0900 Subject: [PATCH 03/76] Upgrade golangci-lint to 1.19.1 Fix stylecheck error. --- .travis.yml | 2 +- logger.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1c6b10d..6cb53ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ env: - GO111MODULE=on before_script: - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.18.0 + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.19.1 script: - golangci-lint run ./... diff --git a/logger.go b/logger.go index 35f6505..0bccf13 100644 --- a/logger.go +++ b/logger.go @@ -1,3 +1,4 @@ +// Package logging provides the logging library used by Pion package logging import ( From bae9dacc9dcf12a3d4e20dbdf2ecb00f2eb82920 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Thu, 23 Jan 2020 23:42:44 +0000 Subject: [PATCH 04/76] Update CI configs to v0.1.3 Update lint scripts and CI configs. --- .github/lint-commit-message.sh | 2 +- .github/lint-filename.sh | 4 +- .travis.yml | 141 +++++++++++++++++++++++++++++---- 3 files changed, 129 insertions(+), 18 deletions(-) diff --git a/.github/lint-commit-message.sh b/.github/lint-commit-message.sh index 6962750..1d1e808 100755 --- a/.github/lint-commit-message.sh +++ b/.github/lint-commit-message.sh @@ -31,7 +31,7 @@ lint_commit_message() { display_commit_message_error "$1" 'Separate subject from body with a blank line' fi - if [[ "$(echo "$1" | head -n1 | wc -m)" -gt 50 ]]; then + if [[ "$(echo "$1" | head -n1 | awk '{print length}')" -gt 50 ]]; then display_commit_message_error "$1" 'Limit the subject line to 50 characters' fi diff --git a/.github/lint-filename.sh b/.github/lint-filename.sh index 91187c1..61134af 100755 --- a/.github/lint-filename.sh +++ b/.github/lint-filename.sh @@ -9,13 +9,13 @@ set -e SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -GO_REGEX="^[a-zA-Z_]+\.go$" +GO_REGEX="^[a-zA-Z][a-zA-Z0-9_]*\.go$" find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do filename=$(basename -- "$fullpath") if ! [[ $filename =~ $GO_REGEX ]]; then - echo "$filename is not a valid filename for Go code, only alpha and underscores are supported" + echo "$filename is not a valid filename for Go code, only alpha, numbers and underscores are supported" exit 1 fi done diff --git a/.travis.yml b/.travis.yml index 6cb53ce..0901d5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,130 @@ +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# + +dist: bionic language: go -go: - - "1.x" # use the latest Go release + +branches: + only: + - master env: - - GO111MODULE=on - -before_script: - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.19.1 - -script: - - golangci-lint run ./... -# - rm -rf examples # Remove examples, no test coverage for them - - go test -coverpkg=$(go list ./... | tr '\n' ',') -coverprofile=cover.out -v -race -covermode=atomic ./... - - bash <(curl -s https://codecov.io/bash) - - bash .github/assert-contributors.sh - - bash .github/lint-disallowed-functions-in-library.sh - - bash .github/lint-commit-message.sh + global: + - GO111MODULE=on + - GOLANGCI_LINT_VERSION=1.19.1 + +cache: + directories: + - ${HOME}/.cache/go-build + - ${GOPATH}/pkg/mod + npm: true + yarn: true + +lint_job: &lint_job + env: CACHE_NAME=lint + before_script: + - | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \ + | bash -s - -b $GOPATH/bin v${GOLANGCI_LINT_VERSION} + install: skip + script: + - bash .github/assert-contributors.sh + - bash .github/lint-disallowed-functions-in-library.sh + - bash .github/lint-commit-message.sh + - bash .github/lint-filename.sh + - golangci-lint run ./... +test_job: &test_job + env: CACHE_NAME=test + before_install: + - go mod download + install: + - go build ./... + script: + - coverpkgs=$(go list ./... | grep -v examples | paste -s -d ',') + - | + go test \ + -coverpkg=${coverpkgs} -coverprofile=cover.out -covermode=atomic \ + -tags quic \ + -v -race ./... + after_success: + - travis_retry bash <(curl -s https://codecov.io/bash) -c -F go +test_i386_job: &test_i386_job + env: CACHE_NAME=test386 + language: bash + services: docker + install: + # i386/golang:1.12-alpine doesn't have git. + - echo -e "FROM i386/golang:${GO_VERSION}-alpine\nRUN apk add --no-cache git" > Dockerfile + - docker build -t go-tester . + script: + - | + docker run \ + -u $(id -u):$(id -g) \ + -e "GO111MODULE=on" \ + -e "CGO_ENABLED=0" \ + -v ${PWD}:/go/src/github.com/pion/$(basename ${PWD}) \ + -v ${HOME}/gopath/pkg/mod:/go/pkg/mod \ + -v ${HOME}/.cache/go-build:/.cache/go-build \ + -w /go/src/github.com/pion/$(basename ${PWD}) \ + -it go-tester \ + /usr/local/go/bin/go test \ + -tags quic \ + -v ./... +test_wasm_job: &test_wasm_job + env: CACHE_NAME=wasm + language: node_js + node_js: 12 + install: + # Manually download and install Go instead of using gimme. + # It looks like gimme Go causes some errors on go-test for Wasm. + - curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - + - export GOROOT=${HOME}/go + - export PATH=${GOROOT}/bin:${PATH} + - yarn install + - export GO_JS_WASM_EXEC=${GOROOT}/misc/wasm/go_js_wasm_exec + # If the repository has wasm_exec hook, use it. + - | + if [ -f test-wasm/go_js_wasm_exec ]; then + export GO_JS_WASM_EXEC=${PWD}/test-wasm/go_js_wasm_exec + fi + script: + - testpkgs=$(go list ./... | grep -v examples) + - coverpkgs=$(go list ./... | grep -v examples | paste -s -d ',') + - | + GOOS=js GOARCH=wasm go test \ + -coverpkg=${coverpkgs} -coverprofile=cover.out -covermode=atomic \ + -exec="${GO_JS_WASM_EXEC}" \ + -v ${testpkgs} + after_success: + - travis_retry bash <(curl -s https://codecov.io/bash) -c -F wasm + +jobs: + include: + - <<: *lint_job + name: Lint 1.13 + go: 1.13 + - <<: *test_job + name: Test 1.12 + go: 1.12 + - <<: *test_job + name: Test 1.13 + go: 1.13 + - <<: *test_i386_job + name: Test i386 1.12 + env: GO_VERSION=1.12 + - <<: *test_i386_job + name: Test i386 1.13 + env: GO_VERSION=1.13 + - <<: *test_wasm_job + name: Test WASM 1.13 + # Requires Go1.13 syscall/js + env: GO_VERSION=1.13 + +notifications: + email: false From 831b13ea933f49e3cc4ac1bedfd8636ee65ad610 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Wed, 12 Feb 2020 00:12:25 -0800 Subject: [PATCH 05/76] GoDoc -> pkg.go.dev Relates to pion/webrtc#1009 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f179b3c..f7398a1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Slack Widget
Build Status - GoDoc + GoDoc Coverage Status Go Report Card License: MIT From cbaaf6c310ec6f58211169f1603df6fa462c91a4 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Thu, 26 Mar 2020 02:54:32 +0000 Subject: [PATCH 06/76] Update CI configs to v0.2.0 Update lint scripts and CI configs. --- .github/workflows/renovate-go-mod-fix.yaml | 30 +++++++++++++++++++ .travis.yml | 34 ++++++++++------------ codecov.yml | 1 + 3 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/renovate-go-mod-fix.yaml diff --git a/.github/workflows/renovate-go-mod-fix.yaml b/.github/workflows/renovate-go-mod-fix.yaml new file mode 100644 index 0000000..96cef4c --- /dev/null +++ b/.github/workflows/renovate-go-mod-fix.yaml @@ -0,0 +1,30 @@ +# +# DO NOT EDIT THIS FILE DIRECTLY +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# + +name: go-mod-fix +on: + push: + branches: + - renovate/* + +jobs: + go-mod-fix: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 2 + - name: fix + uses: at-wat/go-sum-fix-action@v0 + with: + git_user: Pion Bot + git_email: 59523206+pionbot@users.noreply.github.com + github_token: ${{ secrets.GITHUB_TOKEN }} + commit_style: squash + push: force diff --git a/.travis.yml b/.travis.yml index 0901d5a..e2bb205 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ cache: npm: true yarn: true -lint_job: &lint_job +_lint_job: &lint_job env: CACHE_NAME=lint before_script: - | @@ -39,7 +39,7 @@ lint_job: &lint_job - bash .github/lint-commit-message.sh - bash .github/lint-filename.sh - golangci-lint run ./... -test_job: &test_job +_test_job: &test_job env: CACHE_NAME=test before_install: - go mod download @@ -54,14 +54,10 @@ test_job: &test_job -v -race ./... after_success: - travis_retry bash <(curl -s https://codecov.io/bash) -c -F go -test_i386_job: &test_i386_job +_test_i386_job: &test_i386_job env: CACHE_NAME=test386 language: bash services: docker - install: - # i386/golang:1.12-alpine doesn't have git. - - echo -e "FROM i386/golang:${GO_VERSION}-alpine\nRUN apk add --no-cache git" > Dockerfile - - docker build -t go-tester . script: - | docker run \ @@ -72,11 +68,11 @@ test_i386_job: &test_i386_job -v ${HOME}/gopath/pkg/mod:/go/pkg/mod \ -v ${HOME}/.cache/go-build:/.cache/go-build \ -w /go/src/github.com/pion/$(basename ${PWD}) \ - -it go-tester \ + -it i386/golang:${GO_VERSION}-alpine \ /usr/local/go/bin/go test \ -tags quic \ -v ./... -test_wasm_job: &test_wasm_job +_test_wasm_job: &test_wasm_job env: CACHE_NAME=wasm language: node_js node_js: 12 @@ -107,24 +103,26 @@ test_wasm_job: &test_wasm_job jobs: include: - <<: *lint_job - name: Lint 1.13 - go: 1.13 - - <<: *test_job - name: Test 1.12 - go: 1.12 + name: Lint 1.14 + go: 1.14 - <<: *test_job name: Test 1.13 go: 1.13 - - <<: *test_i386_job - name: Test i386 1.12 - env: GO_VERSION=1.12 + - <<: *test_job + name: Test 1.14 + go: 1.14 - <<: *test_i386_job name: Test i386 1.13 env: GO_VERSION=1.13 + - <<: *test_i386_job + name: Test i386 1.14 + env: GO_VERSION=1.14 - <<: *test_wasm_job name: Test WASM 1.13 - # Requires Go1.13 syscall/js env: GO_VERSION=1.13 + - <<: *test_wasm_job + name: Test WASM 1.14 + env: GO_VERSION=1.14 notifications: email: false diff --git a/codecov.yml b/codecov.yml index 4b72e53..5941e99 100644 --- a/codecov.yml +++ b/codecov.yml @@ -13,6 +13,7 @@ coverage: patch: default: target: 70% + only_pulls: true ignore: - "examples/*" From ebe4248d86abbc10239760e4d97da00af7fa20e6 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Thu, 30 Apr 2020 07:01:34 +0000 Subject: [PATCH 07/76] Update CI configs to v0.3.1 Update lint scripts and CI configs. --- .github/assert-contributors.sh | 17 ++++++--- .../lint-disallowed-functions-in-library.sh | 26 ++++++++++++- .travis.yml | 37 +++++++++++-------- 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/.github/assert-contributors.sh b/.github/assert-contributors.sh index 915f680..470d817 100755 --- a/.github/assert-contributors.sh +++ b/.github/assert-contributors.sh @@ -16,11 +16,16 @@ fi SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -EXCLUDED_CONTIBUTORS=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot') -MISSING_CONTIBUTORS=() +if [ -f ${SCRIPT_PATH}/.ci.conf ] +then + . ${SCRIPT_PATH}/.ci.conf +fi + +EXCLUDED_CONTRIBUTORS+=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot') +MISSING_CONTRIBUTORS=() shouldBeIncluded () { - for i in "${EXCLUDED_CONTIBUTORS[@]}" + for i in "${EXCLUDED_CONTRIBUTORS[@]}" do if [ "$i" == "$1" ] ; then return 1 @@ -35,15 +40,15 @@ for contributor in $(git log --format='%aN' | sort -u) do if shouldBeIncluded $contributor; then if ! grep -q "$contributor" "$SCRIPT_PATH/../README.md"; then - MISSING_CONTIBUTORS+=("$contributor") + MISSING_CONTRIBUTORS+=("$contributor") fi fi done unset IFS -if [ ${#MISSING_CONTIBUTORS[@]} -ne 0 ]; then +if [ ${#MISSING_CONTRIBUTORS[@]} -ne 0 ]; then echo "Please add the following contributors to the README" - for i in "${MISSING_CONTIBUTORS[@]}" + for i in "${MISSING_CONTRIBUTORS[@]}" do echo "$i" done diff --git a/.github/lint-disallowed-functions-in-library.sh b/.github/lint-disallowed-functions-in-library.sh index f5c9d87..6d5d55a 100755 --- a/.github/lint-disallowed-functions-in-library.sh +++ b/.github/lint-disallowed-functions-in-library.sh @@ -10,13 +10,35 @@ 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 ) -EXCLUDE_DIRECTORIES="--exclude-dir=examples --exclude-dir=.git --exclude-dir=.github " +if [ -f ${SCRIPT_PATH}/.ci.conf ] +then + . ${SCRIPT_PATH}/.ci.conf +fi + +EXCLUDE_DIRECTORIES=${DISALLOWED_FUNCTIONS_EXCLUDED_DIRECTORIES:-"examples"} DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(') +files=$( + find "$SCRIPT_PATH/.." -name "*.go" \ + | grep -v -e '^.*_test.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 +) for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}" do - if grep -R $EXCLUDE_DIRECTORIES -e "$disallowedFunction" "$SCRIPT_PATH/.." | grep -v -e '_test.go' -e 'nolint'; then + if grep -e "$disallowedFunction" $files | grep -v -e 'nolint'; then echo "$disallowedFunction may only be used in example code" exit 1 fi diff --git a/.travis.yml b/.travis.yml index e2bb205..e464e84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,11 +28,13 @@ cache: _lint_job: &lint_job env: CACHE_NAME=lint + before_install: + - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi + install: skip before_script: - | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \ | bash -s - -b $GOPATH/bin v${GOLANGCI_LINT_VERSION} - install: skip script: - bash .github/assert-contributors.sh - bash .github/lint-disallowed-functions-in-library.sh @@ -42,23 +44,28 @@ _lint_job: &lint_job _test_job: &test_job env: CACHE_NAME=test before_install: + - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - go mod download install: - go build ./... script: - - coverpkgs=$(go list ./... | grep -v examples | paste -s -d ',') + - testpkgs=${TEST_PACKAGES:-$(go list ./... | grep -v examples)} + - coverpkgs=$(echo "${testpkgs}" | paste -s -d ',') - | go test \ -coverpkg=${coverpkgs} -coverprofile=cover.out -covermode=atomic \ - -tags quic \ - -v -race ./... + ${TEST_EXTRA_ARGS:-} \ + -v -race ${testpkgs} + - if [ -n "${TEST_HOOK}" ]; then ${TEST_HOOK}; fi after_success: - travis_retry bash <(curl -s https://codecov.io/bash) -c -F go _test_i386_job: &test_i386_job env: CACHE_NAME=test386 - language: bash services: docker + before_install: + - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi script: + - testpkgs=${TEST_PACKAGES:-$(go list ./... | grep -v examples)} - | docker run \ -u $(id -u):$(id -g) \ @@ -70,12 +77,15 @@ _test_i386_job: &test_i386_job -w /go/src/github.com/pion/$(basename ${PWD}) \ -it i386/golang:${GO_VERSION}-alpine \ /usr/local/go/bin/go test \ - -tags quic \ - -v ./... + ${TEST_EXTRA_ARGS:-} \ + -v ${testpkgs} _test_wasm_job: &test_wasm_job env: CACHE_NAME=wasm language: node_js node_js: 12 + before_install: + - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi + - if ${SKIP_WASM_TEST:-false}; then exit 0; fi install: # Manually download and install Go instead of using gimme. # It looks like gimme Go causes some errors on go-test for Wasm. @@ -83,15 +93,10 @@ _test_wasm_job: &test_wasm_job - export GOROOT=${HOME}/go - export PATH=${GOROOT}/bin:${PATH} - yarn install - - export GO_JS_WASM_EXEC=${GOROOT}/misc/wasm/go_js_wasm_exec - # If the repository has wasm_exec hook, use it. - - | - if [ -f test-wasm/go_js_wasm_exec ]; then - export GO_JS_WASM_EXEC=${PWD}/test-wasm/go_js_wasm_exec - fi + - export GO_JS_WASM_EXEC=${GO_JS_WASM_EXEC:-${GOROOT}/misc/wasm/go_js_wasm_exec} script: - - testpkgs=$(go list ./... | grep -v examples) - - coverpkgs=$(go list ./... | grep -v examples | paste -s -d ',') + - testpkgs=${TEST_PACKAGES:-$(go list ./... | grep -v examples)} + - coverpkgs=$(echo "${testpkgs}" | paste -s -d ',') - | GOOS=js GOARCH=wasm go test \ -coverpkg=${coverpkgs} -coverprofile=cover.out -covermode=atomic \ @@ -114,9 +119,11 @@ jobs: - <<: *test_i386_job name: Test i386 1.13 env: GO_VERSION=1.13 + go: 1.14 # version for host environment used to go list - <<: *test_i386_job name: Test i386 1.14 env: GO_VERSION=1.14 + go: 1.14 # version for host environment used to go list - <<: *test_wasm_job name: Test WASM 1.13 env: GO_VERSION=1.13 From 6569cb47fede327ab88818bad87da55ca1fb63de Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 15 Jul 2020 04:25:29 +0000 Subject: [PATCH 08/76] Update CI configs to v0.3.3 Update lint scripts and CI configs. --- .github/assert-contributors.sh | 13 ++++++++++++- .github/install-hooks.sh | 5 ++++- .github/lint-commit-message.sh | 5 ++++- .github/lint-disallowed-functions-in-library.sh | 5 ++++- .github/lint-filename.sh | 5 ++++- .github/workflows/renovate-go-mod-fix.yaml | 5 ++++- .travis.yml | 15 +++++++++++---- codecov.yml | 2 +- 8 files changed, 44 insertions(+), 11 deletions(-) diff --git a/.github/assert-contributors.sh b/.github/assert-contributors.sh index 470d817..b0be2f7 100755 --- a/.github/assert-contributors.sh +++ b/.github/assert-contributors.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash # -# DO NOT EDIT THIS FILE DIRECTLY +# 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 @@ -21,7 +24,15 @@ then . ${SCRIPT_PATH}/.ci.conf fi +# +# DO NOT EDIT THIS +# EXCLUDED_CONTRIBUTORS+=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot') +# If you want to exclude a name from all repositories, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# If you want to exclude a name only from this repository, +# add EXCLUDED_CONTRIBUTORS=('name') to .github/.ci.conf + MISSING_CONTRIBUTORS=() shouldBeIncluded () { diff --git a/.github/install-hooks.sh b/.github/install-hooks.sh index 289bdbb..73d20a4 100755 --- a/.github/install-hooks.sh +++ b/.github/install-hooks.sh @@ -1,10 +1,13 @@ #!/bin/bash # -# DO NOT EDIT THIS FILE DIRECTLY +# 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. +# SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) diff --git a/.github/lint-commit-message.sh b/.github/lint-commit-message.sh index 1d1e808..7357c94 100755 --- a/.github/lint-commit-message.sh +++ b/.github/lint-commit-message.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash # -# DO NOT EDIT THIS FILE DIRECTLY +# 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 diff --git a/.github/lint-disallowed-functions-in-library.sh b/.github/lint-disallowed-functions-in-library.sh index 6d5d55a..21e48da 100755 --- a/.github/lint-disallowed-functions-in-library.sh +++ b/.github/lint-disallowed-functions-in-library.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash # -# DO NOT EDIT THIS FILE DIRECTLY +# 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 diff --git a/.github/lint-filename.sh b/.github/lint-filename.sh index 61134af..81b3f14 100755 --- a/.github/lint-filename.sh +++ b/.github/lint-filename.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash # -# DO NOT EDIT THIS FILE DIRECTLY +# 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 diff --git a/.github/workflows/renovate-go-mod-fix.yaml b/.github/workflows/renovate-go-mod-fix.yaml index 96cef4c..451fd7d 100644 --- a/.github/workflows/renovate-go-mod-fix.yaml +++ b/.github/workflows/renovate-go-mod-fix.yaml @@ -1,10 +1,13 @@ # -# DO NOT EDIT THIS FILE DIRECTLY +# DO NOT EDIT THIS FILE # # It is automatically copied from https://github.com/pion/.goassets repository. # If this repository should have package specific CI config, # remove the repository name from .goassets/.github/workflows/assets-sync.yml. # +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# name: go-mod-fix on: diff --git a/.travis.yml b/.travis.yml index e464e84..9bd21a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,13 @@ # -# DO NOT EDIT THIS FILE DIRECTLY +# DO NOT EDIT THIS FILE # # It is automatically copied from https://github.com/pion/.goassets repository. # If this repository should have package specific CI config, # remove the repository name from .goassets/.github/workflows/assets-sync.yml. # +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# dist: bionic language: go @@ -40,7 +43,7 @@ _lint_job: &lint_job - bash .github/lint-disallowed-functions-in-library.sh - bash .github/lint-commit-message.sh - bash .github/lint-filename.sh - - golangci-lint run ./... + - golangci-lint run ${GOLANGCI_LINT_EXRA_ARGS:-} ./... _test_job: &test_job env: CACHE_NAME=test before_install: @@ -49,6 +52,8 @@ _test_job: &test_job install: - go build ./... script: + # If you want to specify repository specific test packages rule, + # add `TEST_PACKAGES=$(command to list test target packages)` to .github/.ci.conf - testpkgs=${TEST_PACKAGES:-$(go list ./... | grep -v examples)} - coverpkgs=$(echo "${testpkgs}" | paste -s -d ',') - | @@ -119,11 +124,13 @@ jobs: - <<: *test_i386_job name: Test i386 1.13 env: GO_VERSION=1.13 - go: 1.14 # version for host environment used to go list + go: 1.14 # Go version for host environment only for `go list`. + # All tests are done on the version specified by GO_VERSION. - <<: *test_i386_job name: Test i386 1.14 env: GO_VERSION=1.14 - go: 1.14 # version for host environment used to go list + go: 1.14 # Go version for host environment only for `go list`. + # All tests are done on the version specified by GO_VERSION. - <<: *test_wasm_job name: Test WASM 1.13 env: GO_VERSION=1.13 diff --git a/codecov.yml b/codecov.yml index 5941e99..085200a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,5 +1,5 @@ # -# DO NOT EDIT THIS FILE DIRECTLY +# DO NOT EDIT THIS FILE # # It is automatically copied from https://github.com/pion/.goassets repository. # From 51ebba34475a672c24dd0e03a7da731177de6006 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 25 Aug 2020 00:30:27 +0000 Subject: [PATCH 09/76] Update CI configs to v0.3.4 Update lint scripts and CI configs. --- .github/workflows/tidy-check.yaml | 37 +++++++++++++++++++++++++++++++ .travis.yml | 28 +++++++++++------------ 2 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/tidy-check.yaml diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml new file mode 100644 index 0000000..03b5189 --- /dev/null +++ b/.github/workflows/tidy-check.yaml @@ -0,0 +1,37 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# + +name: Go mod tidy +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + Check: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: Setup Go + uses: actions/setup-go@v2 + - name: check + run: | + go mod download + go mod tidy + if ! git diff --exit-code + then + echo "Not go mod tidied" + exit 1 + fi diff --git a/.travis.yml b/.travis.yml index 9bd21a3..43eb708 100644 --- a/.travis.yml +++ b/.travis.yml @@ -113,30 +113,30 @@ _test_wasm_job: &test_wasm_job jobs: include: - <<: *lint_job - name: Lint 1.14 - go: 1.14 - - <<: *test_job - name: Test 1.13 - go: 1.13 + name: Lint 1.15 + go: 1.15 - <<: *test_job name: Test 1.14 go: 1.14 - - <<: *test_i386_job - name: Test i386 1.13 - env: GO_VERSION=1.13 - go: 1.14 # Go version for host environment only for `go list`. - # All tests are done on the version specified by GO_VERSION. + - <<: *test_job + name: Test 1.15 + go: 1.15 - <<: *test_i386_job name: Test i386 1.14 env: GO_VERSION=1.14 - go: 1.14 # Go version for host environment only for `go list`. + go: 1.15 # Go version for host environment only for `go list`. + # All tests are done on the version specified by GO_VERSION. + - <<: *test_i386_job + name: Test i386 1.15 + env: GO_VERSION=1.15 + go: 1.15 # Go version for host environment only for `go list`. # All tests are done on the version specified by GO_VERSION. - - <<: *test_wasm_job - name: Test WASM 1.13 - env: GO_VERSION=1.13 - <<: *test_wasm_job name: Test WASM 1.14 env: GO_VERSION=1.14 + - <<: *test_wasm_job + name: Test WASM 1.15 + env: GO_VERSION=1.15 notifications: email: false From d4070784e688362887910815b632c2e6e0cecb2c Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 9 Sep 2020 06:13:58 +0000 Subject: [PATCH 10/76] Update CI configs to v0.4.5 Update lint scripts and CI configs. --- .github/workflows/lint.yaml | 37 ++++++++++ .github/workflows/test.yaml | 132 +++++++++++++++++++++++++++++++++ .golangci.yml | 9 +-- .travis.yml | 142 ------------------------------------ 4 files changed, 171 insertions(+), 149 deletions(-) create mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/test.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..7c50107 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,37 @@ +name: Lint +on: + pull_request: + types: + - opened + - edited + - synchronize +jobs: + lint-commit-message: + name: Metadata + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Commit Message + run: .github/lint-commit-message.sh + + - name: File names + run: .github/lint-filename.sh + + - name: Contributors + run: .github/assert-contributors.sh + + - name: Functions + run: .github/lint-disallowed-functions-in-library.sh + + lint-go: + name: Go + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v1 + with: + version: v1.31 + args: $GOLANGCI_LINT_EXRA_ARGS diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..aec55b9 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,132 @@ +name: Test +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + go: ["1.14", "1.15"] + name: Go ${{ matrix.go }} + steps: + - uses: actions/checkout@v2 + + - name: Setup Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go }} + + - name: Set test packages + run: echo ::set-env name=TEST_PACKAGES::$(go list ./... | grep -v examples) + + - name: Run test + run: | + go test \ + -coverprofile=cover.out -covermode=atomic \ + ${TEST_EXTRA_ARGS:-} \ + -v -race ${TEST_PACKAGES} + + - uses: codecov/codecov-action@v1 + with: + file: ./cover.out + name: codecov-umbrella + fail_ci_if_error: true + flags: go + + test-i386: + runs-on: ubuntu-latest + strategy: + matrix: + go: ["1.14", "1.15"] + name: Go i386 ${{ matrix.go }} + steps: + - uses: actions/checkout@v2 + + - uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod + ~/.cache + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Set test packages + run: echo ::set-env name=TEST_PACKAGES::$(go list ./... | grep -v examples) + + - name: Run test + run: | + docker run \ + -u $(id -u):$(id -g) \ + -e "GO111MODULE=on" \ + -e "CGO_ENABLED=0" \ + -v $GITHUB_WORKSPACE:/go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \ + -v $HOME/go/pkg/mod:/go/pkg/mod \ + -v $HOME/.cache:/.cache \ + -w /go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \ + i386/golang:${{matrix.go}}-alpine \ + /usr/local/go/bin/go test \ + ${TEST_EXTRA_ARGS:-} \ + -v ${TEST_PACKAGES} + + test-wasm: + runs-on: ubuntu-latest + name: WASM + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod + ~/.cache + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Set test packages + run: echo ::set-env name=TEST_PACKAGES::$(go list ./... | grep -v examples) + + - name: Download Go + run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - + env: + GO_VERSION: 1.15 + + - name: Set Go Root + run: echo ::set-env name=GOROOT::${HOME}/go + + - name: Set Go Path + run: echo ::set-env name=GOPATH::${HOME}/go + + - name: Update Path + run: echo ::set-env name=PATH::${GOROOT}/bin:${PATH} + + - name: Set Go WASM Exec + run: echo ::set-env name=GO_JS_WASM_EXEC::${GOROOT}/misc/wasm/go_js_wasm_exec + + - name: Insall NPM modules + run: yarn install + + - name: Run Tests + run: | + GOOS=js GOARCH=wasm go test \ + -coverprofile=cover.out -covermode=atomic \ + -exec="${GO_JS_WASM_EXEC}" \ + -v ${TEST_PACKAGES} + + - uses: codecov/codecov-action@v1 + with: + file: ./cover.out + name: codecov-umbrella + fail_ci_if_error: true + flags: wasm diff --git a/.golangci.yml b/.golangci.yml index ffb0058..570f17b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,10 +4,5 @@ linters-settings: misspell: locale: US -linters: - enable-all: true - -issues: - exclude-use-default: false - max-per-linter: 0 - max-same-issues: 50 +run: + skip-dirs-use-default: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 43eb708..0000000 --- a/.travis.yml +++ /dev/null @@ -1,142 +0,0 @@ -# -# DO NOT EDIT THIS FILE -# -# It is automatically copied from https://github.com/pion/.goassets repository. -# If this repository should have package specific CI config, -# remove the repository name from .goassets/.github/workflows/assets-sync.yml. -# -# If you want to update the shared CI config, send a PR to -# https://github.com/pion/.goassets instead of this repository. -# - -dist: bionic -language: go - - -branches: - only: - - master - -env: - global: - - GO111MODULE=on - - GOLANGCI_LINT_VERSION=1.19.1 - -cache: - directories: - - ${HOME}/.cache/go-build - - ${GOPATH}/pkg/mod - npm: true - yarn: true - -_lint_job: &lint_job - env: CACHE_NAME=lint - before_install: - - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - install: skip - before_script: - - | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \ - | bash -s - -b $GOPATH/bin v${GOLANGCI_LINT_VERSION} - script: - - bash .github/assert-contributors.sh - - bash .github/lint-disallowed-functions-in-library.sh - - bash .github/lint-commit-message.sh - - bash .github/lint-filename.sh - - golangci-lint run ${GOLANGCI_LINT_EXRA_ARGS:-} ./... -_test_job: &test_job - env: CACHE_NAME=test - before_install: - - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - - go mod download - install: - - go build ./... - script: - # If you want to specify repository specific test packages rule, - # add `TEST_PACKAGES=$(command to list test target packages)` to .github/.ci.conf - - testpkgs=${TEST_PACKAGES:-$(go list ./... | grep -v examples)} - - coverpkgs=$(echo "${testpkgs}" | paste -s -d ',') - - | - go test \ - -coverpkg=${coverpkgs} -coverprofile=cover.out -covermode=atomic \ - ${TEST_EXTRA_ARGS:-} \ - -v -race ${testpkgs} - - if [ -n "${TEST_HOOK}" ]; then ${TEST_HOOK}; fi - after_success: - - travis_retry bash <(curl -s https://codecov.io/bash) -c -F go -_test_i386_job: &test_i386_job - env: CACHE_NAME=test386 - services: docker - before_install: - - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - script: - - testpkgs=${TEST_PACKAGES:-$(go list ./... | grep -v examples)} - - | - docker run \ - -u $(id -u):$(id -g) \ - -e "GO111MODULE=on" \ - -e "CGO_ENABLED=0" \ - -v ${PWD}:/go/src/github.com/pion/$(basename ${PWD}) \ - -v ${HOME}/gopath/pkg/mod:/go/pkg/mod \ - -v ${HOME}/.cache/go-build:/.cache/go-build \ - -w /go/src/github.com/pion/$(basename ${PWD}) \ - -it i386/golang:${GO_VERSION}-alpine \ - /usr/local/go/bin/go test \ - ${TEST_EXTRA_ARGS:-} \ - -v ${testpkgs} -_test_wasm_job: &test_wasm_job - env: CACHE_NAME=wasm - language: node_js - node_js: 12 - before_install: - - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - - if ${SKIP_WASM_TEST:-false}; then exit 0; fi - install: - # Manually download and install Go instead of using gimme. - # It looks like gimme Go causes some errors on go-test for Wasm. - - curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - - - export GOROOT=${HOME}/go - - export PATH=${GOROOT}/bin:${PATH} - - yarn install - - export GO_JS_WASM_EXEC=${GO_JS_WASM_EXEC:-${GOROOT}/misc/wasm/go_js_wasm_exec} - script: - - testpkgs=${TEST_PACKAGES:-$(go list ./... | grep -v examples)} - - coverpkgs=$(echo "${testpkgs}" | paste -s -d ',') - - | - GOOS=js GOARCH=wasm go test \ - -coverpkg=${coverpkgs} -coverprofile=cover.out -covermode=atomic \ - -exec="${GO_JS_WASM_EXEC}" \ - -v ${testpkgs} - after_success: - - travis_retry bash <(curl -s https://codecov.io/bash) -c -F wasm - -jobs: - include: - - <<: *lint_job - name: Lint 1.15 - go: 1.15 - - <<: *test_job - name: Test 1.14 - go: 1.14 - - <<: *test_job - name: Test 1.15 - go: 1.15 - - <<: *test_i386_job - name: Test i386 1.14 - env: GO_VERSION=1.14 - go: 1.15 # Go version for host environment only for `go list`. - # All tests are done on the version specified by GO_VERSION. - - <<: *test_i386_job - name: Test i386 1.15 - env: GO_VERSION=1.15 - go: 1.15 # Go version for host environment only for `go list`. - # All tests are done on the version specified by GO_VERSION. - - <<: *test_wasm_job - name: Test WASM 1.14 - env: GO_VERSION=1.14 - - <<: *test_wasm_job - name: Test WASM 1.15 - env: GO_VERSION=1.15 - -notifications: - email: false From 5ac2036d7221cb28d513831f9d06c5ed05d0488c Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 13 Sep 2020 20:25:20 +0000 Subject: [PATCH 11/76] Update CI configs to v0.4.6 Update lint scripts and CI configs. --- .github/workflows/renovate-go-mod-fix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/renovate-go-mod-fix.yaml b/.github/workflows/renovate-go-mod-fix.yaml index 451fd7d..46d2d04 100644 --- a/.github/workflows/renovate-go-mod-fix.yaml +++ b/.github/workflows/renovate-go-mod-fix.yaml @@ -28,6 +28,6 @@ jobs: with: git_user: Pion Bot git_email: 59523206+pionbot@users.noreply.github.com - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.PIONBOT_PRIVATE_KEY }} commit_style: squash push: force From d9c73ac36cb76a3e16ae220f012e55f7ad51aadb Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Thu, 17 Sep 2020 03:21:27 +0000 Subject: [PATCH 12/76] Update CI configs to v0.4.7 Update lint scripts and CI configs. --- .golangci.yml | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 570f17b..4213697 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,6 +3,80 @@ linters-settings: check-shadowing: true misspell: locale: US + exhaustive: + default-signifies-exhaustive: true + +linters: + enable: + - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers + - bodyclose # checks whether HTTP response body is closed successfully + - deadcode # Finds unused code + - depguard # Go linter that checks if package imports are in a list of acceptable packages + - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) + - dupl # Tool for code clone detection + - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases + - exhaustive # check exhaustiveness of enum switch statements + - exportloopref # checks for pointers to enclosing loop variables + - gci # Gci control golang package import order and make it always deterministic. + - gochecknoglobals # Checks that no globals are present in Go code + - gochecknoinits # Checks that no init functions are present in Go code + - gocognit # Computes and checks the cognitive complexity of functions + - goconst # Finds repeated strings that could be replaced by a constant + - gocritic # The most opinionated Go source code linter + - godox # Tool for detection of FIXME, TODO and other comment keywords + - goerr113 # Golang linter to check the errors handling expressions + - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification + - gofumpt # Gofumpt checks whether code was gofumpt-ed. + - goheader # Checks is file header matches to pattern + - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports + - golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes + - 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. + - goprintffuncname # Checks that printf-like functions are named with `f` at the end + - gosec # Inspects source code for security problems + - gosimple # Linter for Go source code that specializes in simplifying a code + - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string + - ineffassign # Detects when assignments to existing variables are not used + - misspell # Finds commonly misspelled English words in comments + - nakedret # Finds naked returns in functions greater than a specified function length + - noctx # noctx finds sending http request without context.Context + - scopelint # Scopelint checks for unpinned variables in go programs + - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks + - structcheck # Finds unused struct fields + - stylecheck # Stylecheck is a replacement for golint + - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code + - unconvert # Remove unnecessary type conversions + - unparam # Reports unused function parameters + - unused # Checks Go code for unused constants, variables, functions and types + - varcheck # Finds unused global variables and constants + - whitespace # Tool for detection of leading and trailing whitespace + disable: + - funlen # Tool for detection of long functions + - gocyclo # Computes and checks the cyclomatic complexity of functions + - godot # Check if comments end in a period + - gomnd # An analyzer to detect magic numbers. + - lll # Reports long lines + - maligned # Tool to detect Go structs that would take less memory if their fields were sorted + - nestif # Reports deeply nested if statements + - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity + - nolintlint # Reports ill-formed or insufficient nolint directives + - prealloc # Finds slice declarations that could potentially be preallocated + - rowserrcheck # checks whether Err of rows is checked successfully + - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. + - testpackage # linter that makes you use a separate _test package + - wsl # Whitespace Linter - Forces you to use empty lines! + +issues: + exclude-rules: + # Allow complex tests, better to be self contained + - path: _test\.go + linters: + - gocognit + + # Allow complex main function in examples + - path: examples + text: "of func `main` is high" + linters: + - gocognit run: skip-dirs-use-default: false From 3231fc7f36f380db5b9c149eb7be86f2df95b547 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Mon, 5 Oct 2020 01:00:17 +0000 Subject: [PATCH 13/76] Update CI configs to v0.4.8 Update lint scripts and CI configs. --- .golangci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 4213697..8e4185a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,12 @@ linters-settings: locale: US exhaustive: default-signifies-exhaustive: true + gomodguard: + blocked: + modules: + - github.com/pkg/errors: + recommendations: + - errors linters: enable: From 051d147adec84fbfbf93aa34351c8ee9f9cbd931 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sat, 24 Oct 2020 04:45:26 +0000 Subject: [PATCH 14/76] Update CI configs to v0.4.9 Update lint scripts and CI configs. --- .github/workflows/lint.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7c50107..a3f6ab2 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v2 - name: golangci-lint - uses: golangci/golangci-lint-action@v1 + uses: golangci/golangci-lint-action@v2 with: version: v1.31 args: $GOLANGCI_LINT_EXRA_ARGS diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index aec55b9..11c3f9f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: ${{ matrix.go }} From 8a6cf634f126bd55b7e74f5bc48d73cdf222d6f9 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 30 Oct 2020 04:13:03 +0000 Subject: [PATCH 15/76] Update CI configs to v0.4.10 Update lint scripts and CI configs. --- .github/assert-contributors.sh | 6 ------ .github/lint-commit-message.sh | 8 +------- .github/workflows/lint.yaml | 2 ++ 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/assert-contributors.sh b/.github/assert-contributors.sh index b0be2f7..12e6afe 100755 --- a/.github/assert-contributors.sh +++ b/.github/assert-contributors.sh @@ -11,12 +11,6 @@ set -e -# Unshallow the repo, this check doesn't work with this enabled -# https://github.com/travis-ci/travis-ci/issues/3412 -if [ -f $(git rev-parse --git-dir)/shallow ]; then - git fetch --unshallow || true -fi - SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) if [ -f ${SCRIPT_PATH}/.ci.conf ] diff --git a/.github/lint-commit-message.sh b/.github/lint-commit-message.sh index 7357c94..010a332 100755 --- a/.github/lint-commit-message.sh +++ b/.github/lint-commit-message.sh @@ -58,13 +58,7 @@ if [ "$#" -eq 1 ]; then fi lint_commit_message "$(sed -n '/# Please enter the commit message for your changes. Lines starting/q;p' "$1")" else - # TRAVIS_COMMIT_RANGE is empty for initial branch commit - if [[ "${TRAVIS_COMMIT_RANGE}" != *"..."* ]]; then - parent=$(git log -n 1 --format="%P" ${TRAVIS_COMMIT_RANGE}) - TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE}...$parent" - fi - - for commit in $(git rev-list ${TRAVIS_COMMIT_RANGE}); do + for commit in $(git rev-list --no-merges origin/master..); do lint_commit_message "$(git log --format="%B" -n 1 $commit)" done fi diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index a3f6ab2..4f365e3 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -11,6 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Commit Message run: .github/lint-commit-message.sh From b734f6ca5d850f8064277cc2cf6d8d4f5cacfb84 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 6 Nov 2020 19:53:51 +0000 Subject: [PATCH 16/76] Update CI configs to v0.4.12 Update lint scripts and CI configs. --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index 8e4185a..d6162c9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -72,6 +72,7 @@ linters: - wsl # Whitespace Linter - Forces you to use empty lines! issues: + exclude-use-default: false exclude-rules: # Allow complex tests, better to be self contained - path: _test\.go From c75a2659abdbcb9a5605215bf11780685a8f4a74 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sat, 14 Nov 2020 21:25:04 +0000 Subject: [PATCH 17/76] Update CI configs to v0.4.13 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 11c3f9f..a068bab 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -28,6 +28,7 @@ jobs: run: | go test \ -coverprofile=cover.out -covermode=atomic \ + -bench=. \ ${TEST_EXTRA_ARGS:-} \ -v -race ${TEST_PACKAGES} From aabfe565ba188a3c845ddccd78f91d23fee7e185 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Mon, 16 Nov 2020 18:51:40 +0000 Subject: [PATCH 18/76] Update CI configs to v0.4.14 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a068bab..6a4cea2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,7 +22,7 @@ jobs: go-version: ${{ matrix.go }} - name: Set test packages - run: echo ::set-env name=TEST_PACKAGES::$(go list ./... | grep -v examples) + run: echo "TEST_PACKAGES=$(go list ./... | grep -v examples)" >> $GITHUB_ENV - name: Run test run: | @@ -58,7 +58,7 @@ jobs: ${{ runner.os }}-go- - name: Set test packages - run: echo ::set-env name=TEST_PACKAGES::$(go list ./... | grep -v examples) + run: echo "TEST_PACKAGES=$(go list ./... | grep -v examples)" >> $GITHUB_ENV - name: Run test run: | @@ -96,7 +96,7 @@ jobs: ${{ runner.os }}-go- - name: Set test packages - run: echo ::set-env name=TEST_PACKAGES::$(go list ./... | grep -v examples) + run: echo "TEST_PACKAGES=$(go list ./... | grep -v examples)" >> $GITHUB_ENV - name: Download Go run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - @@ -104,23 +104,20 @@ jobs: GO_VERSION: 1.15 - name: Set Go Root - run: echo ::set-env name=GOROOT::${HOME}/go + run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV - name: Set Go Path - run: echo ::set-env name=GOPATH::${HOME}/go + run: echo "GOPATH=${HOME}/go" >> $GITHUB_ENV - - name: Update Path - run: echo ::set-env name=PATH::${GOROOT}/bin:${PATH} - - - name: Set Go WASM Exec - run: echo ::set-env name=GO_JS_WASM_EXEC::${GOROOT}/misc/wasm/go_js_wasm_exec + - name: Set Go Path + run: echo "GO_JS_WASM_EXEC=${GOROOT}/misc/wasm/go_js_wasm_exec" >> $GITHUB_ENV - name: Insall NPM modules run: yarn install - name: Run Tests run: | - GOOS=js GOARCH=wasm go test \ + GOOS=js GOARCH=wasm $GOPATH/bin/go test \ -coverprofile=cover.out -covermode=atomic \ -exec="${GO_JS_WASM_EXEC}" \ -v ${TEST_PACKAGES} From 3ae4d5518280c8ae7500912f6da1ecdaab45ed4b Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Mon, 16 Nov 2020 19:27:13 +0000 Subject: [PATCH 19/76] Update CI configs to v0.4.15 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6a4cea2..5aae7de 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,16 +21,13 @@ jobs: with: go-version: ${{ matrix.go }} - - name: Set test packages - run: echo "TEST_PACKAGES=$(go list ./... | grep -v examples)" >> $GITHUB_ENV - - name: Run test run: | go test \ -coverprofile=cover.out -covermode=atomic \ -bench=. \ ${TEST_EXTRA_ARGS:-} \ - -v -race ${TEST_PACKAGES} + -v -race ./... - uses: codecov/codecov-action@v1 with: @@ -57,9 +54,6 @@ jobs: restore-keys: | ${{ runner.os }}-go- - - name: Set test packages - run: echo "TEST_PACKAGES=$(go list ./... | grep -v examples)" >> $GITHUB_ENV - - name: Run test run: | docker run \ @@ -73,7 +67,7 @@ jobs: i386/golang:${{matrix.go}}-alpine \ /usr/local/go/bin/go test \ ${TEST_EXTRA_ARGS:-} \ - -v ${TEST_PACKAGES} + -v ./... test-wasm: runs-on: ubuntu-latest @@ -95,9 +89,6 @@ jobs: restore-keys: | ${{ runner.os }}-go- - - name: Set test packages - run: echo "TEST_PACKAGES=$(go list ./... | grep -v examples)" >> $GITHUB_ENV - - name: Download Go run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - env: @@ -120,7 +111,7 @@ jobs: GOOS=js GOARCH=wasm $GOPATH/bin/go test \ -coverprofile=cover.out -covermode=atomic \ -exec="${GO_JS_WASM_EXEC}" \ - -v ${TEST_PACKAGES} + -v ./... - uses: codecov/codecov-action@v1 with: From 1777ea717432d42adea8a97d3739588095bdd179 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sat, 28 Nov 2020 23:52:11 +0000 Subject: [PATCH 20/76] Update CI configs to v0.4.17 Update lint scripts and CI configs. --- .github/workflows/lint.yaml | 4 ++++ .github/workflows/test.yaml | 22 ++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4f365e3..8824c34 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -9,6 +9,8 @@ jobs: lint-commit-message: name: Metadata runs-on: ubuntu-latest + strategy: + fail-fast: false steps: - uses: actions/checkout@v2 with: @@ -29,6 +31,8 @@ jobs: lint-go: name: Go runs-on: ubuntu-latest + strategy: + fail-fast: false steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5aae7de..3f29fce 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,10 +12,20 @@ jobs: strategy: matrix: go: ["1.14", "1.15"] + fail-fast: false name: Go ${{ matrix.go }} steps: - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod + ~/.cache + key: ${{ runner.os }}-amd64-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-amd64-go- + - name: Setup Go uses: actions/setup-go@v2 with: @@ -41,6 +51,7 @@ jobs: strategy: matrix: go: ["1.14", "1.15"] + fail-fast: false name: Go i386 ${{ matrix.go }} steps: - uses: actions/checkout@v2 @@ -50,12 +61,13 @@ jobs: path: | ~/go/pkg/mod ~/.cache - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-i386-go-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + ${{ runner.os }}-i386-go- - name: Run test run: | + mkdir -p $HOME/go/pkg/mod $HOME/.cache docker run \ -u $(id -u):$(id -g) \ -e "GO111MODULE=on" \ @@ -71,6 +83,8 @@ jobs: test-wasm: runs-on: ubuntu-latest + strategy: + fail-fast: false name: WASM steps: - uses: actions/checkout@v2 @@ -85,9 +99,9 @@ jobs: path: | ~/go/pkg/mod ~/.cache - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-wasm-go-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + ${{ runner.os }}-wasm-go- - name: Download Go run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - From 40a023361afa1151fa23abd0352cf1190ad90d16 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 29 Nov 2020 18:57:54 +0000 Subject: [PATCH 21/76] Update CI configs to v0.4.18 Update lint scripts and CI configs. --- .gitignore | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..83db74b --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +### JetBrains IDE ### +##################### +.idea/ + +### Emacs Temporary Files ### +############################# +*~ + +### Folders ### +############### +bin/ +vendor/ +node_modules/ + +### Files ### +############# +*.ivf +*.ogg +tags +cover.out +*.sw[poe] +*.wasm +examples/sfu-ws/cert.pem +examples/sfu-ws/key.pem From f86d3277e5bc6376c4331ba848b332086e53f06e Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 16 Dec 2020 16:29:16 +0000 Subject: [PATCH 22/76] Update CI configs to v0.4.19 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3f29fce..95e3ba0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -90,7 +90,7 @@ jobs: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12.x' From ed5ad6d9793a12e81461ab14a5812bf679a36d19 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Thu, 28 Jan 2021 22:03:49 +0000 Subject: [PATCH 23/76] Update CI configs to v0.4.20 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 95e3ba0..b2a6b39 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,6 +21,7 @@ jobs: with: path: | ~/go/pkg/mod + ~/go/bin ~/.cache key: ${{ runner.os }}-amd64-go-${{ hashFiles('**/go.sum') }} restore-keys: | @@ -31,13 +32,15 @@ jobs: with: go-version: ${{ matrix.go }} + - name: Setup go-acc + run: | + go get -u github.com/ory/go-acc + - name: Run test run: | - go test \ - -coverprofile=cover.out -covermode=atomic \ + go-acc -o cover.out ./... -- \ -bench=. \ - ${TEST_EXTRA_ARGS:-} \ - -v -race ./... + -v -race - uses: codecov/codecov-action@v1 with: From 0b6cf40a443b27f796988d18c84bf0a59f8942b1 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 21 Mar 2021 05:14:31 +0000 Subject: [PATCH 24/76] Update CI configs to v0.4.21 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b2a6b39..889a144 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.14", "1.15"] + go: ["1.15", "1.16"] fail-fast: false name: Go ${{ matrix.go }} steps: @@ -53,7 +53,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.14", "1.15"] + go: ["1.15", "1.16"] fail-fast: false name: Go i386 ${{ matrix.go }} steps: @@ -109,7 +109,7 @@ jobs: - name: Download Go run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - env: - GO_VERSION: 1.15 + GO_VERSION: 1.16 - name: Set Go Root run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV From 37cdd8d67a3736a379b711456a7c4ead0bcee371 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Mon, 22 Mar 2021 04:43:58 +0000 Subject: [PATCH 25/76] Update CI configs to v0.4.22 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 3 ++- renovate.json | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 889a144..5b7a43b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -34,7 +34,8 @@ jobs: - name: Setup go-acc run: | - go get -u github.com/ory/go-acc + go get github.com/ory/go-acc + git checkout go.mod go.sum - name: Run test run: | diff --git a/renovate.json b/renovate.json index 4400fd9..f84608c 100644 --- a/renovate.json +++ b/renovate.json @@ -7,6 +7,10 @@ ], "commitBody": "Generated by renovateBot", "packageRules": [ + { + "matchUpdateTypes": ["minor", "patch", "pin", "digest"], + "automerge": true + }, { "packagePatterns": ["^golang.org/x/"], "schedule": ["on the first day of the month"] From 3aa5c12fda3860d2d1645f0e6e381ab80cd0d80c Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 20 Apr 2021 23:04:03 +0000 Subject: [PATCH 26/76] Update CI configs to v0.4.24 Update lint scripts and CI configs. --- .github/lint-disallowed-functions-in-library.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/lint-disallowed-functions-in-library.sh b/.github/lint-disallowed-functions-in-library.sh index 21e48da..8ce5d09 100755 --- a/.github/lint-disallowed-functions-in-library.sh +++ b/.github/lint-disallowed-functions-in-library.sh @@ -19,7 +19,7 @@ then fi EXCLUDE_DIRECTORIES=${DISALLOWED_FUNCTIONS_EXCLUDED_DIRECTORIES:-"examples"} -DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(') +DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(' 'print(' 'println(') files=$( find "$SCRIPT_PATH/.." -name "*.go" \ @@ -41,7 +41,7 @@ files=$( for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}" do - if grep -e "$disallowedFunction" $files | grep -v -e 'nolint'; then + if grep -e "\s$disallowedFunction" $files | grep -v -e 'nolint'; then echo "$disallowedFunction may only be used in example code" exit 1 fi From 911b5650914f1a2dc7ac72f45ec0644bf1ffba47 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 2 Jul 2021 02:16:45 +0000 Subject: [PATCH 27/76] Update CI configs to v0.5.4 Update lint scripts and CI configs. --- ...rt-contributors.sh => generate-authors.sh} | 29 ++++++----- .github/hooks/pre-push.sh | 2 +- .github/workflows/generate-authors.yml | 48 +++++++++++++++++++ .github/workflows/lint.yaml | 3 -- AUTHORS.txt | 12 +++++ README.md | 9 ---- 6 files changed, 78 insertions(+), 25 deletions(-) rename .github/{assert-contributors.sh => generate-authors.sh} (58%) create mode 100644 .github/workflows/generate-authors.yml create mode 100644 AUTHORS.txt diff --git a/.github/assert-contributors.sh b/.github/generate-authors.sh similarity index 58% rename from .github/assert-contributors.sh rename to .github/generate-authors.sh index 12e6afe..182e4f5 100755 --- a/.github/assert-contributors.sh +++ b/.github/generate-authors.sh @@ -12,6 +12,7 @@ set -e SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +AUTHORS_PATH="$GITHUB_WORKSPACE/AUTHORS.txt" if [ -f ${SCRIPT_PATH}/.ci.conf ] then @@ -21,18 +22,18 @@ fi # # DO NOT EDIT THIS # -EXCLUDED_CONTRIBUTORS+=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot') +EXCLUDED_CONTRIBUTORS+=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot' 'pionbot') # If you want to exclude a name from all repositories, send a PR to # https://github.com/pion/.goassets instead of this repository. # If you want to exclude a name only from this repository, # add EXCLUDED_CONTRIBUTORS=('name') to .github/.ci.conf -MISSING_CONTRIBUTORS=() +CONTRIBUTORS=() shouldBeIncluded () { for i in "${EXCLUDED_CONTRIBUTORS[@]}" do - if [ "$i" == "$1" ] ; then + if [[ $1 =~ "$i" ]]; then return 1 fi done @@ -41,21 +42,25 @@ shouldBeIncluded () { IFS=$'\n' #Only split on newline -for contributor in $(git log --format='%aN' | sort -u) +for contributor in $(git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf) do if shouldBeIncluded $contributor; then - if ! grep -q "$contributor" "$SCRIPT_PATH/../README.md"; then - MISSING_CONTRIBUTORS+=("$contributor") - fi + CONTRIBUTORS+=("$contributor") fi done unset IFS -if [ ${#MISSING_CONTRIBUTORS[@]} -ne 0 ]; then - echo "Please add the following contributors to the README" - for i in "${MISSING_CONTRIBUTORS[@]}" +if [ ${#CONTRIBUTORS[@]} -ne 0 ]; then + cat >$AUTHORS_PATH <<-'EOH' +# Thank you to everyone that made Pion possible. If you are interested in contributing +# we would love to have you https://github.com/pion/webrtc/wiki/Contributing +# +# This file is auto generated, using git to list all individuals contributors. +# see `.github/generate-authors.sh` for the scripting +EOH + for i in "${CONTRIBUTORS[@]}" do - echo "$i" + echo "$i" >> $AUTHORS_PATH done - exit 1 + exit 0 fi diff --git a/.github/hooks/pre-push.sh b/.github/hooks/pre-push.sh index 7cb2365..bfe65bc 100755 --- a/.github/hooks/pre-push.sh +++ b/.github/hooks/pre-push.sh @@ -8,6 +8,6 @@ set -e -.github/assert-contributors.sh +.github/generate-authors.sh exit 0 diff --git a/.github/workflows/generate-authors.yml b/.github/workflows/generate-authors.yml new file mode 100644 index 0000000..a0a7478 --- /dev/null +++ b/.github/workflows/generate-authors.yml @@ -0,0 +1,48 @@ +name: generate-authors + +on: + pull_request: + +jobs: + generate-authors: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + token: ${{ secrets.PIONBOT_PRIVATE_KEY }} + + - name: Generate the authors file + run: .github/generate-authors.sh + + - name: Add the authors file to git + run: git add AUTHORS.txt + + - name: Get last commit message + id: last-commit-message + run: | + COMMIT_MSG=$(git log -1 --pretty=%B) + COMMIT_MSG="${COMMIT_MSG//'%'/'%25'}" + COMMIT_MSG="${COMMIT_MSG//$'\n'/'%0A'}" + COMMIT_MSG="${COMMIT_MSG//$'\r'/'%0D'}" + echo "::set-output name=msg::$COMMIT_MSG" + + - name: Get last commit author + id: last-commit-author + run: | + echo "::set-output name=msg::$(git log -1 --pretty='%aN <%ae>')" + + - name: Check if AUTHORS.txt file has changed + id: git-status-output + run: | + echo "::set-output name=msg::$(git status -s | wc -l)" + + - uses: stefanzweifel/git-auto-commit-action@v4 + if: ${{ steps.git-status-output.outputs.msg != '0' }} + with: + commit_message: ${{ steps.last-commit-message.outputs.msg }} + commit_author: ${{ steps.last-commit-author.outputs.msg }} + commit_options: '--amend --no-edit' + push_options: '--force' + skip_fetch: true diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 8824c34..bc44c3a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,9 +22,6 @@ jobs: - name: File names run: .github/lint-filename.sh - - name: Contributors - run: .github/assert-contributors.sh - - name: Functions run: .github/lint-disallowed-functions-in-library.sh diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 0000000..bdaf3ba --- /dev/null +++ b/AUTHORS.txt @@ -0,0 +1,12 @@ +# Thank you to everyone that made Pion possible. If you are interested in contributing +# we would love to have you https://github.com/pion/webrtc/wiki/Contributing +# +# This file is auto generated, using git to list all individuals contributors. +# see `.github/generate-authors.sh` for the scripting +Atsushi Watanabe +backkem +Hugo Arregui +Michael MacDonald +Okamoto +Sean DuBois +Woodrow Douglass diff --git a/README.md b/README.md index f7398a1..4009036 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,5 @@ If you need commercial support or don't want to use public methods you can conta ### Contributing Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contributing)** to join the group of amazing people making this project possible: -* [John Bradley](https://github.com/kc5nra) - *Original Author* -* [Sean DuBois](https://github.com/Sean-Der) - *Original Author* -* [Michael MacDonald](https://github.com/mjmac) - *Original Author* -* [Woodrow Douglass](https://github.com/wdouglass) - *Test coverage* -* [Michiel De Backker](https://github.com/backkem) - *Docs* -* [Hugo Arregui](https://github.com/hugoArregui) - *Custom Logs* -* [Justin Okamoto](https://github.com/justinokamoto) - *Disabled Logs Update* -* [Atsushi Watanabe](https://github.com/at-wat) - *Fix/update CI* - ### License MIT License - see [LICENSE](LICENSE) for full text From d572b72819b807bba0932da499c793377b6244b7 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 13 Jul 2021 19:53:26 +0000 Subject: [PATCH 28/76] Update CI configs to v0.5.6 Update lint scripts and CI configs. --- .github/workflows/generate-authors.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/generate-authors.yml b/.github/workflows/generate-authors.yml index a0a7478..e619025 100644 --- a/.github/workflows/generate-authors.yml +++ b/.github/workflows/generate-authors.yml @@ -4,7 +4,21 @@ on: pull_request: jobs: + checksecret: + runs-on: ubuntu-latest + outputs: + is_PIONBOT_PRIVATE_KEY_set: ${{ steps.checksecret_job.outputs.is_PIONBOT_PRIVATE_KEY_set }} + steps: + - id: checksecret_job + env: + PIONBOT_PRIVATE_KEY: ${{ secrets.PIONBOT_PRIVATE_KEY }} + run: | + echo "is_PIONBOT_PRIVATE_KEY_set: ${{ env.PIONBOT_PRIVATE_KEY != '' }}" + echo "::set-output name=is_PIONBOT_PRIVATE_KEY_set::${{ env.PIONBOT_PRIVATE_KEY != '' }}" + generate-authors: + needs: [checksecret] + if: needs.checksecret.outputs.is_PIONBOT_PRIVATE_KEY_set == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From b0e968691909fdc8f198d1be221624b74b397fa6 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 21 Jul 2021 00:26:24 +0000 Subject: [PATCH 29/76] Update CI configs to v0.5.9 Update lint scripts and CI configs. --- .github/workflows/generate-authors.yml | 25 +++++++++---- .github/workflows/lint.yaml | 11 ++++++ .github/workflows/test.yaml | 52 ++++++++++++++++++-------- renovate.json | 7 ++++ 4 files changed, 72 insertions(+), 23 deletions(-) diff --git a/.github/workflows/generate-authors.yml b/.github/workflows/generate-authors.yml index e619025..83e7065 100644 --- a/.github/workflows/generate-authors.yml +++ b/.github/workflows/generate-authors.yml @@ -1,3 +1,14 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# + name: generate-authors on: @@ -52,11 +63,11 @@ jobs: run: | echo "::set-output name=msg::$(git status -s | wc -l)" - - uses: stefanzweifel/git-auto-commit-action@v4 + - name: Commit and push if: ${{ steps.git-status-output.outputs.msg != '0' }} - with: - commit_message: ${{ steps.last-commit-message.outputs.msg }} - commit_author: ${{ steps.last-commit-author.outputs.msg }} - commit_options: '--amend --no-edit' - push_options: '--force' - skip_fetch: true + run: | + git config user.email $(echo "${{ steps.last-commit-author.outputs.msg }}" | sed 's/\(.\+\) <\(\S\+\)>/\2/') + git config user.name $(echo "${{ steps.last-commit-author.outputs.msg }}" | sed 's/\(.\+\) <\(\S\+\)>/\1/') + git add AUTHORS.txt + git commit --amend --no-edit + git push --force https://github.com/${GITHUB_REPOSITORY} $(git symbolic-ref -q --short HEAD) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index bc44c3a..f096078 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,3 +1,14 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# + name: Lint on: pull_request: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5b7a43b..7a72c2c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,3 +1,14 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# + name: Test on: push: @@ -39,9 +50,17 @@ jobs: - name: Run test run: | + TEST_BENCH_OPTION="-bench=." + if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi + go-acc -o cover.out ./... -- \ - -bench=. \ - -v -race + ${TEST_BENCH_OPTION} \ + -v -race + + - name: Run TEST_HOOK + run: | + if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi + if [ -n "${TEST_HOOK}" ]; then ${TEST_HOOK}; fi - uses: codecov/codecov-action@v1 with: @@ -73,17 +92,17 @@ jobs: run: | mkdir -p $HOME/go/pkg/mod $HOME/.cache docker run \ - -u $(id -u):$(id -g) \ - -e "GO111MODULE=on" \ - -e "CGO_ENABLED=0" \ - -v $GITHUB_WORKSPACE:/go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \ - -v $HOME/go/pkg/mod:/go/pkg/mod \ - -v $HOME/.cache:/.cache \ - -w /go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \ - i386/golang:${{matrix.go}}-alpine \ - /usr/local/go/bin/go test \ - ${TEST_EXTRA_ARGS:-} \ - -v ./... + -u $(id -u):$(id -g) \ + -e "GO111MODULE=on" \ + -e "CGO_ENABLED=0" \ + -v $GITHUB_WORKSPACE:/go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \ + -v $HOME/go/pkg/mod:/go/pkg/mod \ + -v $HOME/.cache:/.cache \ + -w /go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \ + i386/golang:${{matrix.go}}-alpine \ + /usr/local/go/bin/go test \ + ${TEST_EXTRA_ARGS:-} \ + -v ./... test-wasm: runs-on: ubuntu-latest @@ -126,10 +145,11 @@ jobs: - name: Run Tests run: | + if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi GOOS=js GOARCH=wasm $GOPATH/bin/go test \ - -coverprofile=cover.out -covermode=atomic \ - -exec="${GO_JS_WASM_EXEC}" \ - -v ./... + -coverprofile=cover.out -covermode=atomic \ + -exec="${GO_JS_WASM_EXEC}" \ + -v ./... - uses: codecov/codecov-action@v1 with: diff --git a/renovate.json b/renovate.json index f84608c..08c1e39 100644 --- a/renovate.json +++ b/renovate.json @@ -15,5 +15,12 @@ "packagePatterns": ["^golang.org/x/"], "schedule": ["on the first day of the month"] } + ], + "ignorePaths": [ + ".github/workflows/generate-authors.yml", + ".github/workflows/lint.yaml", + ".github/workflows/renovate-go-mod-fix.yaml", + ".github/workflows/test.yaml", + ".github/workflows/tidy-check.yaml" ] } From 41207f25a795a760cbc4bc91d3518dd98c45c9b0 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 16 Nov 2021 03:08:53 +0000 Subject: [PATCH 30/76] Update CI configs to v0.6.0 Update lint scripts and CI configs. --- renovate.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 08c1e39..f161405 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,7 @@ { "extends": [ - "config:base" + "config:base", + ":disableDependencyDashboard" ], "postUpdateOptions": [ "gomodTidy" From cce6434b558f5b0469e9f1c203e313111853c99b Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 28 Nov 2021 18:42:55 +0000 Subject: [PATCH 31/76] Update CI configs to v0.6.2 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7a72c2c..8affe32 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.15", "1.16"] + go: ["1.16", "1.17"] fail-fast: false name: Go ${{ matrix.go }} steps: @@ -73,7 +73,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.15", "1.16"] + go: ["1.16", "1.17"] fail-fast: false name: Go i386 ${{ matrix.go }} steps: From 7f68dfebb86eacae9315b5450d84c1f71488a345 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 19 Dec 2021 17:16:25 +0000 Subject: [PATCH 32/76] Update CI configs to v0.6.4 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8affe32..9f6ef84 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -62,7 +62,7 @@ jobs: if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi if [ -n "${TEST_HOOK}" ]; then ${TEST_HOOK}; fi - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v2 with: file: ./cover.out name: codecov-umbrella @@ -151,7 +151,7 @@ jobs: -exec="${GO_JS_WASM_EXEC}" \ -v ./... - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v2 with: file: ./cover.out name: codecov-umbrella From 1255034101be5d6d7bdacf4a08020a0ac6d34815 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 6 Feb 2022 18:18:14 +0000 Subject: [PATCH 33/76] Update CI configs to v0.6.6 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9f6ef84..43608f1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -115,7 +115,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v2 with: - node-version: '12.x' + node-version: '16.x' - uses: actions/cache@v2 with: @@ -129,7 +129,7 @@ jobs: - name: Download Go run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - env: - GO_VERSION: 1.16 + GO_VERSION: 1.17 - name: Set Go Root run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV From 21f382b0b86d36b9d554c18b45d13b18a0edc838 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 27 Feb 2022 00:14:59 +0000 Subject: [PATCH 34/76] Update CI configs to v0.6.7 Update lint scripts and CI configs. --- .github/workflows/lint.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index f096078..e72f62d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -45,7 +45,7 @@ jobs: - uses: actions/checkout@v2 - name: golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: version: v1.31 args: $GOLANGCI_LINT_EXRA_ARGS diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 43608f1..9081655 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -113,7 +113,7 @@ jobs: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: '16.x' From a78addf8958d983b85c034e6be11cfd6019e106c Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 2 Mar 2022 18:48:42 +0000 Subject: [PATCH 35/76] Update CI configs to v0.6.8 Update lint scripts and CI configs. --- .github/workflows/generate-authors.yml | 2 +- .github/workflows/lint.yaml | 4 ++-- .github/workflows/renovate-go-mod-fix.yaml | 2 +- .github/workflows/test.yaml | 8 ++++---- .github/workflows/tidy-check.yaml | 4 ++-- .gitignore | 1 + 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/generate-authors.yml b/.github/workflows/generate-authors.yml index 83e7065..9a80a48 100644 --- a/.github/workflows/generate-authors.yml +++ b/.github/workflows/generate-authors.yml @@ -32,7 +32,7 @@ jobs: if: needs.checksecret.outputs.is_PIONBOT_PRIVATE_KEY_set == 'true' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} fetch-depth: 0 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e72f62d..438443f 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -23,7 +23,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 @@ -42,7 +42,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/.github/workflows/renovate-go-mod-fix.yaml b/.github/workflows/renovate-go-mod-fix.yaml index 46d2d04..5991822 100644 --- a/.github/workflows/renovate-go-mod-fix.yaml +++ b/.github/workflows/renovate-go-mod-fix.yaml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 2 - name: fix diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9081655..cd788c9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,7 +26,7 @@ jobs: fail-fast: false name: Go ${{ matrix.go }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: @@ -39,7 +39,7 @@ jobs: ${{ runner.os }}-amd64-go- - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: ${{ matrix.go }} @@ -77,7 +77,7 @@ jobs: fail-fast: false name: Go i386 ${{ matrix.go }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/cache@v2 with: @@ -110,7 +110,7 @@ jobs: fail-fast: false name: WASM steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index 03b5189..3ab2c35 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -23,9 +23,9 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 - name: check run: | go mod download diff --git a/.gitignore b/.gitignore index 83db74b..f977e74 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ cover.out *.wasm examples/sfu-ws/cert.pem examples/sfu-ws/key.pem +wasm_exec.js From d1f23a75dd252da9d94dd086ea645943d139a28a Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Mon, 21 Mar 2022 17:11:55 +0000 Subject: [PATCH 36/76] Update CI configs to v0.6.9 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cd788c9..0d01db5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/go/pkg/mod @@ -79,7 +79,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/go/pkg/mod @@ -117,7 +117,7 @@ jobs: with: node-version: '16.x' - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/go/pkg/mod From 1c9d1bc6a97365fe1eeab98cddf157a0de92b556 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Mon, 11 Apr 2022 03:31:32 +0000 Subject: [PATCH 37/76] Update CI configs to v0.6.10 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0d01db5..95e97fd 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -64,7 +64,6 @@ jobs: - uses: codecov/codecov-action@v2 with: - file: ./cover.out name: codecov-umbrella fail_ci_if_error: true flags: go @@ -153,7 +152,6 @@ jobs: - uses: codecov/codecov-action@v2 with: - file: ./cover.out name: codecov-umbrella fail_ci_if_error: true flags: wasm From 851eed6ca194f5c418834ad03333882925cd78c5 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 13 Apr 2022 09:03:57 +0000 Subject: [PATCH 38/76] Update CI configs to v0.7.0 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 95e97fd..eba60e0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,19 +43,30 @@ jobs: with: go-version: ${{ matrix.go }} - - name: Setup go-acc - run: | - go get github.com/ory/go-acc - git checkout go.mod go.sum + - name: Set up gotestfmt + uses: haveyoudebuggedit/gotestfmt-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} # Avoid getting rate limited - name: Run test run: | TEST_BENCH_OPTION="-bench=." if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - go-acc -o cover.out ./... -- \ + set -euo pipefail + go test -coverprofile=cover.out -covermode=atomic \ ${TEST_BENCH_OPTION} \ - -v -race + -json \ + -v -race \ + ./... 2>&1 | tee /tmp/gotest.log | gotestfmt + + - name: Upload test log + uses: actions/upload-artifact@v2 + if: always() + with: + name: test-log-${{ matrix.go }} + path: /tmp/gotest.log + if-no-files-found: error - name: Run TEST_HOOK run: | From eb043cd1f66e27741b3ff2f6bcc4957e9e0a7d6f Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 13 Apr 2022 15:59:42 +0000 Subject: [PATCH 39/76] Update CI configs to v0.7.1 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index eba60e0..80f75d0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,6 +43,11 @@ jobs: with: go-version: ${{ matrix.go }} + - name: Setup go-acc + run: | + go get github.com/ory/go-acc + git checkout go.mod go.sum + - name: Set up gotestfmt uses: haveyoudebuggedit/gotestfmt-action@v2 with: @@ -54,11 +59,10 @@ jobs: if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi set -euo pipefail - go test -coverprofile=cover.out -covermode=atomic \ + go-acc -o cover.out ./... -- \ ${TEST_BENCH_OPTION} \ -json \ - -v -race \ - ./... 2>&1 | tee /tmp/gotest.log | gotestfmt + -v -race 2>&1 | tee /tmp/gotest.log | gotestfmt - name: Upload test log uses: actions/upload-artifact@v2 From 32cc142451839464a762ce1c26e1bad6b4f26317 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 24 Apr 2022 02:56:52 +0000 Subject: [PATCH 40/76] Update CI configs to v0.7.2 Update lint scripts and CI configs. --- .github/workflows/lint.yaml | 2 +- .golangci.yml | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 438443f..d284b19 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -47,5 +47,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.31 + version: v1.45.2 args: $GOLANGCI_LINT_EXRA_ARGS diff --git a/.golangci.yml b/.golangci.yml index d6162c9..d7a88ec 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,14 +15,22 @@ linters-settings: linters: enable: - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers + - bidichk # Checks for dangerous unicode character sequences - bodyclose # checks whether HTTP response body is closed successfully + - contextcheck # check the function whether use a non-inherited context - deadcode # Finds unused code + - decorder # check declaration order and count of types, constants, variables and functions - depguard # Go linter that checks if package imports are in a list of acceptable packages - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - dupl # Tool for code clone detection + - durationcheck # check for two durations multiplied together - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases + - 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. + - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. + - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. - exhaustive # check exhaustiveness of enum switch statements - exportloopref # checks for pointers to enclosing loop variables + - forcetypeassert # finds forced type assertions - gci # Gci control golang package import order and make it always deterministic. - gochecknoglobals # Checks that no globals are present in Go code - gochecknoinits # Checks that no init functions are present in Go code @@ -35,40 +43,62 @@ linters: - gofumpt # Gofumpt checks whether code was gofumpt-ed. - goheader # Checks is file header matches to pattern - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports - - golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes + - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - 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. - goprintffuncname # Checks that printf-like functions are named with `f` at the end - gosec # Inspects source code for security problems - gosimple # Linter for Go source code that specializes in simplifying a code - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string + - grouper # An analyzer to analyze expression groups. + - importas # Enforces consistent import aliases - ineffassign # Detects when assignments to existing variables are not used - misspell # Finds commonly misspelled English words in comments - nakedret # Finds naked returns in functions greater than a specified function length + - nilerr # Finds the code that returns nil even if it checks that the error is not nil. + - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. - noctx # noctx finds sending http request without context.Context - - scopelint # Scopelint checks for unpinned variables in go programs + - predeclared # find code that shadows one of Go's predeclared identifiers + - revive # golint replacement, finds style mistakes - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks - structcheck # Finds unused struct fields - stylecheck # Stylecheck is a replacement for golint + - tagliatelle # Checks the struct tags. + - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 + - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code - unconvert # Remove unnecessary type conversions - unparam # Reports unused function parameters - unused # Checks Go code for unused constants, variables, functions and types - varcheck # Finds unused global variables and constants + - wastedassign # wastedassign finds wasted assignment statements - whitespace # Tool for detection of leading and trailing whitespace disable: + - containedctx # containedctx is a linter that detects struct contained context.Context field + - cyclop # checks function and package cyclomatic complexity + - exhaustivestruct # Checks if all struct's fields are initialized + - forbidigo # Forbids identifiers - funlen # Tool for detection of long functions - gocyclo # Computes and checks the cyclomatic complexity of functions - godot # Check if comments end in a period - gomnd # An analyzer to detect magic numbers. + - ifshort # Checks that your code uses short syntax for if-statements whenever possible + - ireturn # Accept Interfaces, Return Concrete Types - lll # Reports long lines + - maintidx # maintidx measures the maintainability index of each function. + - makezero # Finds slice declarations with non-zero initial length - maligned # Tool to detect Go structs that would take less memory if their fields were sorted - nestif # Reports deeply nested if statements - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity - nolintlint # Reports ill-formed or insufficient nolint directives + - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test - prealloc # Finds slice declarations that could potentially be preallocated + - promlinter # Check Prometheus metrics naming via promlint - rowserrcheck # checks whether Err of rows is checked successfully - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. - testpackage # linter that makes you use a separate _test package + - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers + - varnamelen # checks that the length of a variable's name matches its scope + - wrapcheck # Checks that errors returned from external packages are wrapped - wsl # Whitespace Linter - Forces you to use empty lines! issues: From efae1345c1afeb2bc7a9a0ac93f38b725a8236b6 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 4 May 2022 14:29:00 +0000 Subject: [PATCH 41/76] Update CI configs to v0.7.3 Update lint scripts and CI configs. --- .github/workflows/codeql-analysis.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..18641ca --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,27 @@ +name: "CodeQL" + +on: + workflow_dispatch: + schedule: + - cron: '23 5 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: 'go' + + - name: CodeQL Analysis + uses: github/codeql-action/analyze@v2 From 4217a1e2c730b5f04fbd3cef5f79f91adc782b36 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Mon, 9 May 2022 03:10:44 +0000 Subject: [PATCH 42/76] Update CI configs to v0.7.5 Update lint scripts and CI configs. --- .github/hooks/pre-commit.sh | 1 + ...int-no-trailing-newline-in-log-messages.sh | 41 +++++++++++++++++++ .github/workflows/codeql-analysis.yml | 8 ++++ .github/workflows/lint.yaml | 3 ++ 4 files changed, 53 insertions(+) create mode 100755 .github/lint-no-trailing-newline-in-log-messages.sh diff --git a/.github/hooks/pre-commit.sh b/.github/hooks/pre-commit.sh index cc318d7..d5a1ce5 100755 --- a/.github/hooks/pre-commit.sh +++ b/.github/hooks/pre-commit.sh @@ -10,3 +10,4 @@ exec 1>&2 .github/lint-disallowed-functions-in-library.sh +.github/lint-no-trailing-newline-in-log-messages.sh diff --git a/.github/lint-no-trailing-newline-in-log-messages.sh b/.github/lint-no-trailing-newline-in-log-messages.sh new file mode 100755 index 0000000..29cd4a2 --- /dev/null +++ b/.github/lint-no-trailing-newline-in-log-messages.sh @@ -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 \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 18641ca..69bef30 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d284b19..3858008 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -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 From 9b909f6383f207d93f5965c2c293f8677cd4cbb8 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 20 May 2022 20:32:46 +0000 Subject: [PATCH 43/76] Update CI configs to v0.7.8 Update lint scripts and CI configs. --- .github/workflows/generate-authors.yml | 4 ++++ .github/workflows/lint.yaml | 7 +++++++ .github/workflows/renovate-go-mod-fix.yaml | 3 +++ .github/workflows/test.yaml | 12 +++++++----- .github/workflows/tidy-check.yaml | 3 +++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/generate-authors.yml b/.github/workflows/generate-authors.yml index 9a80a48..c7a8404 100644 --- a/.github/workflows/generate-authors.yml +++ b/.github/workflows/generate-authors.yml @@ -16,6 +16,8 @@ on: jobs: checksecret: + permissions: + contents: none runs-on: ubuntu-latest outputs: is_PIONBOT_PRIVATE_KEY_set: ${{ steps.checksecret_job.outputs.is_PIONBOT_PRIVATE_KEY_set }} @@ -28,6 +30,8 @@ jobs: echo "::set-output name=is_PIONBOT_PRIVATE_KEY_set::${{ env.PIONBOT_PRIVATE_KEY != '' }}" generate-authors: + permissions: + contents: write needs: [checksecret] if: needs.checksecret.outputs.is_PIONBOT_PRIVATE_KEY_set == 'true' runs-on: ubuntu-latest diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3858008..11b6336 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -16,6 +16,10 @@ on: - opened - edited - synchronize + +permissions: + contents: read + jobs: lint-commit-message: name: Metadata @@ -41,6 +45,9 @@ jobs: lint-go: name: Go + permissions: + contents: read + pull-requests: read runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/renovate-go-mod-fix.yaml b/.github/workflows/renovate-go-mod-fix.yaml index 5991822..0804642 100644 --- a/.github/workflows/renovate-go-mod-fix.yaml +++ b/.github/workflows/renovate-go-mod-fix.yaml @@ -15,6 +15,9 @@ on: branches: - renovate/* +permissions: + contents: write + jobs: go-mod-fix: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 80f75d0..282e5d6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,12 +17,16 @@ on: pull_request: branches: - master + +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest strategy: matrix: - go: ["1.16", "1.17"] + go: ["1.17", "1.18"] fail-fast: false name: Go ${{ matrix.go }} steps: @@ -44,9 +48,7 @@ jobs: go-version: ${{ matrix.go }} - name: Setup go-acc - run: | - go get github.com/ory/go-acc - git checkout go.mod go.sum + run: go install github.com/ory/go-acc@latest - name: Set up gotestfmt uses: haveyoudebuggedit/gotestfmt-action@v2 @@ -87,7 +89,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.16", "1.17"] + go: ["1.17", "1.18"] fail-fast: false name: Go i386 ${{ matrix.go }} steps: diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index 3ab2c35..fa52ce9 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -18,6 +18,9 @@ on: branches: - master +permissions: + contents: read + jobs: Check: runs-on: ubuntu-latest From 6158995255e2ba94c3bcbcd3a189bf07ec6034f0 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sun, 22 May 2022 17:50:56 +0000 Subject: [PATCH 44/76] Update CI configs to v0.7.9 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 282e5d6..300fac6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -64,7 +64,7 @@ jobs: go-acc -o cover.out ./... -- \ ${TEST_BENCH_OPTION} \ -json \ - -v -race 2>&1 | tee /tmp/gotest.log | gotestfmt + -v -race 2>&1 | grep -v '^go: downloading' | tee /tmp/gotest.log | gotestfmt - name: Upload test log uses: actions/upload-artifact@v2 From 24ddd2da5b8b82d089c21334fe474ad3f6a7aff8 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 24 May 2022 08:19:08 +0000 Subject: [PATCH 45/76] Update CI configs to v0.7.10 Update lint scripts and CI configs. --- .github/workflows/codeql-analysis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 69bef30..cec0d7c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -4,6 +4,11 @@ on: workflow_dispatch: schedule: - cron: '23 5 * * 0' + pull_request: + branches: + - master + paths: + - '**.go' jobs: analyze: From 1a33d599dd373a163ab61920723114db8cb3a762 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 20 Jan 2023 02:58:58 +0000 Subject: [PATCH 46/76] Update CI configs to v0.10.2 Update lint scripts and CI configs. --- .github/.gitignore | 1 + .github/fetch-scripts.sh | 29 ++++ .github/generate-authors.sh | 66 -------- .github/hooks/commit-msg.sh | 11 -- .github/hooks/pre-commit.sh | 13 -- .github/hooks/pre-push.sh | 13 -- .github/install-hooks.sh | 12 +- .github/lint-commit-message.sh | 64 ------- .../lint-disallowed-functions-in-library.sh | 48 ------ .github/lint-filename.sh | 24 --- ...int-no-trailing-newline-in-log-messages.sh | 41 ----- .github/workflows/codeql-analysis.yml | 40 ++--- .github/workflows/generate-authors.yml | 66 +------- .github/workflows/lint.yaml | 47 +----- .github/workflows/release.yml | 22 +++ .github/workflows/renovate-go-mod-fix.yaml | 36 ---- .github/workflows/renovate-go-sum-fix.yaml | 22 +++ .github/workflows/test.yaml | 157 ++---------------- .github/workflows/tidy-check.yaml | 25 +-- .goreleaser.yml | 2 + AUTHORS.txt | 2 +- renovate.json | 25 +-- 22 files changed, 122 insertions(+), 644 deletions(-) create mode 100644 .github/.gitignore create mode 100755 .github/fetch-scripts.sh delete mode 100755 .github/generate-authors.sh delete mode 100755 .github/hooks/commit-msg.sh delete mode 100755 .github/hooks/pre-commit.sh delete mode 100755 .github/hooks/pre-push.sh delete mode 100755 .github/lint-commit-message.sh delete mode 100755 .github/lint-disallowed-functions-in-library.sh delete mode 100755 .github/lint-filename.sh delete mode 100755 .github/lint-no-trailing-newline-in-log-messages.sh create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/renovate-go-mod-fix.yaml create mode 100644 .github/workflows/renovate-go-sum-fix.yaml create mode 100644 .goreleaser.yml diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..44d7f86 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +.goassets diff --git a/.github/fetch-scripts.sh b/.github/fetch-scripts.sh new file mode 100755 index 0000000..d7e848b --- /dev/null +++ b/.github/fetch-scripts.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# +# 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 -eu + +SCRIPT_PATH="$(realpath "$(dirname "$0")")" +GOASSETS_PATH="${SCRIPT_PATH}/.goassets" + +GOASSETS_REF=${GOASSETS_REF:-master} + +if [ -d "${GOASSETS_PATH}" ]; then + if ! git -C "${GOASSETS_PATH}" diff --exit-code; then + echo "${GOASSETS_PATH} has uncommitted changes" >&2 + exit 1 + fi + git -C "${GOASSETS_PATH}" fetch origin + git -C "${GOASSETS_PATH}" checkout ${GOASSETS_REF} + git -C "${GOASSETS_PATH}" reset --hard origin/${GOASSETS_REF} +else + git clone -b ${GOASSETS_REF} https://github.com/pion/.goassets.git "${GOASSETS_PATH}" +fi diff --git a/.github/generate-authors.sh b/.github/generate-authors.sh deleted file mode 100755 index 182e4f5..0000000 --- a/.github/generate-authors.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/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 - -SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -AUTHORS_PATH="$GITHUB_WORKSPACE/AUTHORS.txt" - -if [ -f ${SCRIPT_PATH}/.ci.conf ] -then - . ${SCRIPT_PATH}/.ci.conf -fi - -# -# DO NOT EDIT THIS -# -EXCLUDED_CONTRIBUTORS+=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot' 'pionbot') -# If you want to exclude a name from all repositories, send a PR to -# https://github.com/pion/.goassets instead of this repository. -# If you want to exclude a name only from this repository, -# add EXCLUDED_CONTRIBUTORS=('name') to .github/.ci.conf - -CONTRIBUTORS=() - -shouldBeIncluded () { - for i in "${EXCLUDED_CONTRIBUTORS[@]}" - do - if [[ $1 =~ "$i" ]]; then - return 1 - fi - done - return 0 -} - - -IFS=$'\n' #Only split on newline -for contributor in $(git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf) -do - if shouldBeIncluded $contributor; then - CONTRIBUTORS+=("$contributor") - fi -done -unset IFS - -if [ ${#CONTRIBUTORS[@]} -ne 0 ]; then - cat >$AUTHORS_PATH <<-'EOH' -# Thank you to everyone that made Pion possible. If you are interested in contributing -# we would love to have you https://github.com/pion/webrtc/wiki/Contributing -# -# This file is auto generated, using git to list all individuals contributors. -# see `.github/generate-authors.sh` for the scripting -EOH - for i in "${CONTRIBUTORS[@]}" - do - echo "$i" >> $AUTHORS_PATH - done - exit 0 -fi diff --git a/.github/hooks/commit-msg.sh b/.github/hooks/commit-msg.sh deleted file mode 100755 index 8213dc2..0000000 --- a/.github/hooks/commit-msg.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# -# DO NOT EDIT THIS FILE DIRECTLY -# -# It is automatically copied from https://github.com/pion/.goassets repository. -# - -set -e - -.github/lint-commit-message.sh $1 diff --git a/.github/hooks/pre-commit.sh b/.github/hooks/pre-commit.sh deleted file mode 100755 index d5a1ce5..0000000 --- a/.github/hooks/pre-commit.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# -# DO NOT EDIT THIS FILE DIRECTLY -# -# It is automatically copied from https://github.com/pion/.goassets repository. -# - -# Redirect output to stderr. -exec 1>&2 - -.github/lint-disallowed-functions-in-library.sh -.github/lint-no-trailing-newline-in-log-messages.sh diff --git a/.github/hooks/pre-push.sh b/.github/hooks/pre-push.sh deleted file mode 100755 index bfe65bc..0000000 --- a/.github/hooks/pre-push.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# -# DO NOT EDIT THIS FILE DIRECTLY -# -# It is automatically copied from https://github.com/pion/.goassets repository. -# - -set -e - -.github/generate-authors.sh - -exit 0 diff --git a/.github/install-hooks.sh b/.github/install-hooks.sh index 73d20a4..57b7798 100755 --- a/.github/install-hooks.sh +++ b/.github/install-hooks.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # DO NOT EDIT THIS FILE @@ -9,8 +9,10 @@ # https://github.com/pion/.goassets instead of this repository. # -SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +SCRIPT_PATH="$(realpath "$(dirname "$0")")" -cp "$SCRIPT_PATH/hooks/commit-msg.sh" "$SCRIPT_PATH/../.git/hooks/commit-msg" -cp "$SCRIPT_PATH/hooks/pre-commit.sh" "$SCRIPT_PATH/../.git/hooks/pre-commit" -cp "$SCRIPT_PATH/hooks/pre-push.sh" "$SCRIPT_PATH/../.git/hooks/pre-push" +. ${SCRIPT_PATH}/fetch-scripts.sh + +cp "${GOASSETS_PATH}/hooks/commit-msg.sh" "${SCRIPT_PATH}/../.git/hooks/commit-msg" +cp "${GOASSETS_PATH}/hooks/pre-commit.sh" "${SCRIPT_PATH}/../.git/hooks/pre-commit" +cp "${GOASSETS_PATH}/hooks/pre-push.sh" "${SCRIPT_PATH}/../.git/hooks/pre-push" diff --git a/.github/lint-commit-message.sh b/.github/lint-commit-message.sh deleted file mode 100755 index 010a332..0000000 --- a/.github/lint-commit-message.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/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 - -display_commit_message_error() { -cat << EndOfMessage -$1 - -------------------------------------------------- -The preceding commit message is invalid -it failed '$2' of the following checks - -* Separate subject from body with a blank line -* Limit the subject line to 50 characters -* Capitalize the subject line -* Do not end the subject line with a period -* Wrap the body at 72 characters -EndOfMessage - - exit 1 -} - -lint_commit_message() { - if [[ "$(echo "$1" | awk 'NR == 2 {print $1;}' | wc -c)" -ne 1 ]]; then - display_commit_message_error "$1" 'Separate subject from body with a blank line' - fi - - if [[ "$(echo "$1" | head -n1 | awk '{print length}')" -gt 50 ]]; then - display_commit_message_error "$1" 'Limit the subject line to 50 characters' - fi - - if [[ ! $1 =~ ^[A-Z] ]]; then - display_commit_message_error "$1" 'Capitalize the subject line' - fi - - if [[ "$(echo "$1" | awk 'NR == 1 {print substr($0,length($0),1)}')" == "." ]]; then - display_commit_message_error "$1" 'Do not end the subject line with a period' - fi - - if [[ "$(echo "$1" | awk '{print length}' | sort -nr | head -1)" -gt 72 ]]; then - display_commit_message_error "$1" 'Wrap the body at 72 characters' - fi -} - -if [ "$#" -eq 1 ]; then - if [ ! -f "$1" ]; then - echo "$0 was passed one argument, but was not a valid file" - exit 1 - fi - lint_commit_message "$(sed -n '/# Please enter the commit message for your changes. Lines starting/q;p' "$1")" -else - for commit in $(git rev-list --no-merges origin/master..); do - lint_commit_message "$(git log --format="%B" -n 1 $commit)" - done -fi diff --git a/.github/lint-disallowed-functions-in-library.sh b/.github/lint-disallowed-functions-in-library.sh deleted file mode 100755 index 8ce5d09..0000000 --- a/.github/lint-disallowed-functions-in-library.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/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 - -EXCLUDE_DIRECTORIES=${DISALLOWED_FUNCTIONS_EXCLUDED_DIRECTORIES:-"examples"} -DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(' 'print(' 'println(') - -files=$( - find "$SCRIPT_PATH/.." -name "*.go" \ - | grep -v -e '^.*_test.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 -) - -for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}" -do - if grep -e "\s$disallowedFunction" $files | grep -v -e 'nolint'; then - echo "$disallowedFunction may only be used in example code" - exit 1 - fi -done diff --git a/.github/lint-filename.sh b/.github/lint-filename.sh deleted file mode 100755 index 81b3f14..0000000 --- a/.github/lint-filename.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/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 - -SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -GO_REGEX="^[a-zA-Z][a-zA-Z0-9_]*\.go$" - -find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do - filename=$(basename -- "$fullpath") - - if ! [[ $filename =~ $GO_REGEX ]]; then - echo "$filename is not a valid filename for Go code, only alpha, numbers and underscores are supported" - exit 1 - fi -done diff --git a/.github/lint-no-trailing-newline-in-log-messages.sh b/.github/lint-no-trailing-newline-in-log-messages.sh deleted file mode 100755 index 29cd4a2..0000000 --- a/.github/lint-no-trailing-newline-in-log-messages.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/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 \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cec0d7c..bb44904 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,4 +1,15 @@ -name: "CodeQL" +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# + +name: CodeQL on: workflow_dispatch: @@ -12,29 +23,4 @@ on: jobs: analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - steps: - - 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: - languages: 'go' - - - name: CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: pion/.goassets/.github/workflows/codeql-analysis.reusable.yml@master diff --git a/.github/workflows/generate-authors.yml b/.github/workflows/generate-authors.yml index c7a8404..9fc78bc 100644 --- a/.github/workflows/generate-authors.yml +++ b/.github/workflows/generate-authors.yml @@ -9,69 +9,13 @@ # https://github.com/pion/.goassets instead of this repository. # -name: generate-authors +name: Generate Authors on: pull_request: jobs: - checksecret: - permissions: - contents: none - runs-on: ubuntu-latest - outputs: - is_PIONBOT_PRIVATE_KEY_set: ${{ steps.checksecret_job.outputs.is_PIONBOT_PRIVATE_KEY_set }} - steps: - - id: checksecret_job - env: - PIONBOT_PRIVATE_KEY: ${{ secrets.PIONBOT_PRIVATE_KEY }} - run: | - echo "is_PIONBOT_PRIVATE_KEY_set: ${{ env.PIONBOT_PRIVATE_KEY != '' }}" - echo "::set-output name=is_PIONBOT_PRIVATE_KEY_set::${{ env.PIONBOT_PRIVATE_KEY != '' }}" - - generate-authors: - permissions: - contents: write - needs: [checksecret] - if: needs.checksecret.outputs.is_PIONBOT_PRIVATE_KEY_set == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - fetch-depth: 0 - token: ${{ secrets.PIONBOT_PRIVATE_KEY }} - - - name: Generate the authors file - run: .github/generate-authors.sh - - - name: Add the authors file to git - run: git add AUTHORS.txt - - - name: Get last commit message - id: last-commit-message - run: | - COMMIT_MSG=$(git log -1 --pretty=%B) - COMMIT_MSG="${COMMIT_MSG//'%'/'%25'}" - COMMIT_MSG="${COMMIT_MSG//$'\n'/'%0A'}" - COMMIT_MSG="${COMMIT_MSG//$'\r'/'%0D'}" - echo "::set-output name=msg::$COMMIT_MSG" - - - name: Get last commit author - id: last-commit-author - run: | - echo "::set-output name=msg::$(git log -1 --pretty='%aN <%ae>')" - - - name: Check if AUTHORS.txt file has changed - id: git-status-output - run: | - echo "::set-output name=msg::$(git status -s | wc -l)" - - - name: Commit and push - if: ${{ steps.git-status-output.outputs.msg != '0' }} - run: | - git config user.email $(echo "${{ steps.last-commit-author.outputs.msg }}" | sed 's/\(.\+\) <\(\S\+\)>/\2/') - git config user.name $(echo "${{ steps.last-commit-author.outputs.msg }}" | sed 's/\(.\+\) <\(\S\+\)>/\1/') - git add AUTHORS.txt - git commit --amend --no-edit - git push --force https://github.com/${GITHUB_REPOSITORY} $(git symbolic-ref -q --short HEAD) + generate: + uses: pion/.goassets/.github/workflows/generate-authors.reusable.yml@master + secrets: + token: ${{ secrets.PIONBOT_PRIVATE_KEY }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 11b6336..e72c716 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -12,50 +12,7 @@ name: Lint on: pull_request: - types: - - opened - - edited - - synchronize - -permissions: - contents: read jobs: - lint-commit-message: - name: Metadata - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Commit Message - run: .github/lint-commit-message.sh - - - name: File names - run: .github/lint-filename.sh - - - 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 - permissions: - contents: read - pull-requests: read - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v3 - - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.45.2 - args: $GOLANGCI_LINT_EXRA_ARGS + lint: + uses: pion/.goassets/.github/workflows/lint.reusable.yml@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a07c292 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# + +name: Release +on: + push: + tags: + - 'v*' + +jobs: + release: + uses: pion/.goassets/.github/workflows/release.reusable.yml@master + with: + go-version: '1.19' # auto-update/latest-go-version diff --git a/.github/workflows/renovate-go-mod-fix.yaml b/.github/workflows/renovate-go-mod-fix.yaml deleted file mode 100644 index 0804642..0000000 --- a/.github/workflows/renovate-go-mod-fix.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# -# DO NOT EDIT THIS FILE -# -# It is automatically copied from https://github.com/pion/.goassets repository. -# If this repository should have package specific CI config, -# remove the repository name from .goassets/.github/workflows/assets-sync.yml. -# -# If you want to update the shared CI config, send a PR to -# https://github.com/pion/.goassets instead of this repository. -# - -name: go-mod-fix -on: - push: - branches: - - renovate/* - -permissions: - contents: write - -jobs: - go-mod-fix: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - name: fix - uses: at-wat/go-sum-fix-action@v0 - with: - git_user: Pion Bot - git_email: 59523206+pionbot@users.noreply.github.com - github_token: ${{ secrets.PIONBOT_PRIVATE_KEY }} - commit_style: squash - push: force diff --git a/.github/workflows/renovate-go-sum-fix.yaml b/.github/workflows/renovate-go-sum-fix.yaml new file mode 100644 index 0000000..5a9af36 --- /dev/null +++ b/.github/workflows/renovate-go-sum-fix.yaml @@ -0,0 +1,22 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# + +name: Fix go.sum +on: + push: + branches: + - renovate/* + +jobs: + fix: + uses: pion/.goassets/.github/workflows/renovate-go-sum-fix.reusable.yml@master + secrets: + token: ${{ secrets.PIONBOT_PRIVATE_KEY }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 300fac6..834a158 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,162 +13,29 @@ name: Test on: push: branches: - - master + - master pull_request: - branches: - - master - -permissions: - contents: read jobs: test: - runs-on: ubuntu-latest + uses: pion/.goassets/.github/workflows/test.reusable.yml@master strategy: matrix: - go: ["1.17", "1.18"] + go: ['1.19', '1.18'] # auto-update/supported-go-version-list fail-fast: false - name: Go ${{ matrix.go }} - steps: - - uses: actions/checkout@v3 - - - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/go/bin - ~/.cache - key: ${{ runner.os }}-amd64-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-amd64-go- - - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: ${{ matrix.go }} - - - name: Setup go-acc - run: go install github.com/ory/go-acc@latest - - - name: Set up gotestfmt - uses: haveyoudebuggedit/gotestfmt-action@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} # Avoid getting rate limited - - - name: Run test - run: | - TEST_BENCH_OPTION="-bench=." - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - - set -euo pipefail - go-acc -o cover.out ./... -- \ - ${TEST_BENCH_OPTION} \ - -json \ - -v -race 2>&1 | grep -v '^go: downloading' | tee /tmp/gotest.log | gotestfmt - - - name: Upload test log - uses: actions/upload-artifact@v2 - if: always() - with: - name: test-log-${{ matrix.go }} - path: /tmp/gotest.log - if-no-files-found: error - - - name: Run TEST_HOOK - run: | - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - if [ -n "${TEST_HOOK}" ]; then ${TEST_HOOK}; fi - - - uses: codecov/codecov-action@v2 - with: - name: codecov-umbrella - fail_ci_if_error: true - flags: go + with: + go-version: ${{ matrix.go }} test-i386: - runs-on: ubuntu-latest + uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master strategy: matrix: - go: ["1.17", "1.18"] + go: ['1.19', '1.18'] # auto-update/supported-go-version-list fail-fast: false - name: Go i386 ${{ matrix.go }} - steps: - - uses: actions/checkout@v3 - - - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache - key: ${{ runner.os }}-i386-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-i386-go- - - - name: Run test - run: | - mkdir -p $HOME/go/pkg/mod $HOME/.cache - docker run \ - -u $(id -u):$(id -g) \ - -e "GO111MODULE=on" \ - -e "CGO_ENABLED=0" \ - -v $GITHUB_WORKSPACE:/go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \ - -v $HOME/go/pkg/mod:/go/pkg/mod \ - -v $HOME/.cache:/.cache \ - -w /go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \ - i386/golang:${{matrix.go}}-alpine \ - /usr/local/go/bin/go test \ - ${TEST_EXTRA_ARGS:-} \ - -v ./... + with: + go-version: ${{ matrix.go }} test-wasm: - runs-on: ubuntu-latest - strategy: - fail-fast: false - name: WASM - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '16.x' - - - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache - key: ${{ runner.os }}-wasm-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-wasm-go- - - - name: Download Go - run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf - - env: - GO_VERSION: 1.17 - - - name: Set Go Root - run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV - - - name: Set Go Path - run: echo "GOPATH=${HOME}/go" >> $GITHUB_ENV - - - name: Set Go Path - run: echo "GO_JS_WASM_EXEC=${GOROOT}/misc/wasm/go_js_wasm_exec" >> $GITHUB_ENV - - - name: Insall NPM modules - run: yarn install - - - name: Run Tests - run: | - if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi - GOOS=js GOARCH=wasm $GOPATH/bin/go test \ - -coverprofile=cover.out -covermode=atomic \ - -exec="${GO_JS_WASM_EXEC}" \ - -v ./... - - - uses: codecov/codecov-action@v2 - with: - name: codecov-umbrella - fail_ci_if_error: true - flags: wasm + uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master + with: + go-version: '1.19' # auto-update/latest-go-version diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index fa52ce9..29c5cb8 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -12,29 +12,12 @@ name: Go mod tidy on: pull_request: - branches: - - master push: branches: - master -permissions: - contents: read - jobs: - Check: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - name: Setup Go - uses: actions/setup-go@v3 - - name: check - run: | - go mod download - go mod tidy - if ! git diff --exit-code - then - echo "Not go mod tidied" - exit 1 - fi + tidy: + uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master + with: + go-version: '1.19' # auto-update/latest-go-version diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..2caa5fb --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,2 @@ +builds: +- skip: true diff --git a/AUTHORS.txt b/AUTHORS.txt index bdaf3ba..064eeae 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -2,7 +2,7 @@ # we would love to have you https://github.com/pion/webrtc/wiki/Contributing # # This file is auto generated, using git to list all individuals contributors. -# see `.github/generate-authors.sh` for the scripting +# see https://github.com/pion/.goassets/blob/master/scripts/generate-authors.sh for the scripting Atsushi Watanabe backkem Hugo Arregui diff --git a/renovate.json b/renovate.json index f161405..f1bb98c 100644 --- a/renovate.json +++ b/renovate.json @@ -1,27 +1,6 @@ { + "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ - "config:base", - ":disableDependencyDashboard" - ], - "postUpdateOptions": [ - "gomodTidy" - ], - "commitBody": "Generated by renovateBot", - "packageRules": [ - { - "matchUpdateTypes": ["minor", "patch", "pin", "digest"], - "automerge": true - }, - { - "packagePatterns": ["^golang.org/x/"], - "schedule": ["on the first day of the month"] - } - ], - "ignorePaths": [ - ".github/workflows/generate-authors.yml", - ".github/workflows/lint.yaml", - ".github/workflows/renovate-go-mod-fix.yaml", - ".github/workflows/test.yaml", - ".github/workflows/tidy-check.yaml" + "github>pion/renovate-config" ] } From abff37dad8b44ac485fe754cb2caac078981e16b Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Mon, 23 Jan 2023 08:16:18 +0000 Subject: [PATCH 47/76] Update CI configs to v0.10.3 Update lint scripts and CI configs. --- .golangci.yml | 3 --- AUTHORS.txt | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d7a88ec..48696f1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,6 @@ linters: - bidichk # Checks for dangerous unicode character sequences - bodyclose # checks whether HTTP response body is closed successfully - contextcheck # check the function whether use a non-inherited context - - deadcode # Finds unused code - decorder # check declaration order and count of types, constants, variables and functions - depguard # Go linter that checks if package imports are in a list of acceptable packages - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) @@ -60,7 +59,6 @@ linters: - predeclared # find code that shadows one of Go's predeclared identifiers - revive # golint replacement, finds style mistakes - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks - - structcheck # Finds unused struct fields - stylecheck # Stylecheck is a replacement for golint - tagliatelle # Checks the struct tags. - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 @@ -69,7 +67,6 @@ linters: - unconvert # Remove unnecessary type conversions - unparam # Reports unused function parameters - unused # Checks Go code for unused constants, variables, functions and types - - varcheck # Finds unused global variables and constants - wastedassign # wastedassign finds wasted assignment statements - whitespace # Tool for detection of leading and trailing whitespace disable: diff --git a/AUTHORS.txt b/AUTHORS.txt index 064eeae..6e548ac 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -10,3 +10,6 @@ Michael MacDonald Okamoto Sean DuBois Woodrow Douglass + +# List of contributors not appearing in Git history + From 463a6088130e7f078fcc4771a41adf98696c3d0d Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 11 Mar 2023 12:29:50 +0100 Subject: [PATCH 48/76] Cleanup badges in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4009036..3af9063 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Pion transport Slack Widget
- Build Status - GoDoc + GitHub Workflow Status + Go Reference Coverage Status Go Report Card License: MIT From 78fd1e69d29433357de60184859853be90856ad4 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 11 Mar 2023 12:36:49 +0100 Subject: [PATCH 49/76] Cleanup common sections in README --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3af9063..4e530fc 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,15 @@ The library is used as a part of our WebRTC implementation. Please refer to that [roadmap](https://github.com/pion/webrtc/issues/9) to track our major milestones. ### Community -Pion has an active community on the [Golang Slack](https://invite.slack.golangbridge.org/). Sign up and join the **#pion** channel for discussions and support. You can also use [Pion mailing list](https://groups.google.com/forum/#!forum/pion). +Pion has an active community on the [Slack](https://pion.ly/slack). -We are always looking to support **your projects**. Please reach out if you have something to build! +Follow the [Pion Twitter](https://twitter.com/_pion) for project updates and important WebRTC news. +We are always looking to support **your projects**. Please reach out if you have something to build! If you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly) ### Contributing -Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contributing)** to join the group of amazing people making this project possible: +Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contributing)** to join the group of amazing people making this project possible: [AUTHORS.txt](./AUTHORS.txt) ### License MIT License - see [LICENSE](LICENSE) for full text From d4b72463b6af0fa8de3162e409cc6f481383a5b4 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 13 Mar 2023 09:46:33 +0100 Subject: [PATCH 50/76] Update AUTHORS.txt --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 6e548ac..cb933b2 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -9,6 +9,7 @@ Hugo Arregui Michael MacDonald Okamoto Sean DuBois +Steffen Vogel Woodrow Douglass # List of contributors not appearing in Git history From 715722498f4132eec4ecb976eae56a2af0a56dc1 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 5 Apr 2023 08:41:49 +0200 Subject: [PATCH 51/76] Harmonize sections in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e530fc..713f5e0 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ We are always looking to support **your projects**. Please reach out if you have If you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly) ### Contributing -Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contributing)** to join the group of amazing people making this project possible: [AUTHORS.txt](./AUTHORS.txt) +Check out the [contributing wiki](https://github.com/pion/webrtc/wiki/Contributing) to join the group of amazing people making this project possible: [AUTHORS.txt](./AUTHORS.txt) ### License MIT License - see [LICENSE](LICENSE) for full text From 57c27e160cc5c02f6d274d62098802933d1aeb61 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 7 Apr 2023 20:04:54 +0000 Subject: [PATCH 52/76] Update CI configs to v0.10.6 Update lint scripts and CI configs. --- .github/workflows/release.yml | 2 +- .github/workflows/test.yaml | 6 +++--- .github/workflows/tidy-check.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a07c292..d07dfdf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,4 +19,4 @@ jobs: release: uses: pion/.goassets/.github/workflows/release.reusable.yml@master with: - go-version: '1.19' # auto-update/latest-go-version + go-version: '1.20' # auto-update/latest-go-version diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 834a158..7fcb1f5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,7 +21,7 @@ jobs: uses: pion/.goassets/.github/workflows/test.reusable.yml@master strategy: matrix: - go: ['1.19', '1.18'] # auto-update/supported-go-version-list + go: ['1.20', '1.19'] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -30,7 +30,7 @@ jobs: uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master strategy: matrix: - go: ['1.19', '1.18'] # auto-update/supported-go-version-list + go: ['1.20', '1.19'] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -38,4 +38,4 @@ jobs: test-wasm: uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master with: - go-version: '1.19' # auto-update/latest-go-version + go-version: '1.20' # auto-update/latest-go-version diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index 29c5cb8..b94cc19 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -20,4 +20,4 @@ jobs: tidy: uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master with: - go-version: '1.19' # auto-update/latest-go-version + go-version: '1.20' # auto-update/latest-go-version From 4ac3d4178ee2dd583963ceb3c581caaf20838c3e Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 18 Apr 2023 10:35:48 +0000 Subject: [PATCH 53/76] Update CI configs to v0.10.7 Update lint scripts and CI configs. --- .github/.gitignore | 3 +++ .github/fetch-scripts.sh | 2 ++ .github/install-hooks.sh | 2 ++ .github/workflows/codeql-analysis.yml | 2 ++ .github/workflows/generate-authors.yml | 2 ++ .github/workflows/lint.yaml | 2 ++ .github/workflows/release.yml | 2 ++ .github/workflows/renovate-go-sum-fix.yaml | 2 ++ .github/workflows/reuse.yml | 22 ++++++++++++++++++ .github/workflows/test.yaml | 2 ++ .github/workflows/tidy-check.yaml | 2 ++ .gitignore | 3 +++ .golangci.yml | 26 ++++++++++++++++++++-- .goreleaser.yml | 3 +++ .reuse/dep5 | 7 ++++++ codecov.yml | 2 ++ 16 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/reuse.yml create mode 100644 .reuse/dep5 diff --git a/.github/.gitignore b/.github/.gitignore index 44d7f86..c3421a1 100644 --- a/.github/.gitignore +++ b/.github/.gitignore @@ -1 +1,4 @@ +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + .goassets diff --git a/.github/fetch-scripts.sh b/.github/fetch-scripts.sh index d7e848b..f333841 100755 --- a/.github/fetch-scripts.sh +++ b/.github/fetch-scripts.sh @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT set -eu diff --git a/.github/install-hooks.sh b/.github/install-hooks.sh index 57b7798..8aa34be 100755 --- a/.github/install-hooks.sh +++ b/.github/install-hooks.sh @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT SCRIPT_PATH="$(realpath "$(dirname "$0")")" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index bb44904..ea9b825 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT name: CodeQL diff --git a/.github/workflows/generate-authors.yml b/.github/workflows/generate-authors.yml index 9fc78bc..ec7446c 100644 --- a/.github/workflows/generate-authors.yml +++ b/.github/workflows/generate-authors.yml @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT name: Generate Authors diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e72c716..5dd3a99 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT name: Lint on: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d07dfdf..01227e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT name: Release on: diff --git a/.github/workflows/renovate-go-sum-fix.yaml b/.github/workflows/renovate-go-sum-fix.yaml index 5a9af36..b7bb1b4 100644 --- a/.github/workflows/renovate-go-sum-fix.yaml +++ b/.github/workflows/renovate-go-sum-fix.yaml @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT name: Fix go.sum on: diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml new file mode 100644 index 0000000..8633a12 --- /dev/null +++ b/.github/workflows/reuse.yml @@ -0,0 +1,22 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: REUSE Compliance Check + +on: + push: + pull_request: + +jobs: + lint: + uses: pion/.goassets/.github/workflows/reuse.reusable.yml@master diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7fcb1f5..31aada4 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT name: Test on: diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index b94cc19..4d346d4 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -8,6 +8,8 @@ # If you want to update the shared CI config, send a PR to # https://github.com/pion/.goassets instead of this repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT name: Go mod tidy on: diff --git a/.gitignore b/.gitignore index f977e74..6e2f206 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + ### JetBrains IDE ### ##################### .idea/ diff --git a/.golangci.yml b/.golangci.yml index 48696f1..826254a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + linters-settings: govet: check-shadowing: true @@ -10,7 +13,15 @@ linters-settings: modules: - github.com/pkg/errors: recommendations: - - errors + - errors + forbidigo: + forbid: + - Fatal(f|ln)?$ + - ^fmt.Print(f|ln)?$ + - ^log.Print(f|ln)?$ + - ^os.Exit$ + - ^panic$ + - ^print(ln)?$ linters: enable: @@ -29,6 +40,7 @@ linters: - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. - exhaustive # check exhaustiveness of enum switch statements - exportloopref # checks for pointers to enclosing loop variables + - forbidigo # Forbids identifiers - forcetypeassert # finds forced type assertions - gci # Gci control golang package import order and make it always deterministic. - gochecknoglobals # Checks that no globals are present in Go code @@ -73,7 +85,6 @@ linters: - containedctx # containedctx is a linter that detects struct contained context.Context field - cyclop # checks function and package cyclomatic complexity - exhaustivestruct # Checks if all struct's fields are initialized - - forbidigo # Forbids identifiers - funlen # Tool for detection of long functions - gocyclo # Computes and checks the cyclomatic complexity of functions - godot # Check if comments end in a period @@ -105,12 +116,23 @@ issues: - path: _test\.go linters: - gocognit + - forbidigo # Allow complex main function in examples - path: examples text: "of func `main` is high" linters: - gocognit + + # Allow forbidden identifiers in examples + - path: examples + linters: + - forbidigo + + # Allow forbidden identifiers in CLI commands + - path: cmd + linters: + - forbidigo run: skip-dirs-use-default: false diff --git a/.goreleaser.yml b/.goreleaser.yml index 2caa5fb..30093e9 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,2 +1,5 @@ +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + builds: - skip: true diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 0000000..ccc710a --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,7 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Pion +Source: https://github.com/pion/ + +Files: README.md AUTHORS.txt renovate.json +Copyright: 2023 The Pion community +License: MIT diff --git a/codecov.yml b/codecov.yml index 085200a..263e4d4 100644 --- a/codecov.yml +++ b/codecov.yml @@ -3,6 +3,8 @@ # # It is automatically copied from https://github.com/pion/.goassets repository. # +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT coverage: status: From e60efc8ffb1c4f3ab5b07469b41cad254726f5d9 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 18 Apr 2023 13:34:05 +0200 Subject: [PATCH 54/76] Make package REUSE compliant --- .reuse/dep5 | 6 +++++- LICENSE | 22 +--------------------- LICENSES/MIT.txt | 9 +++++++++ logger.go | 3 +++ logging_test.go | 3 +++ scoped.go | 3 +++ 6 files changed, 24 insertions(+), 22 deletions(-) mode change 100644 => 120000 LICENSE create mode 100644 LICENSES/MIT.txt diff --git a/.reuse/dep5 b/.reuse/dep5 index ccc710a..04e1f8f 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -2,6 +2,10 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Pion Source: https://github.com/pion/ -Files: README.md AUTHORS.txt renovate.json +Files: README.md **/README.md AUTHORS.txt renovate.json go.mod go.sum Copyright: 2023 The Pion community License: MIT + +Files: testdata/fuzz/* api/*.txt +Copyright: 2023 The Pion community +License: CC0-1.0 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index ab60297..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/LICENSE b/LICENSE new file mode 120000 index 0000000..31ff787 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +LICENSES/MIT.txt \ No newline at end of file diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..2071b23 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/logger.go b/logger.go index 0bccf13..5a78107 100644 --- a/logger.go +++ b/logger.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + // Package logging provides the logging library used by Pion package logging diff --git a/logging_test.go b/logging_test.go index 5b8c6e2..a7b40cd 100644 --- a/logging_test.go +++ b/logging_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package logging_test import ( diff --git a/scoped.go b/scoped.go index 678bab4..24cf676 100644 --- a/scoped.go +++ b/scoped.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 The Pion community +// SPDX-License-Identifier: MIT + package logging import ( From c466bd87af20ec3e062dfa36b562709722f6cbdf Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Thu, 18 May 2023 19:14:17 +0000 Subject: [PATCH 55/76] Update CI configs to v0.10.8 Update lint scripts and CI configs. --- .golangci.yml | 3 +-- .reuse/dep5 | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 826254a..4e3eddf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,9 +16,8 @@ linters-settings: - errors forbidigo: forbid: - - Fatal(f|ln)?$ - ^fmt.Print(f|ln)?$ - - ^log.Print(f|ln)?$ + - ^log.(Panic|Fatal|Print)(f|ln)?$ - ^os.Exit$ - ^panic$ - ^print(ln)?$ diff --git a/.reuse/dep5 b/.reuse/dep5 index 04e1f8f..afb63d7 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -6,6 +6,6 @@ Files: README.md **/README.md AUTHORS.txt renovate.json go.mod go.sum Copyright: 2023 The Pion community License: MIT -Files: testdata/fuzz/* api/*.txt +Files: testdata/fuzz/* **/testdata/fuzz/* api/*.txt Copyright: 2023 The Pion community License: CC0-1.0 From 37105f733515d4bd1e21f583f7090ca6f6453a84 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 19 May 2023 09:18:57 +0200 Subject: [PATCH 56/76] Bring back LICENSE file pkg.go.dev scanner expects this file [0] [0] https://pkg.go.dev/license-policy --- LICENSE | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) mode change 120000 => 100644 LICENSE diff --git a/LICENSE b/LICENSE deleted file mode 120000 index 31ff787..0000000 --- a/LICENSE +++ /dev/null @@ -1 +0,0 @@ -LICENSES/MIT.txt \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..491caf6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023 The Pion community + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From b62977acd23bc7d98bec846107a7a0220a8ef5bb Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 19 May 2023 07:45:09 +0000 Subject: [PATCH 57/76] Update CI configs to v0.10.9 Update lint scripts and CI configs. --- .reuse/dep5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.reuse/dep5 b/.reuse/dep5 index afb63d7..c8b3dfa 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -2,7 +2,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Pion Source: https://github.com/pion/ -Files: README.md **/README.md AUTHORS.txt renovate.json go.mod go.sum +Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum .eslintrc.json package.json examples/examples.json Copyright: 2023 The Pion community License: MIT From c3a15ed6355722cb3e2c206eb5d998a377a009e3 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Sat, 5 Aug 2023 17:46:17 +0000 Subject: [PATCH 58/76] Update CI configs to v0.10.11 Update lint scripts and CI configs. --- .reuse/dep5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.reuse/dep5 b/.reuse/dep5 index c8b3dfa..717f0c1 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -2,7 +2,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Pion Source: https://github.com/pion/ -Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum .eslintrc.json package.json examples/examples.json +Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum **/go.mod **/go.sum .eslintrc.json package.json examples/examples.json Copyright: 2023 The Pion community License: MIT From 0492da50a8c391f9f7d2380c8f30fe3c326d2e67 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Tue, 2 Jan 2024 11:47:40 -0500 Subject: [PATCH 59/76] Remove 'Generate Authors' workflow pion/.goassets#185 --- .github/workflows/generate-authors.yml | 23 ----------------------- AUTHORS.txt | 16 ---------------- 2 files changed, 39 deletions(-) delete mode 100644 .github/workflows/generate-authors.yml delete mode 100644 AUTHORS.txt diff --git a/.github/workflows/generate-authors.yml b/.github/workflows/generate-authors.yml deleted file mode 100644 index ec7446c..0000000 --- a/.github/workflows/generate-authors.yml +++ /dev/null @@ -1,23 +0,0 @@ -# -# DO NOT EDIT THIS FILE -# -# It is automatically copied from https://github.com/pion/.goassets repository. -# If this repository should have package specific CI config, -# remove the repository name from .goassets/.github/workflows/assets-sync.yml. -# -# If you want to update the shared CI config, send a PR to -# https://github.com/pion/.goassets instead of this repository. -# -# SPDX-FileCopyrightText: 2023 The Pion community -# SPDX-License-Identifier: MIT - -name: Generate Authors - -on: - pull_request: - -jobs: - generate: - uses: pion/.goassets/.github/workflows/generate-authors.reusable.yml@master - secrets: - token: ${{ secrets.PIONBOT_PRIVATE_KEY }} diff --git a/AUTHORS.txt b/AUTHORS.txt deleted file mode 100644 index cb933b2..0000000 --- a/AUTHORS.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Thank you to everyone that made Pion possible. If you are interested in contributing -# we would love to have you https://github.com/pion/webrtc/wiki/Contributing -# -# This file is auto generated, using git to list all individuals contributors. -# see https://github.com/pion/.goassets/blob/master/scripts/generate-authors.sh for the scripting -Atsushi Watanabe -backkem -Hugo Arregui -Michael MacDonald -Okamoto -Sean DuBois -Steffen Vogel -Woodrow Douglass - -# List of contributors not appearing in Git history - From 4e7b4238a822579346add8b5d4401641e84d8cf7 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Tue, 2 Jan 2024 12:32:19 -0500 Subject: [PATCH 60/76] Remove 'AUTHORS.txt' from README.md Relates to pion/.goassets#185 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 713f5e0..b9824ab 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ We are always looking to support **your projects**. Please reach out if you have If you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly) ### Contributing -Check out the [contributing wiki](https://github.com/pion/webrtc/wiki/Contributing) to join the group of amazing people making this project possible: [AUTHORS.txt](./AUTHORS.txt) +Check out the [contributing wiki](https://github.com/pion/webrtc/wiki/Contributing) to join the group of amazing people making this project possible ### License MIT License - see [LICENSE](LICENSE) for full text From 29593aebe98acab672632a75221f331c9f734557 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 2 Jan 2024 19:14:35 +0000 Subject: [PATCH 61/76] Update CI configs to v0.11.0 Update lint scripts and CI configs. --- .golangci.yml | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4e3eddf..6dd80c8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -29,7 +29,6 @@ linters: - bodyclose # checks whether HTTP response body is closed successfully - contextcheck # check the function whether use a non-inherited context - decorder # check declaration order and count of types, constants, variables and functions - - depguard # Go linter that checks if package imports are in a list of acceptable packages - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - dupl # Tool for code clone detection - durationcheck # check for two durations multiplied together @@ -63,7 +62,6 @@ linters: - importas # Enforces consistent import aliases - ineffassign # Detects when assignments to existing variables are not used - misspell # Finds commonly misspelled English words in comments - - nakedret # Finds naked returns in functions greater than a specified function length - nilerr # Finds the code that returns nil even if it checks that the error is not nil. - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. - noctx # noctx finds sending http request without context.Context @@ -81,6 +79,7 @@ linters: - wastedassign # wastedassign finds wasted assignment statements - whitespace # Tool for detection of leading and trailing whitespace disable: + - depguard # Go linter that checks if package imports are in a list of acceptable packages - containedctx # containedctx is a linter that detects struct contained context.Context field - cyclop # checks function and package cyclomatic complexity - exhaustivestruct # Checks if all struct's fields are initialized @@ -94,6 +93,7 @@ linters: - maintidx # maintidx measures the maintainability index of each function. - makezero # Finds slice declarations with non-zero initial length - maligned # Tool to detect Go structs that would take less memory if their fields were sorted + - nakedret # Finds naked returns in functions greater than a specified function length - nestif # Reports deeply nested if statements - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity - nolintlint # Reports ill-formed or insufficient nolint directives @@ -111,22 +111,11 @@ linters: issues: exclude-use-default: false exclude-rules: - # Allow complex tests, better to be self contained - - path: _test\.go + # Allow complex tests and examples, better to be self contained + - path: (examples|main\.go|_test\.go) linters: - - gocognit - forbidigo - - # Allow complex main function in examples - - path: examples - text: "of func `main` is high" - linters: - gocognit - - # Allow forbidden identifiers in examples - - path: examples - linters: - - forbidigo # Allow forbidden identifiers in CLI commands - path: cmd From 05c5f10ef60556401074d0f0a27fad247092b85f Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 5 Jan 2024 00:03:31 +0000 Subject: [PATCH 62/76] Update CI configs to v0.11.3 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 4 ++-- .github/workflows/tidy-check.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 31aada4..c8294ef 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,7 @@ jobs: uses: pion/.goassets/.github/workflows/test.reusable.yml@master strategy: matrix: - go: ['1.20', '1.19'] # auto-update/supported-go-version-list + go: ['1.21', '1.20'] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -32,7 +32,7 @@ jobs: uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master strategy: matrix: - go: ['1.20', '1.19'] # auto-update/supported-go-version-list + go: ['1.21', '1.20'] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index 4d346d4..33d6b50 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -22,4 +22,4 @@ jobs: tidy: uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master with: - go-version: '1.20' # auto-update/latest-go-version + go-version: '1.21' # auto-update/latest-go-version From 6d08bc6c8e8cdebb9b5950e1d440e92782ffa984 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:58:10 +0000 Subject: [PATCH 63/76] Update CI configs to v0.11.4 Update lint scripts and CI configs. --- .github/workflows/api.yaml | 20 ++++++++++++++++++++ .github/workflows/release.yml | 2 +- .github/workflows/test.yaml | 6 +++--- .github/workflows/tidy-check.yaml | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/api.yaml diff --git a/.github/workflows/api.yaml b/.github/workflows/api.yaml new file mode 100644 index 0000000..1032179 --- /dev/null +++ b/.github/workflows/api.yaml @@ -0,0 +1,20 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically copied from https://github.com/pion/.goassets repository. +# If this repository should have package specific CI config, +# remove the repository name from .goassets/.github/workflows/assets-sync.yml. +# +# If you want to update the shared CI config, send a PR to +# https://github.com/pion/.goassets instead of this repository. +# +# SPDX-FileCopyrightText: 2023 The Pion community +# SPDX-License-Identifier: MIT + +name: API +on: + pull_request: + +jobs: + check: + uses: pion/.goassets/.github/workflows/api.reusable.yml@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01227e2..0e72ea4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,4 +21,4 @@ jobs: release: uses: pion/.goassets/.github/workflows/release.reusable.yml@master with: - go-version: '1.20' # auto-update/latest-go-version + go-version: "1.22" # auto-update/latest-go-version diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c8294ef..ad6eb90 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,7 @@ jobs: uses: pion/.goassets/.github/workflows/test.reusable.yml@master strategy: matrix: - go: ['1.21', '1.20'] # auto-update/supported-go-version-list + go: ["1.22", "1.21"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -32,7 +32,7 @@ jobs: uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master strategy: matrix: - go: ['1.21', '1.20'] # auto-update/supported-go-version-list + go: ["1.22", "1.21"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -40,4 +40,4 @@ jobs: test-wasm: uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master with: - go-version: '1.20' # auto-update/latest-go-version + go-version: "1.22" # auto-update/latest-go-version diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index 33d6b50..417e730 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -22,4 +22,4 @@ jobs: tidy: uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master with: - go-version: '1.21' # auto-update/latest-go-version + go-version: "1.22" # auto-update/latest-go-version From 986a4ff4da05f06d03d7b3dc08f91402fbfaec65 Mon Sep 17 00:00:00 2001 From: Adrian Cable Date: Thu, 19 May 2022 17:48:57 -0700 Subject: [PATCH 64/76] Log to stderr by default, not stdout Go's log package writes to stderr by default (like all/most loggers). However pion's logger by default writes to stdout by default, even though pion's packages that use the logger override this to stderr. So projects using both will end up with a mix of log messages to stdout and stderr, which isn't desirable when trying to separate out the log output. The unit test for the pion logger also writes to stdout, which is inconsistent with pion's actual usage whereby the default output is overridden with stderr. This PR changes the default logging fd to stderr, and also changes the logger test to be consistent with pion's usage in writing to stderr. --- logger.go | 4 ++-- logging_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/logger.go b/logger.go index 5a78107..f655e52 100644 --- a/logger.go +++ b/logger.go @@ -156,7 +156,7 @@ func (ll *DefaultLeveledLogger) Errorf(format string, args ...interface{}) { // NewDefaultLeveledLoggerForScope returns a configured LeveledLogger func NewDefaultLeveledLoggerForScope(scope string, level LogLevel, writer io.Writer) *DefaultLeveledLogger { if writer == nil { - writer = os.Stdout + writer = os.Stderr } logger := &DefaultLeveledLogger{ writer: &loggerWriter{output: writer}, @@ -182,7 +182,7 @@ func NewDefaultLoggerFactory() *DefaultLoggerFactory { factory := DefaultLoggerFactory{} factory.DefaultLogLevel = LogLevelError factory.ScopeLevels = make(map[string]LogLevel) - factory.Writer = os.Stdout + factory.Writer = os.Stderr logLevels := map[string]LogLevel{ "DISABLE": LogLevelDisabled, diff --git a/logging_test.go b/logging_test.go index a7b40cd..daf5302 100644 --- a/logging_test.go +++ b/logging_test.go @@ -73,7 +73,7 @@ func testErrorLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { func TestDefaultLoggerFactory(t *testing.T) { f := logging.DefaultLoggerFactory{ - Writer: os.Stdout, + Writer: os.Stderr, DefaultLogLevel: logging.LogLevelWarn, ScopeLevels: map[string]logging.LogLevel{ "foo": logging.LogLevelDebug, @@ -100,7 +100,7 @@ func TestDefaultLoggerFactory(t *testing.T) { func TestDefaultLogger(t *testing.T) { logger := logging. - NewDefaultLeveledLoggerForScope("test1", logging.LogLevelWarn, os.Stdout) + NewDefaultLeveledLoggerForScope("test1", logging.LogLevelWarn, os.Stderr) testNoDebugLevel(t, logger) testWarnLevel(t, logger) @@ -109,7 +109,7 @@ func TestDefaultLogger(t *testing.T) { func TestSetLevel(t *testing.T) { logger := logging. - NewDefaultLeveledLoggerForScope("testSetLevel", logging.LogLevelWarn, os.Stdout) + NewDefaultLeveledLoggerForScope("testSetLevel", logging.LogLevelWarn, os.Stderr) testNoDebugLevel(t, logger) logger.SetLevel(logging.LogLevelDebug) From 1f0cca2e693258cf86e5b87fc6169801bf5ff321 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:41:33 +0000 Subject: [PATCH 65/76] Update CI configs to v0.11.7 Update lint scripts and CI configs. --- .golangci.yml | 7 +++---- .reuse/dep5 | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 6dd80c8..e06de4d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,7 +3,8 @@ linters-settings: govet: - check-shadowing: true + enable: + - shadow misspell: locale: US exhaustive: @@ -110,6 +111,7 @@ linters: issues: exclude-use-default: false + exclude-dirs-use-default: false exclude-rules: # Allow complex tests and examples, better to be self contained - path: (examples|main\.go|_test\.go) @@ -121,6 +123,3 @@ issues: - path: cmd linters: - forbidigo - -run: - skip-dirs-use-default: false diff --git a/.reuse/dep5 b/.reuse/dep5 index 717f0c1..eb7fac2 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -2,7 +2,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Pion Source: https://github.com/pion/ -Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum **/go.mod **/go.sum .eslintrc.json package.json examples/examples.json +Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum **/go.mod **/go.sum .eslintrc.json package.json examples.json sfu-ws/flutter/.gitignore sfu-ws/flutter/pubspec.yaml c-data-channels/webrtc.h examples/examples.json Copyright: 2023 The Pion community License: MIT From a6de6a9f773e12cf980b989677efb45628ed9138 Mon Sep 17 00:00:00 2001 From: Eric Daniels Date: Tue, 2 Apr 2024 14:12:38 -0400 Subject: [PATCH 66/76] Update go.mod version to 1.19 Relates to pion/webrtc#2292 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index a1b849b..c13a80b 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/pion/logging -go 1.12 +go 1.19 From 5bb0d6562572f5657ea987e8a223436984bef913 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Tue, 9 Apr 2024 03:09:38 +0000 Subject: [PATCH 67/76] Update CI configs to v0.11.12 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ad6eb90..08e4272 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -27,6 +27,7 @@ jobs: fail-fast: false with: go-version: ${{ matrix.go }} + secrets: inherit test-i386: uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master @@ -41,3 +42,4 @@ jobs: uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master with: go-version: "1.22" # auto-update/latest-go-version + secrets: inherit From 9dc3c2ead38979705e9d13780564ce9f9251bf45 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:17:18 +0000 Subject: [PATCH 68/76] Update CI configs to v0.11.15 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 6 +++--- .golangci.yml | 8 ++++---- logger.go | 10 +++++----- logging_test.go | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 08e4272..b024289 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,7 @@ jobs: uses: pion/.goassets/.github/workflows/test.reusable.yml@master strategy: matrix: - go: ["1.22", "1.21"] # auto-update/supported-go-version-list + go: ["1.23", "1.22"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -33,7 +33,7 @@ jobs: uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master strategy: matrix: - go: ["1.22", "1.21"] # auto-update/supported-go-version-list + go: ["1.23", "1.22"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -41,5 +41,5 @@ jobs: test-wasm: uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master with: - go-version: "1.22" # auto-update/latest-go-version + go-version: "1.23" # auto-update/latest-go-version secrets: inherit diff --git a/.golangci.yml b/.golangci.yml index e06de4d..a3235be 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,9 @@ # SPDX-FileCopyrightText: 2023 The Pion community # SPDX-License-Identifier: MIT +run: + timeout: 5m + linters-settings: govet: enable: @@ -48,7 +51,7 @@ linters: - goconst # Finds repeated strings that could be replaced by a constant - gocritic # The most opinionated Go source code linter - godox # Tool for detection of FIXME, TODO and other comment keywords - - goerr113 # Golang linter to check the errors handling expressions + - err113 # Golang linter to check the errors handling expressions - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification - gofumpt # Gofumpt checks whether code was gofumpt-ed. - goheader # Checks is file header matches to pattern @@ -83,17 +86,14 @@ linters: - depguard # Go linter that checks if package imports are in a list of acceptable packages - containedctx # containedctx is a linter that detects struct contained context.Context field - cyclop # checks function and package cyclomatic complexity - - exhaustivestruct # Checks if all struct's fields are initialized - funlen # Tool for detection of long functions - gocyclo # Computes and checks the cyclomatic complexity of functions - godot # Check if comments end in a period - gomnd # An analyzer to detect magic numbers. - - ifshort # Checks that your code uses short syntax for if-statements whenever possible - ireturn # Accept Interfaces, Return Concrete Types - lll # Reports long lines - maintidx # maintidx measures the maintainability index of each function. - makezero # Finds slice declarations with non-zero initial length - - maligned # Tool to detect Go structs that would take less memory if their fields were sorted - nakedret # Finds naked returns in functions greater than a specified function length - nestif # Reports deeply nested if statements - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity diff --git a/logger.go b/logger.go index f655e52..29fcc99 100644 --- a/logger.go +++ b/logger.go @@ -105,7 +105,7 @@ func (ll *DefaultLeveledLogger) SetLevel(newLevel LogLevel) { // Trace emits the preformatted message if the logger is at or below LogLevelTrace func (ll *DefaultLeveledLogger) Trace(msg string) { - ll.logf(ll.trace, LogLevelTrace, msg) + ll.logf(ll.trace, LogLevelTrace, msg) // nolint: govet } // Tracef formats and emits a message if the logger is at or below LogLevelTrace @@ -115,7 +115,7 @@ func (ll *DefaultLeveledLogger) Tracef(format string, args ...interface{}) { // Debug emits the preformatted message if the logger is at or below LogLevelDebug func (ll *DefaultLeveledLogger) Debug(msg string) { - ll.logf(ll.debug, LogLevelDebug, msg) + ll.logf(ll.debug, LogLevelDebug, msg) // nolint: govet } // Debugf formats and emits a message if the logger is at or below LogLevelDebug @@ -125,7 +125,7 @@ func (ll *DefaultLeveledLogger) Debugf(format string, args ...interface{}) { // Info emits the preformatted message if the logger is at or below LogLevelInfo func (ll *DefaultLeveledLogger) Info(msg string) { - ll.logf(ll.info, LogLevelInfo, msg) + ll.logf(ll.info, LogLevelInfo, msg) // nolint: govet } // Infof formats and emits a message if the logger is at or below LogLevelInfo @@ -135,7 +135,7 @@ func (ll *DefaultLeveledLogger) Infof(format string, args ...interface{}) { // Warn emits the preformatted message if the logger is at or below LogLevelWarn func (ll *DefaultLeveledLogger) Warn(msg string) { - ll.logf(ll.warn, LogLevelWarn, msg) + ll.logf(ll.warn, LogLevelWarn, msg) // nolint: govet } // Warnf formats and emits a message if the logger is at or below LogLevelWarn @@ -145,7 +145,7 @@ func (ll *DefaultLeveledLogger) Warnf(format string, args ...interface{}) { // Error emits the preformatted message if the logger is at or below LogLevelError func (ll *DefaultLeveledLogger) Error(msg string) { - ll.logf(ll.err, LogLevelError, msg) + ll.logf(ll.err, LogLevelError, msg) // nolint: govet } // Errorf formats and emits a message if the logger is at or below LogLevelError diff --git a/logging_test.go b/logging_test.go index daf5302..7f7865e 100644 --- a/logging_test.go +++ b/logging_test.go @@ -35,7 +35,7 @@ func testDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { if !strings.Contains(outBuf.String(), dbgMsg) { t.Errorf("Expected to find %q in %q, but didn't", dbgMsg, outBuf.String()) } - logger.Debugf(dbgMsg) + logger.Debugf(dbgMsg) // nolint: govet if !strings.Contains(outBuf.String(), dbgMsg) { t.Errorf("Expected to find %q in %q, but didn't", dbgMsg, outBuf.String()) } @@ -50,7 +50,7 @@ func testWarnLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { if !strings.Contains(outBuf.String(), warnMsg) { t.Errorf("Expected to find %q in %q, but didn't", warnMsg, outBuf.String()) } - logger.Warnf(warnMsg) + logger.Warnf(warnMsg) // nolint: govet if !strings.Contains(outBuf.String(), warnMsg) { t.Errorf("Expected to find %q in %q, but didn't", warnMsg, outBuf.String()) } @@ -65,7 +65,7 @@ func testErrorLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { if !strings.Contains(outBuf.String(), errMsg) { t.Errorf("Expected to find %q in %q, but didn't", errMsg, outBuf.String()) } - logger.Errorf(errMsg) + logger.Errorf(errMsg) // nolint: govet if !strings.Contains(outBuf.String(), errMsg) { t.Errorf("Expected to find %q in %q, but didn't", errMsg, outBuf.String()) } From b6abcca03b4b41b0deb49d326a3a5000f57ec71a Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Mon, 26 Aug 2024 11:29:36 -0400 Subject: [PATCH 69/76] Update go.mod version to 1.20 Relates to pion/webrtc#2869 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c13a80b..327e01f 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/pion/logging -go 1.19 +go 1.20 From 8466bdebfcc9cd1585a84cee492cc2cd004c3e8e Mon Sep 17 00:00:00 2001 From: Joe Turk Date: Wed, 8 Jan 2025 21:26:03 -0600 Subject: [PATCH 70/76] Upgrade golangci, Enable more linters Upgrade `golangci` version, Introduce more linters. Relates to pion/.goassets#220 --- .golangci.yml | 49 +++++++++++++++++++++++++--------------- logger.go | 60 ++++++++++++++++++++++++++++--------------------- logging_test.go | 14 +++++++++--- scoped.go | 22 +++++++++--------- 4 files changed, 88 insertions(+), 57 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a3235be..50211be 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -25,17 +25,32 @@ linters-settings: - ^os.Exit$ - ^panic$ - ^print(ln)?$ + varnamelen: + max-distance: 12 + min-name-length: 2 + ignore-type-assert-ok: true + ignore-map-index-ok: true + ignore-chan-recv-ok: true + ignore-decls: + - i int + - n int + - w io.Writer + - r io.Reader + - b []byte linters: enable: - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers - bidichk # Checks for dangerous unicode character sequences - bodyclose # checks whether HTTP response body is closed successfully + - containedctx # containedctx is a linter that detects struct contained context.Context field - contextcheck # check the function whether use a non-inherited context + - cyclop # checks function and package cyclomatic complexity - decorder # check declaration order and count of types, constants, variables and functions - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - dupl # Tool for code clone detection - durationcheck # check for two durations multiplied together + - err113 # Golang linter to check the errors handling expressions - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases - 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. - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. @@ -44,20 +59,20 @@ linters: - exportloopref # checks for pointers to enclosing loop variables - forbidigo # Forbids identifiers - forcetypeassert # finds forced type assertions + - funlen # Tool for detection of long functions - gci # Gci control golang package import order and make it always deterministic. - gochecknoglobals # Checks that no globals are present in Go code - - gochecknoinits # Checks that no init functions are present in Go code - gocognit # Computes and checks the cognitive complexity of functions - goconst # Finds repeated strings that could be replaced by a constant - gocritic # The most opinionated Go source code linter + - gocyclo # Computes and checks the cyclomatic complexity of functions + - godot # Check if comments end in a period - godox # Tool for detection of FIXME, TODO and other comment keywords - - err113 # Golang linter to check the errors handling expressions - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification - gofumpt # Gofumpt checks whether code was gofumpt-ed. - goheader # Checks is file header matches to pattern - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - - 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. - goprintffuncname # Checks that printf-like functions are named with `f` at the end - gosec # Inspects source code for security problems - gosimple # Linter for Go source code that specializes in simplifying a code @@ -65,9 +80,15 @@ linters: - grouper # An analyzer to analyze expression groups. - importas # Enforces consistent import aliases - ineffassign # Detects when assignments to existing variables are not used + - lll # Reports long lines + - maintidx # maintidx measures the maintainability index of each function. + - makezero # Finds slice declarations with non-zero initial length - misspell # Finds commonly misspelled English words in comments + - nakedret # Finds naked returns in functions greater than a specified function length + - nestif # Reports deeply nested if statements - nilerr # Finds the code that returns nil even if it checks that the error is not nil. - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. + - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity - noctx # noctx finds sending http request without context.Context - predeclared # find code that shadows one of Go's predeclared identifiers - revive # golint replacement, finds style mistakes @@ -75,28 +96,21 @@ linters: - stylecheck # Stylecheck is a replacement for golint - tagliatelle # Checks the struct tags. - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 - - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes + - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code - unconvert # Remove unnecessary type conversions - unparam # Reports unused function parameters - unused # Checks Go code for unused constants, variables, functions and types + - varnamelen # checks that the length of a variable's name matches its scope - wastedassign # wastedassign finds wasted assignment statements - whitespace # Tool for detection of leading and trailing whitespace disable: - depguard # Go linter that checks if package imports are in a list of acceptable packages - - containedctx # containedctx is a linter that detects struct contained context.Context field - - cyclop # checks function and package cyclomatic complexity - - funlen # Tool for detection of long functions - - gocyclo # Computes and checks the cyclomatic complexity of functions - - godot # Check if comments end in a period - - gomnd # An analyzer to detect magic numbers. + - gochecknoinits # Checks that no init functions are present in Go code + - 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. + - interfacebloat # A linter that checks length of interface. - ireturn # Accept Interfaces, Return Concrete Types - - lll # Reports long lines - - maintidx # maintidx measures the maintainability index of each function. - - makezero # Finds slice declarations with non-zero initial length - - nakedret # Finds naked returns in functions greater than a specified function length - - nestif # Reports deeply nested if statements - - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity + - mnd # An analyzer to detect magic numbers - nolintlint # Reports ill-formed or insufficient nolint directives - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test - prealloc # Finds slice declarations that could potentially be preallocated @@ -104,8 +118,7 @@ linters: - rowserrcheck # checks whether Err of rows is checked successfully - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. - testpackage # linter that makes you use a separate _test package - - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers - - varnamelen # checks that the length of a variable's name matches its scope + - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes - wrapcheck # Checks that errors returned from external packages are wrapped - wsl # Whitespace Linter - Forces you to use empty lines! diff --git a/logger.go b/logger.go index 29fcc99..6055c8d 100644 --- a/logger.go +++ b/logger.go @@ -13,8 +13,8 @@ import ( "sync" ) -// Use this abstraction to ensure thread-safe access to the logger's io.Writer -// (which could change at runtime) +// Use this abstraction to ensure thread-safe access to the logger's io.Writer. +// (which could change at runtime). type loggerWriter struct { sync.RWMutex output io.Writer @@ -29,11 +29,12 @@ func (lw *loggerWriter) SetOutput(output io.Writer) { func (lw *loggerWriter) Write(data []byte) (int, error) { lw.RLock() defer lw.RUnlock() + return lw.output.Write(data) } -// DefaultLeveledLogger encapsulates functionality for providing logging at -// user-defined levels +// DefaultLeveledLogger encapsulates functionality for providing logging at. +// user-defined levels. type DefaultLeveledLogger struct { level LogLevel writer *loggerWriter @@ -45,44 +46,50 @@ type DefaultLeveledLogger struct { } // WithTraceLogger is a chainable configuration function which sets the -// Trace-level logger +// Trace-level logger. func (ll *DefaultLeveledLogger) WithTraceLogger(log *log.Logger) *DefaultLeveledLogger { ll.trace = log + return ll } // WithDebugLogger is a chainable configuration function which sets the -// Debug-level logger +// Debug-level logger. func (ll *DefaultLeveledLogger) WithDebugLogger(log *log.Logger) *DefaultLeveledLogger { ll.debug = log + return ll } // WithInfoLogger is a chainable configuration function which sets the -// Info-level logger +// Info-level logger. func (ll *DefaultLeveledLogger) WithInfoLogger(log *log.Logger) *DefaultLeveledLogger { ll.info = log + return ll } // WithWarnLogger is a chainable configuration function which sets the -// Warn-level logger +// Warn-level logger. func (ll *DefaultLeveledLogger) WithWarnLogger(log *log.Logger) *DefaultLeveledLogger { ll.warn = log + return ll } // WithErrorLogger is a chainable configuration function which sets the -// Error-level logger +// Error-level logger. func (ll *DefaultLeveledLogger) WithErrorLogger(log *log.Logger) *DefaultLeveledLogger { ll.err = log + return ll } // WithOutput is a chainable configuration function which sets the logger's -// logging output to the supplied io.Writer +// logging output to the supplied io.Writer. func (ll *DefaultLeveledLogger) WithOutput(output io.Writer) *DefaultLeveledLogger { ll.writer.SetOutput(output) + return ll } @@ -98,62 +105,62 @@ func (ll *DefaultLeveledLogger) logf(logger *log.Logger, level LogLevel, format } } -// SetLevel sets the logger's logging level +// SetLevel sets the logger's logging level. func (ll *DefaultLeveledLogger) SetLevel(newLevel LogLevel) { ll.level.Set(newLevel) } -// Trace emits the preformatted message if the logger is at or below LogLevelTrace +// Trace emits the preformatted message if the logger is at or below LogLevelTrace. func (ll *DefaultLeveledLogger) Trace(msg string) { ll.logf(ll.trace, LogLevelTrace, msg) // nolint: govet } -// Tracef formats and emits a message if the logger is at or below LogLevelTrace +// Tracef formats and emits a message if the logger is at or below LogLevelTrace. func (ll *DefaultLeveledLogger) Tracef(format string, args ...interface{}) { ll.logf(ll.trace, LogLevelTrace, format, args...) } -// Debug emits the preformatted message if the logger is at or below LogLevelDebug +// Debug emits the preformatted message if the logger is at or below LogLevelDebug. func (ll *DefaultLeveledLogger) Debug(msg string) { ll.logf(ll.debug, LogLevelDebug, msg) // nolint: govet } -// Debugf formats and emits a message if the logger is at or below LogLevelDebug +// Debugf formats and emits a message if the logger is at or below LogLevelDebug. func (ll *DefaultLeveledLogger) Debugf(format string, args ...interface{}) { ll.logf(ll.debug, LogLevelDebug, format, args...) } -// Info emits the preformatted message if the logger is at or below LogLevelInfo +// Info emits the preformatted message if the logger is at or below LogLevelInfo. func (ll *DefaultLeveledLogger) Info(msg string) { ll.logf(ll.info, LogLevelInfo, msg) // nolint: govet } -// Infof formats and emits a message if the logger is at or below LogLevelInfo +// Infof formats and emits a message if the logger is at or below LogLevelInfo. func (ll *DefaultLeveledLogger) Infof(format string, args ...interface{}) { ll.logf(ll.info, LogLevelInfo, format, args...) } -// Warn emits the preformatted message if the logger is at or below LogLevelWarn +// Warn emits the preformatted message if the logger is at or below LogLevelWarn. func (ll *DefaultLeveledLogger) Warn(msg string) { ll.logf(ll.warn, LogLevelWarn, msg) // nolint: govet } -// Warnf formats and emits a message if the logger is at or below LogLevelWarn +// Warnf formats and emits a message if the logger is at or below LogLevelWarn. func (ll *DefaultLeveledLogger) Warnf(format string, args ...interface{}) { ll.logf(ll.warn, LogLevelWarn, format, args...) } -// Error emits the preformatted message if the logger is at or below LogLevelError +// Error emits the preformatted message if the logger is at or below LogLevelError. func (ll *DefaultLeveledLogger) Error(msg string) { ll.logf(ll.err, LogLevelError, msg) // nolint: govet } -// Errorf formats and emits a message if the logger is at or below LogLevelError +// Errorf formats and emits a message if the logger is at or below LogLevelError. func (ll *DefaultLeveledLogger) Errorf(format string, args ...interface{}) { ll.logf(ll.err, LogLevelError, format, args...) } -// NewDefaultLeveledLoggerForScope returns a configured LeveledLogger +// NewDefaultLeveledLoggerForScope returns a configured LeveledLogger. func NewDefaultLeveledLoggerForScope(scope string, level LogLevel, writer io.Writer) *DefaultLeveledLogger { if writer == nil { writer = os.Stderr @@ -162,6 +169,7 @@ func NewDefaultLeveledLoggerForScope(scope string, level LogLevel, writer io.Wri writer: &loggerWriter{output: writer}, level: level, } + return logger. WithTraceLogger(log.New(logger.writer, fmt.Sprintf("%s TRACE: ", scope), log.Lmicroseconds|log.Lshortfile)). WithDebugLogger(log.New(logger.writer, fmt.Sprintf("%s DEBUG: ", scope), log.Lmicroseconds|log.Lshortfile)). @@ -170,14 +178,14 @@ func NewDefaultLeveledLoggerForScope(scope string, level LogLevel, writer io.Wri WithErrorLogger(log.New(logger.writer, fmt.Sprintf("%s ERROR: ", scope), log.LstdFlags)) } -// DefaultLoggerFactory define levels by scopes and creates new DefaultLeveledLogger +// DefaultLoggerFactory define levels by scopes and creates new DefaultLeveledLogger. type DefaultLoggerFactory struct { Writer io.Writer DefaultLogLevel LogLevel ScopeLevels map[string]LogLevel } -// NewDefaultLoggerFactory creates a new DefaultLoggerFactory +// NewDefaultLoggerFactory creates a new DefaultLoggerFactory. func NewDefaultLoggerFactory() *DefaultLoggerFactory { factory := DefaultLoggerFactory{} factory.DefaultLogLevel = LogLevelError @@ -206,6 +214,7 @@ func NewDefaultLoggerFactory() *DefaultLoggerFactory { if strings.ToLower(env) == "all" { factory.DefaultLogLevel = level + continue } @@ -218,7 +227,7 @@ func NewDefaultLoggerFactory() *DefaultLoggerFactory { return &factory } -// NewLogger returns a configured LeveledLogger for the given , argsscope +// NewLogger returns a configured LeveledLogger for the given, argsscope. func (f *DefaultLoggerFactory) NewLogger(scope string) LeveledLogger { logLevel := f.DefaultLogLevel if f.ScopeLevels != nil { @@ -228,5 +237,6 @@ func (f *DefaultLoggerFactory) NewLogger(scope string) LeveledLogger { logLevel = scopeLevel } } + return NewDefaultLeveledLoggerForScope(scope, logLevel, f.Writer) } diff --git a/logging_test.go b/logging_test.go index 7f7865e..6bac671 100644 --- a/logging_test.go +++ b/logging_test.go @@ -13,6 +13,8 @@ import ( ) func testNoDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { + t.Helper() + var outBuf bytes.Buffer logger.WithOutput(&outBuf) @@ -27,6 +29,8 @@ func testNoDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { } func testDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { + t.Helper() + var outBuf bytes.Buffer logger.WithOutput(&outBuf) @@ -42,6 +46,8 @@ func testDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { } func testWarnLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { + t.Helper() + var outBuf bytes.Buffer logger.WithOutput(&outBuf) @@ -57,6 +63,8 @@ func testWarnLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { } func testErrorLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { + t.Helper() + var outBuf bytes.Buffer logger.WithOutput(&outBuf) @@ -72,7 +80,7 @@ func testErrorLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { } func TestDefaultLoggerFactory(t *testing.T) { - f := logging.DefaultLoggerFactory{ + factory := logging.DefaultLoggerFactory{ Writer: os.Stderr, DefaultLogLevel: logging.LogLevelWarn, ScopeLevels: map[string]logging.LogLevel{ @@ -80,7 +88,7 @@ func TestDefaultLoggerFactory(t *testing.T) { }, } - logger := f.NewLogger("baz") + logger := factory.NewLogger("baz") bazLogger, ok := logger.(*logging.DefaultLeveledLogger) if !ok { t.Error("Invalid logger type") @@ -89,7 +97,7 @@ func TestDefaultLoggerFactory(t *testing.T) { testNoDebugLevel(t, bazLogger) testWarnLevel(t, bazLogger) - logger = f.NewLogger("foo") + logger = factory.NewLogger("foo") fooLogger, ok := logger.(*logging.DefaultLeveledLogger) if !ok { t.Error("Invalid logger type") diff --git a/scoped.go b/scoped.go index 24cf676..7b3a550 100644 --- a/scoped.go +++ b/scoped.go @@ -7,15 +7,15 @@ import ( "sync/atomic" ) -// LogLevel represents the level at which the logger will emit log messages +// LogLevel represents the level at which the logger will emit log messages. type LogLevel int32 -// Set updates the LogLevel to the supplied value +// Set updates the LogLevel to the supplied value. func (ll *LogLevel) Set(newLevel LogLevel) { atomic.StoreInt32((*int32)(ll), int32(newLevel)) } -// Get retrieves the current LogLevel value +// Get retrieves the current LogLevel value. func (ll *LogLevel) Get() LogLevel { return LogLevel(atomic.LoadInt32((*int32)(ll))) } @@ -40,22 +40,22 @@ func (ll LogLevel) String() string { } const ( - // LogLevelDisabled completely disables logging of any events + // LogLevelDisabled completely disables logging of any events. LogLevelDisabled LogLevel = iota // LogLevelError is for fatal errors which should be handled by user code, - // but are logged to ensure that they are seen + // but are logged to ensure that they are seen. LogLevelError - // LogLevelWarn is for logging abnormal, but non-fatal library operation + // LogLevelWarn is for logging abnormal, but non-fatal library operation. LogLevelWarn - // LogLevelInfo is for logging normal library operation (e.g. state transitions, etc.) + // LogLevelInfo is for logging normal library operation (e.g. state transitions, etc.). LogLevelInfo - // LogLevelDebug is for logging low-level library information (e.g. internal operations) + // LogLevelDebug is for logging low-level library information (e.g. internal operations). LogLevelDebug - // LogLevelTrace is for logging very low-level library information (e.g. network traces) + // LogLevelTrace is for logging very low-level library information (e.g. network traces). LogLevelTrace ) -// LeveledLogger is the basic pion Logger interface +// LeveledLogger is the basic pion Logger interface. type LeveledLogger interface { Trace(msg string) Tracef(format string, args ...interface{}) @@ -69,7 +69,7 @@ type LeveledLogger interface { Errorf(format string, args ...interface{}) } -// LoggerFactory is the basic pion LoggerFactory interface +// LoggerFactory is the basic pion LoggerFactory interface. type LoggerFactory interface { NewLogger(scope string) LeveledLogger } From 770cd0b2bbb63d76bc06c128f626cd78099eb76a Mon Sep 17 00:00:00 2001 From: Joe Turk Date: Fri, 10 Jan 2025 11:55:39 -0600 Subject: [PATCH 71/76] Fix flaky PION_LOG_*, more tests (#117) #### Description I was tracking an issue with video feedback when I noticed the logs were flaky. Initially, I thought it was a bug, but I later discovered that PION_LOG_*=all is unreliable due to how the range map is ordered. Added tests to cover everything. --- logger.go | 4 +- logging_test.go | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 1 deletion(-) diff --git a/logger.go b/logger.go index 6055c8d..eb1e56a 100644 --- a/logger.go +++ b/logger.go @@ -213,7 +213,9 @@ func NewDefaultLoggerFactory() *DefaultLoggerFactory { } if strings.ToLower(env) == "all" { - factory.DefaultLogLevel = level + if factory.DefaultLogLevel < level { + factory.DefaultLogLevel = level + } continue } diff --git a/logging_test.go b/logging_test.go index 6bac671..735ec63 100644 --- a/logging_test.go +++ b/logging_test.go @@ -79,6 +79,50 @@ func testErrorLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { } } +func testTraceLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { + t.Helper() + + var outBuf bytes.Buffer + logger.WithOutput(&outBuf) + + traceMsg := "trace message" + logger.Trace(traceMsg) + if !strings.Contains(outBuf.String(), traceMsg) { + t.Errorf("Expected to find %q in %q, but didn't", traceMsg, outBuf.String()) + } + logger.Tracef(traceMsg) // nolint: govet + if !strings.Contains(outBuf.String(), traceMsg) { + t.Errorf("Expected to find %q in %q, but didn't", traceMsg, outBuf.String()) + } +} + +func testInfoLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { + t.Helper() + + var outBuf bytes.Buffer + logger.WithOutput(&outBuf) + + infoMsg := "info message" + logger.Info(infoMsg) + if !strings.Contains(outBuf.String(), infoMsg) { + t.Errorf("Expected to find %q in %q, but didn't", infoMsg, outBuf.String()) + } + logger.Infof(infoMsg) // nolint: govet + if !strings.Contains(outBuf.String(), infoMsg) { + t.Errorf("Expected to find %q in %q, but didn't", infoMsg, outBuf.String()) + } +} + +func testAllLevels(t *testing.T, logger *logging.DefaultLeveledLogger) { + t.Helper() + + testDebugLevel(t, logger) + testWarnLevel(t, logger) + testErrorLevel(t, logger) + testTraceLevel(t, logger) + testInfoLevel(t, logger) +} + func TestDefaultLoggerFactory(t *testing.T) { factory := logging.DefaultLoggerFactory{ Writer: os.Stderr, @@ -115,6 +159,96 @@ func TestDefaultLogger(t *testing.T) { testErrorLevel(t, logger) } +func TestNewDefaultLoggerFactory(t *testing.T) { + factory := logging.NewDefaultLoggerFactory() + + disabled := factory.NewLogger("DISABLE") + errorLevel := factory.NewLogger("ERROR") + warnLevel := factory.NewLogger("WARN") + infoLevel := factory.NewLogger("INFO") + debugLevel := factory.NewLogger("DEBUG") + traceLevel := factory.NewLogger("TRACE") + + disabledLogger, ok := disabled.(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Missing disabled logger") + } + + errorLogger, ok := errorLevel.(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Missing error logger") + } + + warnLogger, ok := warnLevel.(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Missing warn logger") + } + + infoLogger, ok := infoLevel.(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Missing info logger") + } + + debugLogger, ok := debugLevel.(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Missing debug logger") + } + + traceLogger, ok := traceLevel.(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Missing trace logger") + } + + testNoDebugLevel(t, disabledLogger) + testNoDebugLevel(t, errorLogger) + testNoDebugLevel(t, warnLogger) + testNoDebugLevel(t, infoLogger) + testNoDebugLevel(t, debugLogger) + testNoDebugLevel(t, traceLogger) +} + +func TestNewDefaultLoggerFactoryLogAll(t *testing.T) { + t.Setenv("PION_LOG_ERROR", "all") + t.Setenv("PION_LOG_WARN", "all") + t.Setenv("PION_LOG_INFO", "all") + t.Setenv("PION_LOG_DEBUG", "all") + t.Setenv("PION_LOG_TRACE", "all") + + factory := logging.NewDefaultLoggerFactory() + + testAPI, ok := factory.NewLogger("test").(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Invalid logger factory type") + } + + testAllLevels(t, testAPI) +} + +func TestNewDefaultLoggerFactorySpecifcScopes(t *testing.T) { + t.Setenv("PION_LOG_DEBUG", "feature,rtp-logger") + + factory := logging.NewDefaultLoggerFactory() + + feature, ok := factory.NewLogger("feature").(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Invalid logger factory type") + } + + rtp, ok := factory.NewLogger("rtp-logger").(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Invalid logger factory type") + } + + noScope, ok := factory.NewLogger("no-scope").(*logging.DefaultLeveledLogger) + if !ok { + t.Error("Invalid logger factory type") + } + + testDebugLevel(t, feature) + testDebugLevel(t, rtp) + testNoDebugLevel(t, noScope) +} + func TestSetLevel(t *testing.T) { logger := logging. NewDefaultLeveledLoggerForScope("testSetLevel", logging.LogLevelWarn, os.Stderr) @@ -123,3 +257,38 @@ func TestSetLevel(t *testing.T) { logger.SetLevel(logging.LogLevelDebug) testDebugLevel(t, logger) } + +func TestLogLevel(t *testing.T) { + logLevel := logging.LogLevelDisabled + + logLevel.Set(logging.LogLevelError) + if logLevel.Get() != logging.LogLevelError { + t.Error("LogLevel was not set to LogLevelError") + } +} + +func TestLogLevelString(t *testing.T) { + expected := map[logging.LogLevel]string{ + logging.LogLevelDisabled: "Disabled", + logging.LogLevelError: "Error", + logging.LogLevelWarn: "Warn", + logging.LogLevelInfo: "Info", + logging.LogLevelDebug: "Debug", + logging.LogLevelTrace: "Trace", + logging.LogLevel(999): "UNKNOWN", + } + + for level, expectedStr := range expected { + if level.String() != expectedStr { + t.Errorf("Expected %q, got %q", expectedStr, level.String()) + } + } +} + +func TestNewDefaultLoggerStderr(t *testing.T) { + logger := logging.NewDefaultLeveledLoggerForScope("test", logging.LogLevelWarn, nil) + + testNoDebugLevel(t, logger) + testWarnLevel(t, logger) + testErrorLevel(t, logger) +} From 7195595b394f0cfb3e7aad8e20a5dc355f07b364 Mon Sep 17 00:00:00 2001 From: Pion Bot <59523206+pionbot@users.noreply.github.com> Date: Thu, 13 Feb 2025 23:26:43 -0500 Subject: [PATCH 72/76] Update CI configs to v0.11.17 Update lint scripts and CI configs. --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 50211be..88cb4fb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -59,7 +59,6 @@ linters: - exportloopref # checks for pointers to enclosing loop variables - forbidigo # Forbids identifiers - forcetypeassert # finds forced type assertions - - funlen # Tool for detection of long functions - gci # Gci control golang package import order and make it always deterministic. - gochecknoglobals # Checks that no globals are present in Go code - gocognit # Computes and checks the cognitive complexity of functions @@ -106,6 +105,7 @@ linters: - whitespace # Tool for detection of leading and trailing whitespace disable: - depguard # Go linter that checks if package imports are in a list of acceptable packages + - funlen # Tool for detection of long functions - gochecknoinits # Checks that no init functions are present in Go code - 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. - interfacebloat # A linter that checks length of interface. From a1a340ca2f38aedba1a2c0ba3ba4e2356c8b2002 Mon Sep 17 00:00:00 2001 From: Pion Bot <59523206+pionbot@users.noreply.github.com> Date: Thu, 13 Feb 2025 23:40:57 -0500 Subject: [PATCH 73/76] Update CI configs to v0.11.18 (#119) Update lint scripts and CI configs. --- .reuse/dep5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.reuse/dep5 b/.reuse/dep5 index eb7fac2..4ce0569 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -6,6 +6,6 @@ Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum Copyright: 2023 The Pion community License: MIT -Files: testdata/fuzz/* **/testdata/fuzz/* api/*.txt +Files: testdata/seed/* testdata/fuzz/* **/testdata/fuzz/* api/*.txt Copyright: 2023 The Pion community License: CC0-1.0 From 2d5402f6579f2579cc51a5bd9c1fac127a781abb Mon Sep 17 00:00:00 2001 From: RyanPotat Date: Mon, 24 Mar 2025 08:12:32 +0000 Subject: [PATCH 74/76] Update lint rules, use testify/assert --- .golangci.yml | 9 +++- go.mod | 8 ++++ go.sum | 10 ++++ logging_test.go | 123 ++++++++++++++++++------------------------------ 4 files changed, 71 insertions(+), 79 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 88cb4fb..120faf2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -19,12 +19,16 @@ linters-settings: recommendations: - errors forbidigo: + analyze-types: true forbid: - ^fmt.Print(f|ln)?$ - ^log.(Panic|Fatal|Print)(f|ln)?$ - ^os.Exit$ - ^panic$ - ^print(ln)?$ + - p: ^testing.T.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)$ + pkg: ^testing$ + msg: "use testify/assert instead" varnamelen: max-distance: 12 min-name-length: 2 @@ -127,9 +131,12 @@ issues: exclude-dirs-use-default: false exclude-rules: # Allow complex tests and examples, better to be self contained - - path: (examples|main\.go|_test\.go) + - path: (examples|main\.go) linters: + - gocognit - forbidigo + - path: _test\.go + linters: - gocognit # Allow forbidden identifiers in CLI commands diff --git a/go.mod b/go.mod index 327e01f..acc2be9 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,11 @@ module github.com/pion/logging go 1.20 + +require github.com/stretchr/testify v1.10.0 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum index e69de29..713a0b4 100644 --- a/go.sum +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/logging_test.go b/logging_test.go index 735ec63..72faea0 100644 --- a/logging_test.go +++ b/logging_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/pion/logging" + "github.com/stretchr/testify/assert" ) func testNoDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { @@ -19,13 +20,10 @@ func testNoDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { logger.WithOutput(&outBuf) logger.Debug("this shouldn't be logged") - if outBuf.Len() > 0 { - t.Error("Debug was logged when it shouldn't have been") - } + assert.GreaterOrEqual(t, 0, outBuf.Len(), "Debug was logged when it shouldn't have been") + logger.Debugf("this shouldn't be logged") - if outBuf.Len() > 0 { - t.Error("Debug was logged when it shouldn't have been") - } + assert.GreaterOrEqual(t, 0, outBuf.Len(), "Debug was logged when it shouldn't have been") } func testDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { @@ -36,13 +34,14 @@ func testDebugLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { dbgMsg := "this is a debug message" logger.Debug(dbgMsg) - if !strings.Contains(outBuf.String(), dbgMsg) { - t.Errorf("Expected to find %q in %q, but didn't", dbgMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), dbgMsg), + "Expected to find %q in %q, but didn't", dbgMsg, outBuf.String()) + assert.Truef(t, strings.Contains(outBuf.String(), dbgMsg), + "Expected to find %q in %q, but didn't", dbgMsg, outBuf.String()) + logger.Debugf(dbgMsg) // nolint: govet - if !strings.Contains(outBuf.String(), dbgMsg) { - t.Errorf("Expected to find %q in %q, but didn't", dbgMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), dbgMsg), + "Expected to find %q in %q, but didn't", dbgMsg, outBuf.String()) } func testWarnLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { @@ -53,13 +52,12 @@ func testWarnLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { warnMsg := "this is a warning message" logger.Warn(warnMsg) - if !strings.Contains(outBuf.String(), warnMsg) { - t.Errorf("Expected to find %q in %q, but didn't", warnMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), warnMsg), + "Expected to find %q in %q, but didn't", warnMsg, outBuf.String()) + logger.Warnf(warnMsg) // nolint: govet - if !strings.Contains(outBuf.String(), warnMsg) { - t.Errorf("Expected to find %q in %q, but didn't", warnMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), warnMsg), + "Expected to find %q in %q, but didn't", warnMsg, outBuf.String()) } func testErrorLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { @@ -70,13 +68,12 @@ func testErrorLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { errMsg := "this is an error message" logger.Error(errMsg) - if !strings.Contains(outBuf.String(), errMsg) { - t.Errorf("Expected to find %q in %q, but didn't", errMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), errMsg), + "Expected to find %q in %q but didn't", errMsg, outBuf.String()) + logger.Errorf(errMsg) // nolint: govet - if !strings.Contains(outBuf.String(), errMsg) { - t.Errorf("Expected to find %q in %q, but didn't", errMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), errMsg), + "Expected to find %q in %q but didn't", errMsg, outBuf.String()) } func testTraceLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { @@ -87,13 +84,12 @@ func testTraceLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { traceMsg := "trace message" logger.Trace(traceMsg) - if !strings.Contains(outBuf.String(), traceMsg) { - t.Errorf("Expected to find %q in %q, but didn't", traceMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), traceMsg), + "Expected to find %q in %q but didn't", traceMsg, outBuf.String()) + logger.Tracef(traceMsg) // nolint: govet - if !strings.Contains(outBuf.String(), traceMsg) { - t.Errorf("Expected to find %q in %q, but didn't", traceMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), traceMsg), + "Expected to find %q in %q but didn't", traceMsg, outBuf.String()) } func testInfoLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { @@ -104,13 +100,12 @@ func testInfoLevel(t *testing.T, logger *logging.DefaultLeveledLogger) { infoMsg := "info message" logger.Info(infoMsg) - if !strings.Contains(outBuf.String(), infoMsg) { - t.Errorf("Expected to find %q in %q, but didn't", infoMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), infoMsg), + "Expected to find %q in %q but didn't", infoMsg, outBuf.String()) + logger.Infof(infoMsg) // nolint: govet - if !strings.Contains(outBuf.String(), infoMsg) { - t.Errorf("Expected to find %q in %q, but didn't", infoMsg, outBuf.String()) - } + assert.Truef(t, strings.Contains(outBuf.String(), infoMsg), + "Expected to find %q in %q but didn't", infoMsg, outBuf.String()) } func testAllLevels(t *testing.T, logger *logging.DefaultLeveledLogger) { @@ -134,18 +129,14 @@ func TestDefaultLoggerFactory(t *testing.T) { logger := factory.NewLogger("baz") bazLogger, ok := logger.(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Invalid logger type") - } + assert.True(t, ok, "Invalid logger type") testNoDebugLevel(t, bazLogger) testWarnLevel(t, bazLogger) logger = factory.NewLogger("foo") fooLogger, ok := logger.(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Invalid logger type") - } + assert.True(t, ok, "Invalid logger type") testDebugLevel(t, fooLogger) } @@ -170,34 +161,22 @@ func TestNewDefaultLoggerFactory(t *testing.T) { traceLevel := factory.NewLogger("TRACE") disabledLogger, ok := disabled.(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Missing disabled logger") - } + assert.True(t, ok, "Missing disabled logger") errorLogger, ok := errorLevel.(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Missing error logger") - } + assert.True(t, ok, "Missing error logger") warnLogger, ok := warnLevel.(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Missing warn logger") - } + assert.True(t, ok, "Missing warn logger") infoLogger, ok := infoLevel.(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Missing info logger") - } + assert.True(t, ok, "Missing info logger") debugLogger, ok := debugLevel.(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Missing debug logger") - } + assert.True(t, ok, "Missing debug logger") traceLogger, ok := traceLevel.(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Missing trace logger") - } + assert.True(t, ok, "Missing trace logger") testNoDebugLevel(t, disabledLogger) testNoDebugLevel(t, errorLogger) @@ -217,9 +196,7 @@ func TestNewDefaultLoggerFactoryLogAll(t *testing.T) { factory := logging.NewDefaultLoggerFactory() testAPI, ok := factory.NewLogger("test").(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Invalid logger factory type") - } + assert.True(t, ok, "Invalid logger factory type") testAllLevels(t, testAPI) } @@ -230,19 +207,13 @@ func TestNewDefaultLoggerFactorySpecifcScopes(t *testing.T) { factory := logging.NewDefaultLoggerFactory() feature, ok := factory.NewLogger("feature").(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Invalid logger factory type") - } + assert.True(t, ok, "Invalid logger factory type") rtp, ok := factory.NewLogger("rtp-logger").(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Invalid logger factory type") - } + assert.True(t, ok, "Invalid logger factory type") noScope, ok := factory.NewLogger("no-scope").(*logging.DefaultLeveledLogger) - if !ok { - t.Error("Invalid logger factory type") - } + assert.True(t, ok, "Invalid logger factory type") testDebugLevel(t, feature) testDebugLevel(t, rtp) @@ -262,9 +233,7 @@ func TestLogLevel(t *testing.T) { logLevel := logging.LogLevelDisabled logLevel.Set(logging.LogLevelError) - if logLevel.Get() != logging.LogLevelError { - t.Error("LogLevel was not set to LogLevelError") - } + assert.Equal(t, logging.LogLevelError, logLevel.Get(), "LogLevel was not set to LogLevelError") } func TestLogLevelString(t *testing.T) { @@ -279,9 +248,7 @@ func TestLogLevelString(t *testing.T) { } for level, expectedStr := range expected { - if level.String() != expectedStr { - t.Errorf("Expected %q, got %q", expectedStr, level.String()) - } + assert.Equal(t, expectedStr, level.String()) } } From 07513351ad04aa87a6eb17887b18f49ed8a40199 Mon Sep 17 00:00:00 2001 From: Joe Turki Date: Mon, 7 Apr 2025 05:27:12 +0200 Subject: [PATCH 75/76] Update social media links, move to discord --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b9824ab..20ae889 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

The Pion logging library

Pion transport - Slack Widget + join us on Discord Follow us on Bluesky
GitHub Workflow Status Go Reference @@ -20,9 +20,9 @@ The library is used as a part of our WebRTC implementation. Please refer to that [roadmap](https://github.com/pion/webrtc/issues/9) to track our major milestones. ### Community -Pion has an active community on the [Slack](https://pion.ly/slack). +Pion has an active community on the [Discord](https://discord.gg/PngbdqpFbt). -Follow the [Pion Twitter](https://twitter.com/_pion) for project updates and important WebRTC news. +Follow the [Pion Bluesky](https://bsky.app/profile/pion.ly) or [Pion Twitter](https://twitter.com/_pion) for project updates and important WebRTC news. We are always looking to support **your projects**. Please reach out if you have something to build! If you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly) From 3c32a02abae2fbe7db12e82070fe6696b32ef96f Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Wed, 23 Apr 2025 14:41:26 +0000 Subject: [PATCH 76/76] Update CI configs to v0.11.19 Update lint scripts and CI configs. --- .github/workflows/release.yml | 2 +- .github/workflows/test.yaml | 6 +++--- .github/workflows/tidy-check.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e72ea4..b4967b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,4 +21,4 @@ jobs: release: uses: pion/.goassets/.github/workflows/release.reusable.yml@master with: - go-version: "1.22" # auto-update/latest-go-version + go-version: "1.24" # auto-update/latest-go-version diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b024289..7713e93 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,7 @@ jobs: uses: pion/.goassets/.github/workflows/test.reusable.yml@master strategy: matrix: - go: ["1.23", "1.22"] # auto-update/supported-go-version-list + go: ["1.24", "1.23"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -33,7 +33,7 @@ jobs: uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master strategy: matrix: - go: ["1.23", "1.22"] # auto-update/supported-go-version-list + go: ["1.24", "1.23"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -41,5 +41,5 @@ jobs: test-wasm: uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master with: - go-version: "1.23" # auto-update/latest-go-version + go-version: "1.24" # auto-update/latest-go-version secrets: inherit diff --git a/.github/workflows/tidy-check.yaml b/.github/workflows/tidy-check.yaml index 417e730..710dbc9 100644 --- a/.github/workflows/tidy-check.yaml +++ b/.github/workflows/tidy-check.yaml @@ -22,4 +22,4 @@ jobs: tidy: uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master with: - go-version: "1.22" # auto-update/latest-go-version + go-version: "1.24" # auto-update/latest-go-version