diff options
| author | Radon Rosborough <radon.neon@gmail.com> | 2022-01-05 15:35:12 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-05 15:35:12 -0800 |
| commit | 53f243b111b18f49d910d1501b5795a1ec045420 (patch) | |
| tree | 785538e39d04a00bc43507224f0ad6a4c89f297d /scripts | |
| parent | 41fa1f70ee01cd2ab3ab90f6fe4c4fc0819c2f96 (diff) | |
Add formatter tests (#72)
Closes #24
Builds on #25 by @PrimaryCanary
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/check-line-length.bash | 2 | ||||
| -rwxr-xr-x | scripts/docker-pid1.bash | 23 | ||||
| -rwxr-xr-x | scripts/docker-run.bash | 19 | ||||
| -rwxr-xr-x | scripts/docker.bash | 9 |
4 files changed, 52 insertions, 1 deletions
diff --git a/scripts/check-line-length.bash b/scripts/check-line-length.bash index c6a040d..3dd4cd1 100755 --- a/scripts/check-line-length.bash +++ b/scripts/check-line-length.bash @@ -6,6 +6,8 @@ set -o pipefail find=( find . -name .git -prune -o + -name .log -prune -o + -path ./test/formatters -prune -o -name "*.elc" -o -type f -print ) diff --git a/scripts/docker-pid1.bash b/scripts/docker-pid1.bash new file mode 100755 index 0000000..cee0dff --- /dev/null +++ b/scripts/docker-pid1.bash @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cat <<"EOF" > /etc/sudoers.d/apheleia +%sudo ALL=(ALL:ALL) NOPASSWD: ALL +EOF + +groupadd -g "$(stat -c %g "$PWD")" -o -p '!' -r apheleia +useradd -u "$(stat -c %u "$PWD")" -g "$(stat -c %g "$PWD")" \ + -o -p '!' -m -N -l -s /usr/bin/bash -G sudo apheleia + +runuser -u apheleia touch /home/apheleia/.sudo_as_admin_successful + +if (( "$#" == 0 )) || [[ -z "$1" ]]; then + set -- bash +fi + +if (( "$#" == 1 )) && [[ "$1" == *" "* ]]; then + set -- bash -c "$1" +fi + +exec runuser -u apheleia -- "$@" diff --git a/scripts/docker-run.bash b/scripts/docker-run.bash new file mode 100755 index 0000000..e7de1f4 --- /dev/null +++ b/scripts/docker-run.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -euo pipefail + +repo="$(git rev-parse --show-toplevel)" + +docker=(docker) +if [[ "$OSTYPE" != darwin* ]] && [[ "$EUID" != 0 ]]; then + docker=(sudo -E "${docker[@]}") +fi + +it=() + +if [[ -t 0 ]]; then + it+=(-it) +fi + +exec "${docker[@]}" run "${it[@]}" --rm -v "${repo}:/src" \ + --entrypoint=/src/scripts/docker-pid1.bash "$@" diff --git a/scripts/docker.bash b/scripts/docker.bash index d846122..812cded 100755 --- a/scripts/docker.bash +++ b/scripts/docker.bash @@ -22,4 +22,11 @@ docker build . -t "apheleia:$tag" \ --build-arg "UID=$UID" \ --build-arg "VERSION=$tag" -docker run -it --rm -v "$PWD:/home/docker/src" "apheleia:$tag" "${args[@]}" +it=() + +if [[ -t 0 ]]; then + it+=(-it) +fi + +docker run "${it[@]}" --rm -v "$PWD:/home/docker/src" \ + "apheleia:$tag" "${args[@]}" |
