1657 allow the contributor to self assign the issue #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# workflows/lint-format.yml | |
# | |
# Lint Format | |
# Lint the project's file trailing spaces, line endings, and format. | |
name: Lint Format | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
workflow_dispatch: | |
concurrency: | |
group: lint-format-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
lint-format: | |
name: Lint File Endings & Trailing Whitespaces | |
runs-on: depot-ubuntu-latest-2 | |
if: github.event.pull_request.draft == false | |
steps: | |
- name: Checkout Git Repository | |
uses: actions/checkout@v4 | |
- name: Install fd Search Tool | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y fd-find | |
mkdir -p "$HOME/.local/bin" | |
sudo ln -s $(which fdfind) "$HOME/.local/bin/fd" | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Check for CRLF Files | |
run: | | |
FILES=$(git ls-files --eol | grep crlf || true) | |
if [[ ! -z "$FILES" ]]; then | |
echo "The following files have incorrect line endings:" | |
echo "$FILES" | |
false | |
fi | |
# We ignore .out and .sql files, which are used by pg_regress for testing | |
# and need a very specific format | |
- name: Check for Trailing Whitespaces | |
run: | | |
FILES=$(git grep -Ilr '[[:blank:]]$' -- ':(exclude)*.out' ':(exclude)*.sql' ':(exclude)*.rs' || true) | |
if [[ ! -z "$FILES" ]]; then | |
echo "The following files have trailing whitespaces:" | |
echo "$FILES" | |
exit 1 | |
fi | |
- name: Print Modified Files | |
run: | | |
FILES=$(git ls-files --modified) | |
if [[ ! -z "$FILES" ]]; then | |
echo "The following files have incorrect trailing newlines:" | |
echo "$FILES" | |
echo "Please fix them using:" | |
echo -e 'if [[ -f "$1" ]]; then\n echo -n "$1"\n if (diff /dev/null "$1" || true) | tail -1 | grep -q "^\\ No newline"; then\n echo >> "$1"\n echo "...fixed"\n else\n echo ""\n fi\nfi' | |
false | |
fi |