Skip to content

Commit

Permalink
(maint) Add ability to specify a ref to compare against
Browse files Browse the repository at this point in the history
This change allows the GitHub action workflow to specify a specific
reference to be used when finding files to send to the language server.

This allows the the languagetool check to use less time by only compare
any new or changed files, instead of running all of the files in the
repository through the language server.

Additional work is needed for repositories after this change is merged.
  • Loading branch information
AdmiringWorm committed Oct 18, 2023
1 parent 445dede commit 536a181
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
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
Expand Up @@ -36,7 +36,11 @@ fi

# 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

run_langtool() {
Expand Down

0 comments on commit 536a181

Please sign in to comment.