refactor(gh): Pull out formatter

This makes for easier local testing.
This commit is contained in:
Ed Page 2022-06-22 11:33:54 -05:00
parent a3c8693b45
commit a950dd27ff
3 changed files with 13 additions and 6 deletions

View file

@ -6,5 +6,6 @@ RUN wget https://github.com/crate-ci/typos/releases/download/v${VERSION}/typos-v
tar -xzvf typos-v${VERSION}-x86_64-unknown-linux-musl.tar.gz && \ tar -xzvf typos-v${VERSION}-x86_64-unknown-linux-musl.tar.gz && \
mv typos /usr/local/bin mv typos /usr/local/bin
COPY entrypoint.sh /entrypoint.sh COPY entrypoint.sh /entrypoint.sh
COPY format_gh.sh /format_gh.sh
WORKDIR /github/workspace WORKDIR /github/workspace
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View file

@ -2,6 +2,8 @@
set -eu set -eu
SOURCE_DIR="$(dirname -- ${BASH_SOURCE[0]:-$0})";
log() { log() {
echo -e "$1" >&2 echo -e "$1" >&2
} }
@ -47,10 +49,5 @@ if [[ -n "${INPUT_CONFIG:-}" ]]; then
fi fi
log "$ ${CMD_NAME} ${ARGS}" log "$ ${CMD_NAME} ${ARGS}"
${CMD_NAME} ${ARGS} --format json | ${CMD_NAME} ${ARGS} --format json | ${SOURCE_DIR}/format_gh.sh || true
grep '"type":"typo"' |
jq --sort-keys --raw-output '"::warning file=\(.path),line=\(.line_num),col=\(.byte_offset)::\"\(.typo)\" should be \"" + (.corrections // [] | join("\" or \"") + "\".")' |
while IFS= read -r line; do
echo "$line"
done || true
${CMD_NAME} ${ARGS} ${CMD_NAME} ${ARGS}

9
docker/format_gh.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
set -eu
grep '"type":"typo"' |
jq --sort-keys --raw-output '"::warning file=\(.path),line=\(.line_num),col=\(.byte_offset)::\"\(.typo)\" should be \"" + (.corrections // [] | join("\" or \"") + "\".")' |
while IFS= read -r line; do
echo "$line"
done