Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Test"

on:
pull_request:

jobs:
shell-scripts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: luizm/action-sh-checker@883217215b11c1fabbf00eb1a9a041f62d74c744
env: { SHFMT_OPTS: -i 2 -d }
4 changes: 4 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
external-sources=true
check-sourced=true
source-path=lib
enable=avoid-nullary-conditions,check-unassigned-uppercase,deprecate-which,quote-safe-variables,useless-use-of-cat
49 changes: 49 additions & 0 deletions lib/ci-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

################################################################################
# Because GitHub runners don't set these:
export LANG=en_US.UTF-8
export LC_ALL=$LANG
export LC_COLLATE=$LANG

################################################################################
# Strip whitespace and delete blank lines from STDIN to STDOUT.
function strip_space() {
sed -E \
-e 's/^[[:space:]]+//' \
-e 's/[[:space:]]+$//' \
-e 's/[[:space:]]+/ /' \
-e '/^[[:space:]]*$/d'
}

################################################################################
# Resolve a `git` commit name given on the command line.
#
# When a repository is cloned in a GitHub action the main branch isn't
# available directly, even though `$GITHUB_BASE_REF` references it.
# So we need to fully qualify any symbolic revision name we are given.
function resolve_git_commit() {
local name=$1
local commit

local possible=(
"$name"
"origin/$name"
"remotes/origin/$name"
)

for rev in "${possible[@]}"; do
commit=$(git rev-parse --verify --quiet "$rev" || :)

if [ -n "$commit" ]; then
break
fi
done

if [ -z "$commit" ]; then
echo >&2 "ERROR: invalid revision: $name"
exit 1
fi

echo "$commit"
}
48 changes: 2 additions & 46 deletions scripts/authors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ set -eu
set -o pipefail

################################################################################
# Because GitHub runners don't set these:
export LANG=en_US.UTF-8
export LC_ALL=$LANG
export LC_COLLATE=$LANG
script_dir=$(realpath "$(dirname "$0")")
source "$script_dir/../lib/ci-tools.sh"

################################################################################
option_from="HEAD^"
Expand All @@ -32,48 +30,6 @@ NOTE: Must be exeucted from within a git repository.
EOF
}

################################################################################
# Strip whitespace and delete blank lines from STDIN to STDOUT.
function strip_space() {
sed -E \
-e 's/^[[:space:]]+//' \
-e 's/[[:space:]]+$//' \
-e 's/[[:space:]]+/ /' \
-e '/^[[:space:]]*$/d'
}

################################################################################
# Resolve a `git` commit name given on the command line.
#
# When a repository is cloned in a GitHub action the main branch isn't
# available directly, even though `$GITHUB_BASE_REF` references it.
# So we need to fully qualify any symbolic revision name we are given.
function resolve_git_commit() {
local name=$1
local commit

local possible=(
"$name"
"origin/$name"
"remotes/origin/$name"
)

for rev in "${possible[@]}"; do
commit=$(git rev-parse --verify --quiet "$rev" || :)

if [ -n "$commit" ]; then
break
fi
done

if [ -z "$commit" ]; then
echo >&2 "ERROR: invalid revision: $name"
exit 1
fi

echo "$commit"
}

################################################################################
# Ask `git` for a list of authors.
function authors_from_git() {
Expand Down
10 changes: 7 additions & 3 deletions scripts/check-tool-handler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
set -eu
set -o pipefail

################################################################################
script_dir=$(realpath "$(dirname "$0")")
source "$script_dir/../lib/ci-tools.sh"

################################################################################
declare -A topp_exceptions=(
["FeatureLinkerBase.cpp"]=1
Expand Down Expand Up @@ -60,7 +64,7 @@ function topp_files_in_map() {

if [ "${topp_exceptions[$base]:-0}" -ne 1 ] && ! is_in_tools_map_cpp "$base"; then
echo >&2 "ERROR: $base is not listed in $option_tool_handler_cpp"
exit 1
exit 100
fi
done < <(find "$option_topp_dir" -type f -name '*.cpp' -print0)
}
Expand Down Expand Up @@ -121,8 +125,8 @@ function main() {

if [ $# -gt 0 ]; then
if [ $# -eq 2 ]; then
option_from=$1
option_to=$2
option_from=$(resolve_git_commit "$1")
option_to=$(resolve_git_commit "$2")
else
echo >&2 "ERROR: provide exactly two commits"
exit 1
Expand Down