Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) Add ability to specify a ref to compare against #4

Merged
merged 1 commit into from
Feb 12, 2024
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
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: info
test-pr-change-check:
if: github.event_name == 'pull_request'
name: runner / languagetool (github-pr-check) (Changed)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: info
base_ref: develop

test-pr-review:
if: github.event_name == 'pull_request'
Expand All @@ -40,4 +54,4 @@ jobs:
reporter: github-pr-review
level: info
patterns: "**.md"
custom_api_endpoint: https://languagetool.org/api
custom_api_endpoint: https://languagetool.org/api
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ inputs:
custom_api_endpoint:
description: 'Custom API endpoint of LanguageTool server. e.g. https://languagetool.org/api'
default: ''
base_ref:
description: 'The branch or commit reference that files changed or added should be collected from. Will use the default branch if coming from a pull request if not set.'
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
6 changes: 5 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -eo pipefail

Check warning on line 2 in entrypoint.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 In POSIX sh, set option pipefail is undefined. [SC3040](https://github.com/koalaman/shellcheck/wiki/SC3040) Raw Output: ./entrypoint.sh:2:9:warning:In POSIX sh, set option pipefail is undefined. [SC3040](https://github.com/koalaman/shellcheck/wiki/SC3040)

API_ENDPOINT="${INPUT_CUSTOM_API_ENDPOINT}"
if [ -z "${INPUT_CUSTOM_API_ENDPOINT}" ]; then
Expand All @@ -14,7 +14,7 @@
cd "${GITHUB_WORKSPACE}" || exit
fi

git config --global --add safe.directory $GITHUB_WORKSPACE

Check warning on line 17 in entrypoint.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./entrypoint.sh:17:42:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check failure on line 17 in entrypoint.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: entrypoint.sh:17:-git config --global --add safe.directory $GITHUB_WORKSPACE entrypoint.sh:17:+git config --global --add safe.directory "$GITHUB_WORKSPACE"

# https://languagetool.org/http-api/swagger-ui/#!/default/post_check
DATA="language=${INPUT_LANGUAGE}"
Expand All @@ -36,11 +36,15 @@

# Disable glob to handle glob patterns with ghglob command instead of with shell.
set -o noglob
FILES="$(git ls-files | ghglob ${INPUT_PATTERNS})"
if [ -n "${INPUT_BASE_REF}" ]; then
FILES="$(git diff "origin/${INPUT_BASE_REF}" --name-only | ghglob "${INPUT_PATTERNS}")"
else
FILES="$(git ls-files | ghglob "${INPUT_PATTERNS}")"
fi
set +o noglob

# To manage whitespaces in filepath
IFS=$(echo -en "\n\b")

Check warning on line 47 in entrypoint.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 In POSIX sh, echo flags are undefined. [SC3037](https://github.com/koalaman/shellcheck/wiki/SC3037) Raw Output: ./entrypoint.sh:47:12:warning:In POSIX sh, echo flags are undefined. [SC3037](https://github.com/koalaman/shellcheck/wiki/SC3037)

run_langtool() {
for FILE in ${FILES}; do
Expand Down