fix(ci): avoid failing "dirname"-cleanup PRs (#1405)

This commit is contained in:
kylo252 2021-11-13 09:43:37 +01:00 committed by GitHub
parent f605c50fe6
commit f19b12f527
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 18 deletions

16
.github/ci/run_sanitizer.sh vendored Normal file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
REF_BRANCH="$1"
PR_BRANCH="$2"
# checks for added lines that contain search pattern and prints them
SEARCH_PATTERN="(dirname|fn\.cwd)"
if git diff --pickaxe-all -U0 -G "${SEARCH_PATTERN}" "${REF_BRANCH}" "${PR_BRANCH}" -- '*.lua' | grep -Ev '(configs|utils)\.lua$' | grep -E "^\+.*${SEARCH_PATTERN}" ; then
echo
echo 'String "dirname" found. There is a high risk that this might contradict the directive:'
echo '"Do not add vim.fn.cwd or util.path.dirname in root_dir".'
echo "see: https://github.com/neovim/nvim-lspconfig/blob/master/CONTRIBUTING.md#adding-a-server-to-lspconfig."
exit 1
fi

View file

@ -1,18 +0,0 @@
name: "Dirname Checker"
on: [pull_request]
jobs:
dirname-check:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2.3.1
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- run: |
if ! git log -G"dirname" --exit-code origin/$GITHUB_BASE_REF..$(git branch --show-current) -- . ':!lua/lspconfig/configs.lua'; then
echo
echo 'String "dirname" found. There is a high risk that this might contradict the directive "Do not add vim.fn.cwd or util.path.dirname in root_dir" specified in https://github.com/neovim/nvim-lspconfig/blob/master/CONTRIBUTING.md#adding-a-server-to-lspconfig.'
exit 1
fi

15
.github/workflows/sanitizer.yml vendored Normal file
View file

@ -0,0 +1,15 @@
name: "Dirname Checker"
on: [pull_request]
jobs:
disallowed-root-checker:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2.3.1
with:
fetch-depth: 0
- run: |
if ! bash .github/ci/run_sanitizer.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}; then
exit 1
fi