2020-08-22 23:04:57 +02:00
|
|
|
name: 📊 Static Checks
|
2023-04-04 15:56:53 +02:00
|
|
|
on:
|
|
|
|
workflow_call:
|
2020-07-13 09:34:34 +02:00
|
|
|
|
2021-08-24 20:49:06 +02:00
|
|
|
concurrency:
|
2021-08-25 15:04:05 +02:00
|
|
|
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static
|
2021-08-24 20:49:06 +02:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-07-13 09:34:34 +02:00
|
|
|
jobs:
|
2020-07-15 00:37:02 +02:00
|
|
|
static-checks:
|
2023-04-19 15:10:36 +02:00
|
|
|
name: Code style, file formatting, and docs
|
|
|
|
runs-on: ubuntu-22.04
|
2020-07-13 09:34:34 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-09-04 16:05:38 +02:00
|
|
|
uses: actions/checkout@v4
|
2023-04-19 15:10:36 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 2
|
|
|
|
|
|
|
|
- name: Install APT dependencies
|
|
|
|
uses: awalsh128/cache-apt-pkgs-action@latest
|
|
|
|
with:
|
|
|
|
packages: dos2unix libxml2-utils moreutils
|
2020-07-13 09:34:34 +02:00
|
|
|
|
2023-04-19 15:10:36 +02:00
|
|
|
- name: Install Python dependencies and general setup
|
2020-08-11 17:14:47 +02:00
|
|
|
run: |
|
2024-01-09 13:47:16 +01:00
|
|
|
pip3 install pytest==7.1.2 mypy==0.971
|
2023-04-05 13:51:38 +02:00
|
|
|
git config diff.wsErrorHighlight all
|
2020-07-13 09:34:34 +02:00
|
|
|
|
2023-04-19 15:10:36 +02:00
|
|
|
- name: Get changed files
|
|
|
|
id: changed-files
|
2023-05-08 14:49:51 +02:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2023-04-19 15:10:36 +02:00
|
|
|
run: |
|
|
|
|
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
2023-05-08 14:49:51 +02:00
|
|
|
files=$(gh pr diff ${{ github.event.pull_request.number }} --name-only)
|
2023-04-19 15:10:36 +02:00
|
|
|
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
|
2023-04-20 17:51:53 +02:00
|
|
|
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
|
2023-04-19 15:10:36 +02:00
|
|
|
fi
|
|
|
|
echo "$files" >> changed.txt
|
|
|
|
cat changed.txt
|
2023-05-08 14:49:51 +02:00
|
|
|
files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "./{}"' | tr '\n' ' ')
|
2023-05-08 11:28:34 +02:00
|
|
|
echo "CHANGED_FILES=$files" >> $GITHUB_ENV
|
2023-04-19 15:10:36 +02:00
|
|
|
|
2023-07-01 15:32:30 +02:00
|
|
|
# This needs to happen before Python and npm execution; it must happen before any extra files are written.
|
|
|
|
- name: .gitignore checks (gitignore_check.sh)
|
|
|
|
run: |
|
|
|
|
bash ./misc/scripts/gitignore_check.sh
|
|
|
|
|
2024-01-09 13:47:16 +01:00
|
|
|
- name: Style checks via pre-commit
|
|
|
|
uses: pre-commit/action@v3.0.1
|
|
|
|
|
2020-07-13 09:34:34 +02:00
|
|
|
- name: File formatting checks (file_format.sh)
|
|
|
|
run: |
|
2023-04-19 15:10:36 +02:00
|
|
|
bash ./misc/scripts/file_format.sh changed.txt
|
2020-07-13 09:34:34 +02:00
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
- name: Header guards formatting checks (header_guards.sh)
|
|
|
|
run: |
|
2023-04-19 15:10:36 +02:00
|
|
|
bash ./misc/scripts/header_guards.sh changed.txt
|
2022-07-23 23:41:51 +02:00
|
|
|
|
2022-08-23 15:21:46 +02:00
|
|
|
- name: Python scripts static analysis (mypy_check.sh)
|
|
|
|
run: |
|
2023-04-20 18:16:38 +02:00
|
|
|
if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then
|
2023-04-19 15:10:36 +02:00
|
|
|
bash ./misc/scripts/mypy_check.sh
|
|
|
|
else
|
|
|
|
echo "Skipping Python static analysis as no Python files were changed."
|
|
|
|
fi
|
2022-08-23 15:21:46 +02:00
|
|
|
|
2022-06-30 04:14:07 +02:00
|
|
|
- name: Python builders checks via pytest (pytest_builders.sh)
|
|
|
|
run: |
|
|
|
|
bash ./misc/scripts/pytest_builders.sh
|
|
|
|
|
2021-02-22 06:10:16 +01:00
|
|
|
- name: JavaScript style and documentation checks via ESLint and JSDoc
|
2020-11-19 05:59:12 +01:00
|
|
|
run: |
|
2024-02-23 23:22:37 +01:00
|
|
|
if grep -q "\.js" changed.txt || [ -z "$(cat changed.txt)" ]; then
|
2023-04-19 15:10:36 +02:00
|
|
|
cd platform/web
|
|
|
|
npm ci
|
|
|
|
npm run lint
|
|
|
|
npm run docs -- -d dry-run
|
|
|
|
else
|
|
|
|
echo "Skipping JavaScript formatting as no Web/JS files were changed."
|
|
|
|
fi
|
2020-11-19 05:59:12 +01:00
|
|
|
|
2022-02-14 14:18:53 +01:00
|
|
|
- name: Class reference schema checks
|
|
|
|
run: |
|
2023-04-19 11:23:22 +02:00
|
|
|
xmllint --noout --schema doc/class.xsd doc/classes/*.xml modules/*/doc_classes/*.xml platform/*/doc_classes/*.xml
|
2022-02-14 14:18:53 +01:00
|
|
|
|
2020-07-13 09:34:34 +02:00
|
|
|
- name: Documentation checks
|
|
|
|
run: |
|
2023-07-13 05:20:44 +02:00
|
|
|
doc/tools/doc_status.py doc/classes modules/*/doc_classes platform/*/doc_classes
|
2022-08-27 03:14:27 +02:00
|
|
|
|
|
|
|
- name: Style checks via dotnet format (dotnet_format.sh)
|
|
|
|
run: |
|
2023-04-20 18:16:38 +02:00
|
|
|
if grep -q "modules/mono" changed.txt || [ -z "$(cat changed.txt)" ]; then
|
2023-04-19 15:10:36 +02:00
|
|
|
bash ./misc/scripts/dotnet_format.sh
|
|
|
|
else
|
|
|
|
echo "Skipping dotnet format as no C# files were changed."
|
|
|
|
fi
|
2023-02-01 10:50:52 +01:00
|
|
|
|
|
|
|
- name: Spell checks via codespell
|
2023-05-10 09:44:35 +02:00
|
|
|
if: github.event_name == 'pull_request' && env.CHANGED_FILES != ''
|
2023-06-16 08:45:35 +02:00
|
|
|
uses: codespell-project/actions-codespell@v2
|
2023-02-01 10:50:52 +01:00
|
|
|
with:
|
2023-05-10 09:44:35 +02:00
|
|
|
skip: "./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json"
|
2023-11-11 23:01:24 +01:00
|
|
|
ignore_words_list: "breaked,curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,mis,nd,numer,ot,requestor,te,vai"
|
2023-05-08 11:28:34 +02:00
|
|
|
path: ${{ env.CHANGED_FILES }}
|