Skip to content

Commit 2645e38

Browse files
committed
Run tests automatically on push
1 parent dc77e39 commit 2645e38

File tree

4 files changed

+152
-5
lines changed

4 files changed

+152
-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: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
sudo apt-get update
40+
sudo apt-get install -y wget unzip net-tools
41+
42+
- name: Download Godot
43+
shell: bash
44+
run: |
45+
echo "Godot version: ${{ github.event.inputs.godot-version }}"
46+
mkdir -p bin
47+
cd bin
48+
wget "${DONWLOAD_URL}" -O godot.zip
49+
unzip godot.zip
50+
chmod u+x ${BIN}
51+
rm godot.zip
52+
ls -l
53+
54+
- name: Clone repository
55+
uses: actions/checkout@v4
56+
with:
57+
path: repo
58+
ref: ${{ inputs.repo-ref }}
59+
60+
# - name: Import assets
61+
# shell: bash
62+
# run: |
63+
# timeout 10s ./bin/${BIN} --headless --editor --path ./repo/ || /bin/true
64+
65+
- name: Run tests
66+
shell: bash
67+
run: |
68+
: # Run an editor process in background, because we need its LSP server
69+
./bin/${BIN} --headless --path ./repo/ --editor --lsp-port 6008 &
70+
sleep 10
71+
./bin/${BIN} --headless --path ./repo/ --script addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit
72+
73+
unit-tests-windows:
74+
name: 🔎 Unit tests - Windows
75+
runs-on: "ubuntu-latest"
76+
container: ghcr.io/catthehacker/ubuntu:act-latest
77+
78+
env:
79+
DONWLOAD_URL: https://github.com/godotengine/godot/releases/download/${{inputs.godot-version}}/Godot_v${{inputs.godot-version}}_win32.exe.zip
80+
BIN: Godot_v${{inputs.godot-version}}_win32.exe
81+
82+
steps:
83+
- name: Setup
84+
shell: bash
85+
run: |
86+
dpkg --add-architecture i386
87+
apt-get update
88+
apt-get install -y wget unzip wine-stable wine32
89+
90+
- name: Download Godot
91+
shell: bash
92+
run: |
93+
echo "Godot version: ${{ github.event.inputs.godot-version }}"
94+
mkdir -p bin
95+
cd bin
96+
wget "${DONWLOAD_URL}" -O godot.zip
97+
unzip godot.zip
98+
chmod u+x ${BIN}
99+
rm godot.zip
100+
ls -l
101+
102+
- name: Clone repository
103+
uses: actions/checkout@v4
104+
with:
105+
path: repo
106+
ref: ${{ inputs.repo-ref }}
107+
108+
- name: Import assets
109+
shell: bash
110+
run: |
111+
timeout 20s wine ./bin/${BIN} --headless --editor --path ./repo/ || /bin/true
112+
113+
- name: Run tests
114+
shell: bash
115+
run: |
116+
: # Run an editor process in background, because we need its LSP server
117+
wine ./bin/${BIN} --headless --path ./repo/ --editor &
118+
sleep 10
119+
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)