From 3d6d270084ce28a6c02c483b8883ce58c2419d8b Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Sat, 18 May 2024 16:33:16 +0200 Subject: [PATCH] Run tests automatically on push --- .github/workflows/ci.yml | 25 +++++++ .github/workflows/unit_tests.yml | 111 +++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/unit_tests.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0c6224e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: ⚙️ CI +on: + push: + # branches: [ master ] + paths-ignore: + - "README.md" + - "LICENSE" + - "**/*.png" + - "**/*.svg" + + pull_request: + # branches: [ master ] + paths-ignore: + - "README.md" + - "LICENSE" + - "**/*.png" + - "**/*.svg" + +jobs: + ci-unit-tests: + name: "⚙️ CI: Unit tests" + uses: ./.github/workflows/unit_tests.yml + with: + repo-ref: ${{ github.ref }} + diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..3604b3c --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,111 @@ +name: 🔎 Unit tests +on: + workflow_call: + inputs: + godot-version: + description: Godot Engine version to use for testing. + type: string + default: 4.2.1-stable + repo-ref: + description: A commit, branch or tag to use for testing. + type: string + required: true + + workflow_dispatch: + inputs: + godot-version: + description: Godot Engine version to use for testing. + type: string + default: 4.2.1-stable + repo-ref: + description: A commit, branch or tag to use for testing. + type: string + required: true + +jobs: + unit-tests-linux: + name: 🔎 Unit tests - Linux + runs-on: "ubuntu-latest" + + env: + DONWLOAD_URL: https://github.com/godotengine/godot/releases/download/${{inputs.godot-version}}/Godot_v${{inputs.godot-version}}_linux.x86_64.zip + BIN: Godot_v${{inputs.godot-version}}_linux.x86_64 + + steps: + - name: Download Godot + shell: bash + run: | + echo "Godot version: ${{ github.event.inputs.godot-version }}" + mkdir -p bin + cd bin + wget "${DONWLOAD_URL}" -O godot.zip + unzip godot.zip + chmod u+x ${BIN} + rm godot.zip + ls -l + + - name: Verify Godot binary + shell: bash + run: | + ls -l ./bin/ + ./bin/${BIN} --version + + - name: Clone repository + uses: actions/checkout@v4 + with: + path: repo + ref: ${{ inputs.repo-ref }} + + - name: Run tests + shell: bash + run: | + : # Run an editor process in background, because we need its LSP server + ./bin/${BIN} --headless --path ./repo/ --editor & + sleep 5 + ./bin/${BIN} --headless --path ./repo/ --script addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit + + unit-tests-windows: + name: 🔎 Unit tests - Windows + runs-on: "ubuntu-latest" + + env: + DONWLOAD_URL: https://github.com/godotengine/godot/releases/download/${{inputs.godot-version}}/Godot_v${{inputs.godot-version}}_win64.exe.zip + BIN: Godot_v${{inputs.godot-version}}_win64.exe + + steps: + - name: Download Godot + shell: bash + run: | + echo "Godot version: ${{ github.event.inputs.godot-version }}" + mkdir -p bin + cd bin + wget "${DONWLOAD_URL}" -O godot.zip + unzip godot.zip + chmod u+x ${BIN} + rm godot.zip + ls -l + + - name: Install wine + shell: bash + run: | + apt-get install wine-stable + + - name: Verify Godot binary + shell: bash + run: | + ls -l ./bin/ + ./bin/${BIN} --version + + - name: Clone repository + uses: actions/checkout@v4 + with: + path: repo + ref: ${{ inputs.repo-ref }} + + - name: Run tests + shell: bash + run: | + : # Run an editor process in background, because we need its LSP server + wine ./bin/${BIN} --headless --path ./repo/ --editor & + sleep 5 + wine ./bin/${BIN} --headless --path ./repo/ --script addons/gut/gut_cmdln.gd -gdir=res://test/ -gexit