Skip to content

Commit

Permalink
Update CI configs to v0.8.1
Browse files Browse the repository at this point in the history
Update lint scripts and CI configs.
  • Loading branch information
pionbot authored and kevmo314 committed Nov 18, 2022
1 parent 0bd9553 commit d13e8b6
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 79 deletions.
23 changes: 10 additions & 13 deletions .github/generate-authors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
set -e

SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
AUTHORS_PATH="$GITHUB_WORKSPACE/AUTHORS.txt"
GIT_WORKDIR=${GITHUB_WORKSPACE:-$(git rev-parse --show-toplevel)}
AUTHORS_PATH="${GIT_WORKDIR}/AUTHORS.txt"

if [ -f ${SCRIPT_PATH}/.ci.conf ]
then
if [ -f ${SCRIPT_PATH}/.ci.conf ]; then
. ${SCRIPT_PATH}/.ci.conf
fi

Expand All @@ -31,8 +31,7 @@ EXCLUDED_CONTRIBUTORS+=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion B
CONTRIBUTORS=()

shouldBeIncluded () {
for i in "${EXCLUDED_CONTRIBUTORS[@]}"
do
for i in "${EXCLUDED_CONTRIBUTORS[@]}"; do
if [[ $1 =~ "$i" ]]; then
return 1
fi
Expand All @@ -42,25 +41,23 @@ shouldBeIncluded () {


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")
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'
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
for i in "${CONTRIBUTORS[@]}"; do
echo "$i" >> ${AUTHORS_PATH}
done
exit 0
fi
6 changes: 3 additions & 3 deletions .github/install-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

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"
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"
4 changes: 2 additions & 2 deletions .github/lint-commit-message.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +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
for commit in $(git rev-list --no-merges origin/master..); do
lint_commit_message "$(git log --format="%B" -n 1 $commit)"
for COMMIT in $(git rev-list --no-merges origin/master..); do
lint_commit_message "$(git log --format="%B" -n 1 ${COMMIT})"
done
fi
29 changes: 12 additions & 17 deletions .github/lint-disallowed-functions-in-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,31 @@ 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
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" \
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
| while read FILE; do
EXCLUDED=false
for EXCLUDE_DIRECTORY in ${EXCLUDE_DIRECTORIES}; do
if [[ ${FILE} == */${EXCLUDE_DIRECTORY}/* ]]; then
EXCLUDED=true
break
fi
done
$excluded || echo "$file"
${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"
for DISALLOWED_FUNCTION in "${DISALLOWED_FUNCTIONS[@]}"; do
if grep -e "\s${DISALLOWED_FUNCTION}" ${FILES} | grep -v -e 'nolint'; then
echo "${DISALLOWED_FUNCTION} may only be used in example code"
exit 1
fi
done
8 changes: 4 additions & 4 deletions .github/lint-filename.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ 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")
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"
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
24 changes: 10 additions & 14 deletions .github/lint-no-trailing-newline-in-log-messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,25 @@ 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
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
FILES=$(
find "${SCRIPT_PATH}/.." -name "*.go" \
| while read FILE; do
EXCLUDED=false
for EXCLUDE_DIRECTORY in ${EXCLUDE_DIRECTORIES}; do
if [[ $file == */${EXCLUDE_DIRECTORY}/* ]]; then
EXCLUDED=true
break
fi
done
$excluded || echo "$file"
${EXCLUDED} || echo "${FILE}"
done
)

if grep -E '\.(Trace|Debug|Info|Warn|Error)f?\("[^"]*\\n"\)?' $files | grep -v -e 'nolint'; then
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
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: release
on:
push:
tags:
- 'v*'

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '1.18' # auto-update/latest-go-version
- name: Build and release
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.17", "1.18"]
go: ["1.17", "1.18"] # auto-update/supported-go-version-list
fail-fast: false
name: Go ${{ matrix.go }}
steps:
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.17", "1.18"]
go: ["1.17", "1.18"] # auto-update/supported-go-version-list
fail-fast: false
name: Go i386 ${{ matrix.go }}
steps:
Expand Down Expand Up @@ -145,7 +145,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.17
GO_VERSION: 1.17 # auto-update/latest-go-version

- name: Set Go Root
run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tidy-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.17 # auto-update/latest-go-version
- name: check
run: |
go mod download
Expand Down
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
builds:
- skip: true
25 changes: 2 additions & 23 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -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"
]
}

0 comments on commit d13e8b6

Please sign in to comment.