diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..3fb55eab --- /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: --build-tags quic diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..9c8c1188 --- /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 \ + -tags quic \ + -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 \ + -tags quic \ + -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::${PWD}/test-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 c9b9dbf1..570f17b0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,27 +4,5 @@ linters-settings: misspell: locale: US -linters: - enable-all: true - disable: - - funlen - - godox - - lll - - maligned - -issues: - exclude-use-default: false - exclude-rules: - - path: rtptransceiverinit - text: "type RtpTransceiverInit should be RTPTransceiverInit" - linters: - - stylecheck - - text: "StreamID redeclared" - linters: - - typecheck - - text: "other declaration of StreamID" - linters: - - typecheck - run: skip-dirs-use-default: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 43eb7088..00000000 --- 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 diff --git a/rtptransceiver.go b/rtptransceiver.go index 0a0b84f4..505da951 100644 --- a/rtptransceiver.go +++ b/rtptransceiver.go @@ -96,7 +96,7 @@ func (t *RTPTransceiver) setDirection(d RTPTransceiverDirection) { } func (t *RTPTransceiver) setSendingTrack(track *Track) error { - t.Sender().track = track + t.Sender().setTrack(track) if track == nil { t.setSender(nil) }