diff --git a/.gitea/workflows/build_artifacts.yml b/.gitea/workflows/build_artifacts.yml index b3a14d7..2a14cc7 100644 --- a/.gitea/workflows/build_artifacts.yml +++ b/.gitea/workflows/build_artifacts.yml @@ -24,11 +24,6 @@ jobs: timeout-minutes: 45 if: github.event.inputs.platform == 'windows' || github.event.inputs.platform == 'all' steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -50,6 +45,7 @@ jobs: - name: Export Windows run: | + mkdir -p build godot --headless --export-release "Windows Desktop" build/tekton_armageddon_${{ github.event.inputs.version || 'dev' }}_windows.exe - name: Upload artifact @@ -65,11 +61,6 @@ jobs: timeout-minutes: 45 if: github.event.inputs.platform == 'linux' || github.event.inputs.platform == 'all' steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -91,6 +82,7 @@ jobs: - name: Export Linux run: | + mkdir -p build godot --headless --export-release "Linux/X11" build/tekton_armageddon_${{ github.event.inputs.version || 'dev' }}_linux.x86_64 - name: Upload artifact @@ -106,11 +98,6 @@ jobs: timeout-minutes: 60 if: github.event.inputs.platform == 'android' || github.event.inputs.platform == 'all' steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -139,6 +126,7 @@ jobs: - name: Export Android run: | + mkdir -p build godot --headless --export-release "Android" build/tekton_dash_armageddon_${{ github.event.inputs.version || 'dev' }}.apk - name: Upload artifact diff --git a/.gitea/workflows/build_binaries.yml b/.gitea/workflows/build_binaries.yml index 045882b..672b200 100644 --- a/.gitea/workflows/build_binaries.yml +++ b/.gitea/workflows/build_binaries.yml @@ -7,8 +7,7 @@ on: jobs: build: runs-on: ubuntu-latest - container: - image: barichello/godot-ci:4.2.1 + timeout-minutes: 45 steps: - name: Checkout run: | @@ -19,19 +18,51 @@ jobs: git clone ssh://git@100.79.174.108:222/danchie/tekton.git . git checkout ${{ github.ref_name }} + - name: Setup Godot + run: | + wget -q https://github.com/godotengine/godot-builds/releases/download/4.6-stable/Godot_v4.6-stable_linux.x86_64.zip + unzip -q Godot_v4.6-stable_linux.x86_64.zip + sudo mv Godot_v4.6-stable_linux.x86_64 /usr/local/bin/godot + chmod +x /usr/local/bin/godot + + - name: Install export templates + run: | + mkdir -v -p ~/.local/share/godot/export_templates/4.6.stable + wget -q https://github.com/godotengine/godot-builds/releases/download/4.6-stable/Godot_v4.6-stable_export_templates.tpz + unzip -q Godot_v4.6-stable_export_templates.tpz -d ~/.local/share/godot/export_templates/4.6.stable + - name: Build Windows run: mkdir -p build && godot --headless --export-release "Windows Desktop" build/tekton.exe - name: Build Linux run: godot --headless --export-release "Linux/X11" build/tekton.x86_64 + - name: Get or create Gitea release + id: gitea_release + env: + GITEA_TOKEN: ${{ secrets.TEKTON_RELEASE_TOKEN }} + TAG_NAME: ${{ github.ref_name }} + run: | + API="https://git.klud.top/api/v1/repos/danchie/tekton/releases" + RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$API/tags/$TAG_NAME") + RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*') + if [ -z "$RELEASE_ID" ]; then + RELEASE_JSON=$(curl -s -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\"}" \ + "$API") + RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*') + fi + echo "release_id=$RELEASE_ID" >> "$GITHUB_OUTPUT" + - name: Upload Windows Binary run: | curl -X POST \ -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ -H "Content-Type: multipart/form-data" \ -F "attachment=@build/tekton.exe" \ - "https://git.klud.top/api/v1/repos/danchie/tekton/releases/tags/${{ github.ref_name }}" + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" - name: Upload Linux Binary run: | @@ -39,4 +70,4 @@ jobs: -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ -H "Content-Type: multipart/form-data" \ -F "attachment=@build/tekton.x86_64" \ - "https://git.klud.top/api/v1/repos/danchie/tekton/releases/tags/${{ github.ref_name }}" \ No newline at end of file + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 49500b7..8b3aab2 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -7,50 +7,11 @@ on: branches: [main, experimental, patch-release] jobs: - test: - name: Run Tests - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - - name: Checkout repository - uses: actions/checkout@v4 - with: - ssh-key: ${{ secrets.TEKTON_SSH_KEY }} - ssh-strict: false - - - name: Setup Godot - run: | - wget -q https://github.com/godotengine/godot-builds/releases/download/4.6-stable/Godot_v4.6-stable_linux.x86_64.zip - unzip -q Godot_v4.6-stable_linux.x86_64.zip - sudo mv Godot_v4.6-stable_linux.x86_64 /usr/local/bin/godot - chmod +x /usr/local/bin/godot - - - name: Install dependencies - run: | - # Install Godot headless dependencies - sudo apt-get update - sudo apt-get install -y libvulkan1 libx11-6 libxcursor1 libxi6 libxrandr2 libxinerama1 libxi6 libxxf86vm1 libgl1 - - - name: Run GUT tests - run: | - godot --headless -d --path . -s addons/gut/gut_cmdln.gd - export-windows: name: Export Windows runs-on: ubuntu-latest timeout-minutes: 45 - needs: test steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -72,6 +33,7 @@ jobs: - name: Export Windows run: | + mkdir -p build godot --headless --export-release "Windows Desktop" build/tekton_armageddon_windows.exe - name: Upload Windows artifact @@ -85,13 +47,7 @@ jobs: name: Export Linux runs-on: ubuntu-latest timeout-minutes: 45 - needs: test steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -113,6 +69,7 @@ jobs: - name: Export Linux run: | + mkdir -p build godot --headless --export-release "Linux/X11" build/tekton_armageddon_linux.x86_64 - name: Upload Linux artifact @@ -126,13 +83,7 @@ jobs: name: Export Android runs-on: ubuntu-latest timeout-minutes: 60 - needs: test steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -161,6 +112,7 @@ jobs: - name: Export Android run: | + mkdir -p build godot --headless --export-release "Android" build/tekton_dash_armageddon.apk - name: Upload Android artifact @@ -197,11 +149,45 @@ jobs: name: tekton-android path: artifacts/android - - name: Create Release - uses: softprops/action-gh-release@v2 - with: - files: | - artifacts/windows/tekton_armageddon_windows.exe - artifacts/linux/tekton_armageddon_linux.x86_64 - artifacts/android/tekton_dash_armageddon.apk - generate_release_notes: true \ No newline at end of file + - name: Get or create Gitea release + id: gitea_release + env: + GITEA_TOKEN: ${{ secrets.TEKTON_RELEASE_TOKEN }} + TAG_NAME: ${{ github.ref_name }} + run: | + API="https://git.klud.top/api/v1/repos/danchie/tekton/releases" + RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$API/tags/$TAG_NAME") + RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*') + if [ -z "$RELEASE_ID" ]; then + RELEASE_JSON=$(curl -s -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\"}" \ + "$API") + RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*') + fi + echo "release_id=$RELEASE_ID" >> "$GITHUB_OUTPUT" + + - name: Upload Windows asset + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@artifacts/windows/tekton_armageddon_windows.exe" \ + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" + + - name: Upload Linux asset + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@artifacts/linux/tekton_armageddon_linux.x86_64" \ + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" + + - name: Upload Android asset + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@artifacts/android/tekton_dash_armageddon.apk" \ + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" \ No newline at end of file diff --git a/.gitea/workflows/deploy_patch.yml b/.gitea/workflows/deploy_patch.yml index 42e6e69..00ffe6d 100644 --- a/.gitea/workflows/deploy_patch.yml +++ b/.gitea/workflows/deploy_patch.yml @@ -18,11 +18,6 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -44,15 +39,20 @@ jobs: unzip -q Godot_v4.6-stable_export_templates.tpz -d ~/.local/share/godot/export_templates/4.6.stable - name: Run patch build script + env: + PATCH_VERSION: ${{ github.event.inputs.version }} + PATCH_NOTES: ${{ github.event.inputs.notes }} run: | - python3 patch_version.py ${{ github.event.inputs.version }} "${{ github.event.inputs.notes }}" + python3 patch_version.py "$PATCH_VERSION" "$PATCH_NOTES" - name: Export Windows patch run: | + mkdir -p build godot --headless --export-release "Windows Desktop" build/tekton_armageddon_patch_windows.exe - name: Export Linux patch run: | + mkdir -p build godot --headless --export-release "Linux/X11" build/tekton_armageddon_patch_linux.x86_64 - name: Upload patch artifacts @@ -78,14 +78,40 @@ jobs: name: tekton-patch-${{ github.event.inputs.version }} path: artifacts/patch - - name: Create patch release - uses: softprops/action-gh-release@v2 - with: - tag_name: patch-${{ github.event.inputs.version }} - name: "Patch ${{ github.event.inputs.version }}" - body: | - ${{ github.event.inputs.notes }} - files: | - artifacts/patch/tekton_armageddon_patch_windows.exe - artifacts/patch/tekton_armageddon_patch_linux.x86_64 - prerelease: true \ No newline at end of file + - name: Get or create Gitea patch release + id: gitea_release + env: + GITEA_TOKEN: ${{ secrets.TEKTON_RELEASE_TOKEN }} + TAG_NAME: patch-${{ github.event.inputs.version }} + RELEASE_NAME: "Patch ${{ github.event.inputs.version }}" + RELEASE_NOTES: ${{ github.event.inputs.notes }} + run: | + API="https://git.klud.top/api/v1/repos/danchie/tekton/releases" + RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$API/tags/$TAG_NAME") + RELEASE_ID=$(echo "$RELEASE_JSON" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null) + if [ -z "$RELEASE_ID" ]; then + PAYLOAD=$(python3 -c "import json, os; print(json.dumps({'tag_name': os.environ['TAG_NAME'], 'name': os.environ['RELEASE_NAME'], 'body': os.environ['RELEASE_NOTES'], 'prerelease': True}))") + RELEASE_JSON=$(curl -s -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "$PAYLOAD" \ + "$API") + RELEASE_ID=$(echo "$RELEASE_JSON" | python3 -c "import json,sys; print(json.load(sys.stdin)['id'])") + fi + echo "release_id=$RELEASE_ID" >> "$GITHUB_OUTPUT" + + - name: Upload Windows patch asset + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@artifacts/patch/tekton_armageddon_patch_windows.exe" \ + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" + + - name: Upload Linux patch asset + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@artifacts/patch/tekton_armageddon_patch_linux.x86_64" \ + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" \ No newline at end of file diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 0afd30e..1c2e100 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -13,11 +13,6 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -45,11 +40,6 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -78,24 +68,17 @@ jobs: # Start server in background ./build/tekton_server.x86_64 --headless --port 7777 & SERVER_PID=$! + trap 'kill $SERVER_PID 2>/dev/null' EXIT sleep 5 # Run client tests against server godot --headless -d --path . -s addons/gut/gut_cmdln.gd --select=test_integration - # Cleanup - kill $SERVER_PID - lint: name: Code Style Check runs-on: ubuntu-latest timeout-minutes: 10 steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: @@ -109,21 +92,15 @@ jobs: sudo mv Godot_v4.6-stable_linux.x86_64 /usr/local/bin/godot chmod +x /usr/local/bin/godot - - name: Check GDScript formatting + - name: Check GDScript syntax run: | - godot --headless --check-only -s scripts/lint.gd || true - # Note: GDScript doesn't have a built-in formatter; this checks syntax only + godot --headless -s scripts/lint.gd security-scan: name: Security Scan runs-on: ubuntu-latest timeout-minutes: 15 steps: - - name: Setup SSH config for Gitea - run: | - mkdir -p ~/.ssh - echo -e "Host gitea\n HostName 100.79.174.108\n Port 222\n StrictHostKeyChecking no" > ~/.ssh/config - - name: Checkout repository uses: actions/checkout@v4 with: diff --git a/.gitea/workflows/upload_pck.yml b/.gitea/workflows/upload_pck.yml index 0fe647d..3b16b88 100644 --- a/.gitea/workflows/upload_pck.yml +++ b/.gitea/workflows/upload_pck.yml @@ -7,8 +7,7 @@ on: jobs: upload: runs-on: ubuntu-latest - container: - image: barichello/godot-ci:4.3 + timeout-minutes: 30 steps: - name: Checkout run: | @@ -19,16 +18,42 @@ jobs: git clone ssh://git@100.79.174.108:222/danchie/tekton.git . git checkout ${{ github.ref_name }} + - name: Setup Godot + run: | + wget -q https://github.com/godotengine/godot-builds/releases/download/4.6-stable/Godot_v4.6-stable_linux.x86_64.zip + unzip -q Godot_v4.6-stable_linux.x86_64.zip + sudo mv Godot_v4.6-stable_linux.x86_64 /usr/local/bin/godot + chmod +x /usr/local/bin/godot + - name: Build PCK run: godot --headless -s tools/build_patch.gd + - name: Get or create Gitea release + id: gitea_release + env: + GITEA_TOKEN: ${{ secrets.TEKTON_RELEASE_TOKEN }} + TAG_NAME: ${{ github.ref_name }} + run: | + API="https://git.klud.top/api/v1/repos/danchie/tekton/releases" + RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$API/tags/$TAG_NAME") + RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*') + if [ -z "$RELEASE_ID" ]; then + RELEASE_JSON=$(curl -s -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\"}" \ + "$API") + RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*') + fi + echo "release_id=$RELEASE_ID" >> "$GITHUB_OUTPUT" + - name: Upload PCK to Release run: | curl -X POST \ -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ -H "Content-Type: multipart/form-data" \ -F "attachment=@patch.pck" \ - "https://git.klud.top/api/v1/repos/danchie/tekton/releases/tags/${{ github.ref_name }}" + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" - name: Upload version.json to Release run: | @@ -36,4 +61,4 @@ jobs: -H "Authorization: token ${{ secrets.TEKTON_RELEASE_TOKEN }}" \ -H "Content-Type: multipart/form-data" \ -F "attachment=@assets/data/version.json" \ - "https://git.klud.top/api/v1/repos/danchie/tekton/releases/tags/${{ github.ref_name }}" \ No newline at end of file + "https://git.klud.top/api/v1/repos/danchie/tekton/releases/${{ steps.gitea_release.outputs.release_id }}/assets" diff --git a/assets/models/meshes/block.res b/assets/models/meshes/block.res index cdad7cf..25ec462 100644 Binary files a/assets/models/meshes/block.res and b/assets/models/meshes/block.res differ diff --git a/patch_version.py b/patch_version.py index a50378a..506032a 100644 --- a/patch_version.py +++ b/patch_version.py @@ -1,36 +1,33 @@ import json +import sys from datetime import date +if len(sys.argv) < 2: + print("Usage: patch_version.py [notes]") + sys.exit(1) + +version = sys.argv[1] +notes = sys.argv[2] if len(sys.argv) > 2 else "" + with open("assets/data/version.json", "r", encoding="utf-8") as f: data = json.load(f) -# Find the 2.4.0 entry or just add 2.4.1 at the top -changelog = [ - "Fixed Gauntlet map layout to remove red unpassable barrier blocks and center blocks.", - "Fixed Gauntlet mode to prevent powerups or sticky bubbles from spawning on boundary tiles or under the central cannon.", - "Center Candy Cannon now shoots actual projectiles that fly towards sticky cells and leave a VFX trail.", - "Added new VFX to the Center Candy Cannon. It now has a glowing pink tank and spinning metallic rings.", - "Fixed Gauntlet Cleanser to stack charges instead of capping at 1.", - "Cleanser instantly clears a 3x3 AoE of sticky cells and frees any players inside immediately upon activation.", - "Added VFX and SFX when purifying cells with the Cleanser (cyan burst particles).", - "Added instant visual feedback indicator for Gauntlet Cleanser using popup text when consumed.", - "Fixed Gauntlet Cleanser UI phase label layout to ensure it does not overlap with other UI elements." -] +changelog = [line.strip() for line in notes.splitlines() if line.strip()] new_release = { - "version": "2.4.1", - "date": "2026-06-28", + "version": version, + "date": date.today().isoformat(), "pck_url": "https://raw.githubusercontent.com/adtpdn/tekton-updates/main/latest/patch.pck", "pck_size": 0, "changelog": changelog } -# Remove existing 2.4.1 if any -data["releases"] = [r for r in data["releases"] if r.get("version") != "2.4.1"] +# Remove existing entry for this version if any +data["releases"] = [r for r in data["releases"] if r.get("version") != version] # Insert at top data["releases"].insert(0, new_release) -data["latest_version"] = "2.4.1" +data["latest_version"] = version with open("assets/data/version.json", "w", encoding="utf-8") as f: json.dump(data, f, indent="\t") diff --git a/scripts/lint.gd b/scripts/lint.gd new file mode 100644 index 0000000..4dc35ef --- /dev/null +++ b/scripts/lint.gd @@ -0,0 +1,36 @@ +extends SceneTree + +const SKIP_DIRS := [".git", ".godot", "addons"] + +func _initialize() -> void: + var errors: Array[String] = [] + _scan_dir("res://", errors) + if errors.is_empty(): + print("Lint passed: no GDScript syntax errors found") + quit(0) + else: + for e in errors: + printerr(e) + printerr("Lint failed: %d file(s) with syntax errors" % errors.size()) + quit(1) + +func _scan_dir(path: String, errors: Array[String]) -> void: + var dir := DirAccess.open(path) + if dir == null: + return + dir.list_dir_begin() + var entry := dir.get_next() + while entry != "": + if entry == "." or entry == "..": + entry = dir.get_next() + continue + var full_path := path.path_join(entry) + if dir.current_is_dir(): + if not SKIP_DIRS.has(entry): + _scan_dir(full_path, errors) + elif entry.ends_with(".gd"): + var script := GDScript.new() + script.source_code = FileAccess.get_file_as_string(full_path) + if script.reload() != OK: + errors.append("%s: syntax error" % full_path) + entry = dir.get_next()