|
| 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 | + # Needs to run in a container apparently, otherwise TCP connection won' work. |
| 30 | + container: ghcr.io/catthehacker/ubuntu:act-latest |
| 31 | + |
| 32 | + env: |
| 33 | + DONWLOAD_URL: https://github.com/godotengine/godot/releases/download/${{inputs.godot-version}}/Godot_v${{inputs.godot-version}}_linux.x86_64.zip |
| 34 | + BIN: Godot_v${{inputs.godot-version}}_linux.x86_64 |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Setup |
| 38 | + shell: bash |
| 39 | + run: | |
| 40 | + apt-get update |
| 41 | + apt-get install -y wget unzip |
| 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. (also first time setup, like importing resources) |
| 65 | + ./bin/${BIN} --headless --path ./repo/ --editor --lsp-port 6008 & |
| 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 | + WINEARCH=win32 WINEPREFIX=custom_prefix winecfg |
| 86 | +
|
| 87 | + - name: Download Godot |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + echo "Godot version: ${{ github.event.inputs.godot-version }}" |
| 91 | + mkdir -p bin |
| 92 | + cd bin |
| 93 | + wget "${DONWLOAD_URL}" -O godot.zip |
| 94 | + unzip godot.zip |
| 95 | + chmod u+x ${BIN} |
| 96 | + rm godot.zip |
| 97 | + ls -l |
| 98 | +
|
| 99 | + - name: Clone repository |
| 100 | + uses: actions/checkout@v4 |
| 101 | + with: |
| 102 | + path: repo |
| 103 | + ref: ${{ inputs.repo-ref }} |
| 104 | + |
| 105 | + - name: Run tests |
| 106 | + shell: bash |
| 107 | + run: | |
| 108 | + : # Run an editor process in background, because we need its LSP server |
| 109 | + WINEPREFIX=custom_prefix wine ./bin/${BIN} --headless --path ./repo/ --editor --lsp-port 6008 & |
| 110 | + sleep 10 |
| 111 | + WINEPREFIX=custom_prefix wine ./bin/${BIN} --headless --path ./repo/ --script addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit |
0 commit comments