-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add format_check.py and adjust gitignore to new zig cache location.
- Loading branch information
1 parent
408b8e6
commit 5e1ae31
Showing
3 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This is a basic workflow that is manually triggered | ||
|
||
name: Format Check | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
format_check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Check Format | ||
run: python3 "format_check.py" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
zig-out | ||
zig-cache | ||
.zig-cache | ||
.vscode | ||
zig-out.tar.gz | ||
zig-out.tar.gz |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
|
||
import sys | ||
|
||
directory = os.fsencode(".") | ||
|
||
fails = 0 | ||
|
||
for subdir, dirs, files in os.walk("."): | ||
for file in files: | ||
#print os.path.join(subdir, file) | ||
filepath = subdir + os.sep + file | ||
if filepath.startswith("./compiler"): continue | ||
if filepath.startswith("./saves"): continue | ||
if filepath.startswith("./serverAssets"): continue | ||
if filepath.startswith("./zig-cache"): continue | ||
if filepath.startswith("./.zig-cache"): continue | ||
|
||
if filepath.endswith(".json") or filepath.endswith(".zig") or filepath.endswith(".py") or filepath.endswith(".zon") or filepath.endswith(".vs") or filepath.endswith(".fs") or filepath.endswith(".glsl"): | ||
with open(filepath, "r", newline = '') as f: | ||
string = f.read() | ||
line = 1 | ||
lineStart = True | ||
for i, c in enumerate(string): | ||
if(c == '\r'): | ||
print("Incorrect line ending \\r in file ", filepath, " in line ", line, ". Please configure your editor to use LF instead of CRLF.") | ||
fails += 1 | ||
elif(c == '\n'): | ||
line += 1 | ||
lineStart = True | ||
elif(c == ' '): | ||
if(lineStart): | ||
print("Incorrect indentation in file ", filepath, " in line ", line, ". Please use tabs instead of spaces.") | ||
fails += 1 | ||
lineStart = False # avoid repeating this error multiple times | ||
elif(c == '\t'): | ||
continue | ||
elif(lineStart): | ||
lineStart = False | ||
else: | ||
continue | ||
if(fails != 0): | ||
sys.exit(1) | ||
sys.exit(0) |