Skip to content

Commit 62d3ce6

Browse files
committed
Run tests automatically on push
1 parent dc77e39 commit 62d3ce6

File tree

4 files changed

+143
-5
lines changed

4 files changed

+143
-5
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: ⚙️ CI
2+
on:
3+
push:
4+
# branches: [ master ]
5+
paths-ignore:
6+
- "README.md"
7+
- "LICENSE"
8+
- "**/*.png"
9+
- "**/*.svg"
10+
11+
pull_request:
12+
# branches: [ master ]
13+
paths-ignore:
14+
- "README.md"
15+
- "LICENSE"
16+
- "**/*.png"
17+
- "**/*.svg"
18+
19+
jobs:
20+
ci-unit-tests:
21+
name: "⚙️ CI: Unit tests"
22+
uses: ./.github/workflows/unit_tests.yml
23+
with:
24+
repo-ref: ${{ github.ref }}
25+

.github/workflows/unit_tests.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: 🔎 Unit tests
2+
on:
3+
workflow_call:
4+
inputs:
5+
godot-version:
6+
description: Godot Engine version to use for testing.
7+
type: string
8+
default: 4.2.1-stable
9+
repo-ref:
10+
description: A commit, branch or tag to use for testing.
11+
type: string
12+
required: true
13+
14+
workflow_dispatch:
15+
inputs:
16+
godot-version:
17+
description: Godot Engine version to use for testing.
18+
type: string
19+
default: 4.2.1-stable
20+
repo-ref:
21+
description: A commit, branch or tag to use for testing.
22+
type: string
23+
required: true
24+
25+
jobs:
26+
unit-tests-linux:
27+
name: 🔎 Unit tests - Linux
28+
runs-on: "ubuntu-latest"
29+
# container: ghcr.io/catthehacker/ubuntu:act-latest
30+
31+
env:
32+
DONWLOAD_URL: https://github.com/godotengine/godot/releases/download/${{inputs.godot-version}}/Godot_v${{inputs.godot-version}}_linux.x86_64.zip
33+
BIN: Godot_v${{inputs.godot-version}}_linux.x86_64
34+
35+
steps:
36+
- name: Setup
37+
shell: bash
38+
run: |
39+
apt-get update
40+
apt-get install -y wget unzip
41+
netstat -l
42+
43+
- name: Download Godot
44+
shell: bash
45+
run: |
46+
echo "Godot version: ${{ github.event.inputs.godot-version }}"
47+
mkdir -p bin
48+
cd bin
49+
wget "${DONWLOAD_URL}" -O godot.zip
50+
unzip godot.zip
51+
chmod u+x ${BIN}
52+
rm godot.zip
53+
ls -l
54+
55+
- name: Clone repository
56+
uses: actions/checkout@v4
57+
with:
58+
path: repo
59+
ref: ${{ inputs.repo-ref }}
60+
61+
- name: Run tests
62+
shell: bash
63+
run: |
64+
: # Run an editor process in background, because we need its LSP server
65+
./bin/${BIN} --headless --path ./repo/ --editor &
66+
sleep 10
67+
./bin/${BIN} --headless --path ./repo/ --script addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit
68+
69+
unit-tests-windows:
70+
name: 🔎 Unit tests - Windows
71+
runs-on: "ubuntu-latest"
72+
# container: ghcr.io/catthehacker/ubuntu:act-latest
73+
74+
env:
75+
DONWLOAD_URL: https://github.com/godotengine/godot/releases/download/${{inputs.godot-version}}/Godot_v${{inputs.godot-version}}_win32.exe.zip
76+
BIN: Godot_v${{inputs.godot-version}}_win32.exe
77+
78+
steps:
79+
- name: Setup
80+
shell: bash
81+
run: |
82+
dpkg --add-architecture i386
83+
apt-get update
84+
apt-get install -y wget unzip wine-stable wine32
85+
86+
- name: Download Godot
87+
shell: bash
88+
run: |
89+
echo "Godot version: ${{ github.event.inputs.godot-version }}"
90+
mkdir -p bin
91+
cd bin
92+
wget "${DONWLOAD_URL}" -O godot.zip
93+
unzip godot.zip
94+
chmod u+x ${BIN}
95+
rm godot.zip
96+
ls -l
97+
98+
- name: Clone repository
99+
uses: actions/checkout@v4
100+
with:
101+
path: repo
102+
ref: ${{ inputs.repo-ref }}
103+
104+
- name: Run tests
105+
shell: bash
106+
run: |
107+
: # Run an editor process in background, because we need its LSP server
108+
wine ./bin/${BIN} --headless --path ./repo/ --editor &
109+
sleep 10
110+
wine ./bin/${BIN} --headless --path ./repo/ --script addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit

addons/diagnosticlist/LSPClient.gd

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,28 @@ func disconnect_lsp() -> void:
4747

4848

4949
## Connect to the LSP server using host and port specified in the editor config.
50-
func connect_lsp() -> void:
50+
func connect_lsp() -> bool:
5151
var settings := EditorInterface.get_editor_settings()
5252
var port: int = settings.get("network/language_server/remote_port")
5353
var host: String = settings.get("network/language_server/remote_host")
54-
connect_lsp_at(host, port)
54+
return connect_lsp_at(host, port)
5555

5656

5757
## Connect to the LSP server at the given host and port.
58-
func connect_lsp_at(host: String, port: int) -> void:
58+
func connect_lsp_at(host: String, port: int) -> bool:
5959
var err := _client.connect_to_host(host, port)
6060

6161
if err != OK:
6262
log_error("Failed to connect to LSP server: %s" % err)
63+
return false
6364

6465
# Enable processing
6566
_id = 0
6667
_timer.start()
6768
_reset_tick_interval()
6869

70+
return true
71+
6972

7073
func is_lsp_connected() -> bool:
7174
return _client.get_status() == StreamPeerTCP.STATUS_CONNECTED

test/BaseTest.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func _connect_client() -> DiagnosticList_LSPClient:
1616

1717
assert_false(client.is_lsp_connected())
1818

19-
client.connect_lsp_at("127.0.0.1", 6008)
19+
client.connect_lsp_at("localhost", 6008)
2020
await wait_for_signal(client.on_initialized, 3)
2121

2222
return client
@@ -26,7 +26,7 @@ func _get_diagnostics(client: DiagnosticList_LSPClient, res_path: String) -> Dia
2626
client.on_publish_diagnostics.connect(_on_publish_diagnostics)
2727

2828
client.update_diagnostics(res_path, FileAccess.get_file_as_string(res_path))
29-
await client.on_publish_diagnostics
29+
await wait_for_signal(client.on_publish_diagnostics, 3)
3030

3131
client.on_publish_diagnostics.disconnect(_on_publish_diagnostics)
3232

0 commit comments

Comments
 (0)