Skip to content

Commit 5e7f90f

Browse files
pionbotkevmo314
authored andcommittedDec 31, 2022
Update CI configs to v0.8.1
Update lint scripts and CI configs.
1 parent c21afb8 commit 5e7f90f

6 files changed

+41
-53
lines changed
 

‎.github/generate-authors.sh

+10-13
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
set -e
1313

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

17-
if [ -f ${SCRIPT_PATH}/.ci.conf ]
18-
then
18+
if [ -f ${SCRIPT_PATH}/.ci.conf ]; then
1919
. ${SCRIPT_PATH}/.ci.conf
2020
fi
2121

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

3333
shouldBeIncluded () {
34-
for i in "${EXCLUDED_CONTRIBUTORS[@]}"
35-
do
34+
for i in "${EXCLUDED_CONTRIBUTORS[@]}"; do
3635
if [[ $1 =~ "$i" ]]; then
3736
return 1
3837
fi
@@ -42,25 +41,23 @@ shouldBeIncluded () {
4241

4342

4443
IFS=$'\n' #Only split on newline
45-
for contributor in $(git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf)
46-
do
47-
if shouldBeIncluded $contributor; then
48-
CONTRIBUTORS+=("$contributor")
44+
for CONTRIBUTOR in $(git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf); do
45+
if shouldBeIncluded ${CONTRIBUTOR}; then
46+
CONTRIBUTORS+=("${CONTRIBUTOR}")
4947
fi
5048
done
5149
unset IFS
5250

5351
if [ ${#CONTRIBUTORS[@]} -ne 0 ]; then
54-
cat >$AUTHORS_PATH <<-'EOH'
52+
cat >${AUTHORS_PATH} <<-'EOH'
5553
# Thank you to everyone that made Pion possible. If you are interested in contributing
5654
# we would love to have you https://github.com/pion/webrtc/wiki/Contributing
5755
#
5856
# This file is auto generated, using git to list all individuals contributors.
5957
# see `.github/generate-authors.sh` for the scripting
6058
EOH
61-
for i in "${CONTRIBUTORS[@]}"
62-
do
63-
echo "$i" >> $AUTHORS_PATH
59+
for i in "${CONTRIBUTORS[@]}"; do
60+
echo "$i" >> ${AUTHORS_PATH}
6461
done
6562
exit 0
6663
fi

‎.github/install-hooks.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
1313

14-
cp "$SCRIPT_PATH/hooks/commit-msg.sh" "$SCRIPT_PATH/../.git/hooks/commit-msg"
15-
cp "$SCRIPT_PATH/hooks/pre-commit.sh" "$SCRIPT_PATH/../.git/hooks/pre-commit"
16-
cp "$SCRIPT_PATH/hooks/pre-push.sh" "$SCRIPT_PATH/../.git/hooks/pre-push"
14+
cp "${SCRIPT_PATH}/hooks/commit-msg.sh" "${SCRIPT_PATH}/../.git/hooks/commit-msg"
15+
cp "${SCRIPT_PATH}/hooks/pre-commit.sh" "${SCRIPT_PATH}/../.git/hooks/pre-commit"
16+
cp "${SCRIPT_PATH}/hooks/pre-push.sh" "${SCRIPT_PATH}/../.git/hooks/pre-push"

‎.github/lint-commit-message.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if [ "$#" -eq 1 ]; then
5858
fi
5959
lint_commit_message "$(sed -n '/# Please enter the commit message for your changes. Lines starting/q;p' "$1")"
6060
else
61-
for commit in $(git rev-list --no-merges origin/master..); do
62-
lint_commit_message "$(git log --format="%B" -n 1 $commit)"
61+
for COMMIT in $(git rev-list --no-merges origin/master..); do
62+
lint_commit_message "$(git log --format="%B" -n 1 ${COMMIT})"
6363
done
6464
fi

‎.github/lint-disallowed-functions-in-library.sh

+12-17
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,31 @@ set -e
1313

1414
# Disallow usages of functions that cause the program to exit in the library code
1515
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
16-
if [ -f ${SCRIPT_PATH}/.ci.conf ]
17-
then
16+
if [ -f ${SCRIPT_PATH}/.ci.conf ]; then
1817
. ${SCRIPT_PATH}/.ci.conf
1918
fi
2019

2120
EXCLUDE_DIRECTORIES=${DISALLOWED_FUNCTIONS_EXCLUDED_DIRECTORIES:-"examples"}
2221
DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(' 'print(' 'println(')
2322

24-
files=$(
25-
find "$SCRIPT_PATH/.." -name "*.go" \
23+
FILES=$(
24+
find "${SCRIPT_PATH}/.." -name "*.go" \
2625
| grep -v -e '^.*_test.go$' \
27-
| while read file
28-
do
29-
excluded=false
30-
for ex in $EXCLUDE_DIRECTORIES
31-
do
32-
if [[ $file == */$ex/* ]]
33-
then
34-
excluded=true
26+
| while read FILE; do
27+
EXCLUDED=false
28+
for EXCLUDE_DIRECTORY in ${EXCLUDE_DIRECTORIES}; do
29+
if [[ ${FILE} == */${EXCLUDE_DIRECTORY}/* ]]; then
30+
EXCLUDED=true
3531
break
3632
fi
3733
done
38-
$excluded || echo "$file"
34+
${EXCLUDED} || echo "${FILE}"
3935
done
4036
)
4137

42-
for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}"
43-
do
44-
if grep -e "\s$disallowedFunction" $files | grep -v -e 'nolint'; then
45-
echo "$disallowedFunction may only be used in example code"
38+
for DISALLOWED_FUNCTION in "${DISALLOWED_FUNCTIONS[@]}"; do
39+
if grep -e "\s${DISALLOWED_FUNCTION}" ${FILES} | grep -v -e 'nolint'; then
40+
echo "${DISALLOWED_FUNCTION} may only be used in example code"
4641
exit 1
4742
fi
4843
done

‎.github/lint-filename.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ set -e
1414
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
1515
GO_REGEX="^[a-zA-Z][a-zA-Z0-9_]*\.go$"
1616

17-
find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do
18-
filename=$(basename -- "$fullpath")
17+
find "${SCRIPT_PATH}/.." -name "*.go" | while read FULLPATH; do
18+
FILENAME=$(basename -- "${FULLPATH}")
1919

20-
if ! [[ $filename =~ $GO_REGEX ]]; then
21-
echo "$filename is not a valid filename for Go code, only alpha, numbers and underscores are supported"
20+
if ! [[ ${FILENAME} =~ ${GO_REGEX} ]]; then
21+
echo "${FILENAME} is not a valid filename for Go code, only alpha, numbers and underscores are supported"
2222
exit 1
2323
fi
2424
done

‎.github/lint-no-trailing-newline-in-log-messages.sh

+10-14
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,25 @@ set -e
1313

1414
# Disallow usages of functions that cause the program to exit in the library code
1515
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
16-
if [ -f ${SCRIPT_PATH}/.ci.conf ]
17-
then
16+
if [ -f ${SCRIPT_PATH}/.ci.conf ]; then
1817
. ${SCRIPT_PATH}/.ci.conf
1918
fi
2019

21-
files=$(
22-
find "$SCRIPT_PATH/.." -name "*.go" \
23-
| while read file
24-
do
25-
excluded=false
26-
for ex in $EXCLUDE_DIRECTORIES
27-
do
28-
if [[ $file == */$ex/* ]]
29-
then
30-
excluded=true
20+
FILES=$(
21+
find "${SCRIPT_PATH}/.." -name "*.go" \
22+
| while read FILE; do
23+
EXCLUDED=false
24+
for EXCLUDE_DIRECTORY in ${EXCLUDE_DIRECTORIES}; do
25+
if [[ $file == */${EXCLUDE_DIRECTORY}/* ]]; then
26+
EXCLUDED=true
3127
break
3228
fi
3329
done
34-
$excluded || echo "$file"
30+
${EXCLUDED} || echo "${FILE}"
3531
done
3632
)
3733

38-
if grep -E '\.(Trace|Debug|Info|Warn|Error)f?\("[^"]*\\n"\)?' $files | grep -v -e 'nolint'; then
34+
if grep -E '\.(Trace|Debug|Info|Warn|Error)f?\("[^"]*\\n"\)?' ${FILES} | grep -v -e 'nolint'; then
3935
echo "Log format strings should have trailing new-line"
4036
exit 1
4137
fi

0 commit comments

Comments
 (0)
Please sign in to comment.