mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-26 03:36:08 -05:00 
			
		
		
		
	Add GitHub Actions workflow to check black formatting
This commit is contained in:
		
							
								
								
									
										37
									
								
								.github/workflow-scripts/check-trailing-newline
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										37
									
								
								.github/workflow-scripts/check-trailing-newline
									
									
									
									
										vendored
									
									
								
							| @@ -1,37 +0,0 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Verify that all text files end in a trailing newline. | ||||
|  | ||||
| # Exit on first failing command. | ||||
| set -e | ||||
|  | ||||
| # Exit on unset variable. | ||||
| set -u | ||||
|  | ||||
| success=0 | ||||
|  | ||||
| function is_plaintext_file() { | ||||
|   local file="$1" | ||||
|   if [[ $file == *.svg ]]; then | ||||
|     echo "" | ||||
|     return | ||||
|   fi | ||||
|   file --brief "${file}" | grep text | ||||
| } | ||||
|  | ||||
| # Split strings on newlines. | ||||
| IFS=' | ||||
| ' | ||||
| for file in $(git ls-files) | ||||
| do | ||||
|   if [[ -z $(is_plaintext_file "${file}") ]]; then | ||||
|     continue | ||||
|   fi | ||||
|  | ||||
|   if ! [[ -z "$(tail -c 1 "${file}")" ]]; then | ||||
|     printf "File must end in a trailing newline: %s\n" "${file}" >&2 | ||||
|     success=255 | ||||
|   fi | ||||
| done | ||||
|  | ||||
| exit "${success}" | ||||
| @@ -1,26 +0,0 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Check for trailing whitespace at end of lines. | ||||
|  | ||||
| # Exit on first failing command. | ||||
| set -e | ||||
| # Exit on unset variable. | ||||
| set -u | ||||
|  | ||||
| FOUND_TRAILING_WHITESPACE=0 | ||||
|  | ||||
| while read -r line; do | ||||
|   if grep \ | ||||
|     "\s$" \ | ||||
|     --line-number \ | ||||
|     --with-filename \ | ||||
|     --binary-files=without-match \ | ||||
|     --exclude="*.svg" \ | ||||
|     --exclude="*.eps" \ | ||||
|     "${line}"; then | ||||
|     echo "ERROR: Found trailing whitespace" >&2; | ||||
|     FOUND_TRAILING_WHITESPACE=1 | ||||
|   fi | ||||
| done < <(git ls-files) | ||||
|  | ||||
| exit "${FOUND_TRAILING_WHITESPACE}" | ||||
							
								
								
									
										15
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @@ -81,20 +81,19 @@ jobs: | ||||
|         run: | | ||||
|           cd src/ | ||||
|           pycodestyle | ||||
|   whitespace: | ||||
|   formatting: | ||||
|     runs-on: ubuntu-20.04 | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Ensure there are no trailing spaces | ||||
|         run: | | ||||
|           .github/workflow-scripts/check-trailing-whitespace | ||||
|       - | ||||
|         name: Ensure all text files end with a trailing newline | ||||
|         run: | | ||||
|           .github/workflow-scripts/check-trailing-whitespace | ||||
|         name: Run black | ||||
|         uses: psf/black@stable | ||||
|         with: | ||||
|           options: "--check --diff --verbose" | ||||
|           src: "./src" | ||||
|           version: "22.1.0" | ||||
|  | ||||
|   tests: | ||||
|     runs-on: ubuntu-20.04 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 kpj
					kpj