-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADF 41 | Added a gdlint github action, with variable problems thresho…
…ld (#19)
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
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,47 @@ | ||
# Workflow to automatically lint gdscript code | ||
name: gdlint on push | ||
|
||
on: | ||
[push, pull_request] | ||
|
||
jobs: | ||
gdlint: | ||
name: gdlint code | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
PROBLEMS_THRESHOLD: 88 # The allowed amount of linter problems | ||
|
||
steps: | ||
# Check out the repository | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# Ensure python is installed | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
# Install gdtoolkit | ||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install 'gdtoolkit==4.*' | ||
# Lint all the code directories (except addons) and capture the output | ||
# "|| true" make sure the github action doesn't stop when there are problems | ||
- name: Lint code | ||
run: | | ||
gdlint assets global resources scenes > gdlint_output.txt 2>&1 || true | ||
cat gdlint_output.txt | ||
# Parse the output and compare with the threshold | ||
- name: Check linter results | ||
run: | | ||
PROBLEMS=$(grep -oP 'Failure: \K\d+' gdlint_output.txt || echo "0") | ||
echo "Problems found: $PROBLEMS, threshold is: $PROBLEMS_THRESHOLD" | ||
if [ "$PROBLEMS" -gt "$PROBLEMS_THRESHOLD" ]; then | ||
echo "Too many linter problems" | ||
exit 1 | ||
fi |