mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Update CI configs to v0.3.1
Update lint scripts and CI configs.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+22
-15
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user