Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Update CI configs to v0.2.1 #94

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/assert-contributors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/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
# 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 )

EXCLUDED_CONTIBUTORS=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot')
MISSING_CONTIBUTORS=()

shouldBeIncluded () {
for i in "${EXCLUDED_CONTIBUTORS[@]}"
do
if [ "$i" == "$1" ] ; then
return 1
fi
done
return 0
}


IFS=$'\n' #Only split on newline
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")
fi
fi
done
unset IFS

if [ ${#MISSING_CONTIBUTORS[@]} -ne 0 ]; then
echo "Please add the following contributors to the README"
for i in "${MISSING_CONTIBUTORS[@]}"
do
echo "$i"
done
exit 1
fi
11 changes: 11 additions & 0 deletions .github/hooks/commit-msg.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .github/hooks/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .github/hooks/pre-push.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .github/install-hooks.sh
Original file line number Diff line number Diff line change
@@ -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"
67 changes: 67 additions & 0 deletions .github/lint-commit-message.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/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() {
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
# 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
lint_commit_message "$(git log --format="%B" -n 1 $commit)"
done
fi
23 changes: 23 additions & 0 deletions .github/lint-disallowed-functions-in-library.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(')


for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}"
do
if grep -R $EXCLUDE_DIRECTORIES -e "$disallowedFunction" "$SCRIPT_PATH/.." | grep -v -e '_test.go' -e 'nolint'; then
echo "$disallowedFunction may only be used in example code"
exit 1
fi
done
21 changes: 21 additions & 0 deletions .github/lint-filename.sh
Original file line number Diff line number Diff line change
@@ -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][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
30 changes: 30 additions & 0 deletions .github/workflows/renovate-go-mod-fix.yaml
Original file line number Diff line number Diff line change
@@ -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
131 changes: 125 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,128 @@
#
# 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.13.4"
script:
- go build ./cmd/biz
- go build ./cmd/islb
- go build ./cmd/sfu

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_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
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 i386/golang:${GO_VERSION}-alpine \
/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.14
go: 1.14
- <<: *test_job
name: Test 1.13
go: 1.13
- <<: *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
env: GO_VERSION=1.13
- <<: *test_wasm_job
name: Test WASM 1.14
env: GO_VERSION=1.14

notifications:
email: false
Loading