From ee2a3445b60c030cbb96fa88e294dff2fca9e7e2 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Mon, 11 Nov 2024 19:15:29 +0100 Subject: [PATCH] Add existing tests to CI --- .github/actions/run-godot-tests/action.yml | 16 ++++++ .github/workflows/build-pull-request.yml | 7 ++- .github/workflows/build-release-tagged.yml | 9 +++- .github/workflows/build-release-unstable.yml | 11 +++- .github/workflows/tests-run-project.yml | 54 ++++++++++++++++++++ 5 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 .github/actions/run-godot-tests/action.yml create mode 100644 .github/workflows/tests-run-project.yml diff --git a/.github/actions/run-godot-tests/action.yml b/.github/actions/run-godot-tests/action.yml new file mode 100644 index 0000000..36e93f8 --- /dev/null +++ b/.github/actions/run-godot-tests/action.yml @@ -0,0 +1,16 @@ +name: Run Godot tests +description: Run a test project on the target platform. + +inputs: + project-path: + default: "./tests" + run-script: + default: "./run.gd" + +runs: + using: "composite" + steps: + - name: Run the project script + shell: bash + run: | + godot --headless --path ${{ inputs.project-path }} --script ${{ inputs.run-script }} --verbose diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index c964a3c..67d9aad 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -32,7 +32,12 @@ jobs: name: Compile and upload Android version uses: ./.github/workflows/extension-build-android.yml -# Then, use the artifacts to test the example project. +# Then, use the artifacts to do tests. + + run-tests-project: + name: Run tests on target platforms + needs: [ build-linux, build-macos, build-windows, build-web, build-android ] + uses: ./.github/workflows/tests-run-project.yml export-example-project: name: Export the example project for target platforms diff --git a/.github/workflows/build-release-tagged.yml b/.github/workflows/build-release-tagged.yml index 7c22ebf..bf18903 100644 --- a/.github/workflows/build-release-tagged.yml +++ b/.github/workflows/build-release-tagged.yml @@ -47,11 +47,18 @@ jobs: with: git-base-ref: ${{ github.ref }} +# Then, use the artifacts to do tests. + + run-tests-project: + name: Run tests on target platforms + needs: [ build-linux, build-macos, build-windows, build-web, build-android ] + uses: ./.github/workflows/tests-run-project.yml + # Then, make a draft release for the tag. release-all: name: Make a draft GitHub Release for the tag - needs: [ build-linux, build-macos, build-windows, build-web, build-android ] + needs: [ run-tests-project ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/build-release-unstable.yml b/.github/workflows/build-release-unstable.yml index 2e1fe80..8c25a99 100644 --- a/.github/workflows/build-release-unstable.yml +++ b/.github/workflows/build-release-unstable.yml @@ -46,18 +46,25 @@ jobs: with: git-base-ref: 'main' +# Then, use the artifacts to do tests. + + run-tests-project: + name: Run tests on target platforms + needs: [ build-linux, build-macos, build-windows, build-web, build-android ] + uses: ./.github/workflows/tests-run-project.yml + # Then, use the artifacts to prepare the example project and publish the build. publish-all: name: Package and publish the extension - needs: [ build-linux, build-macos, build-windows, build-web, build-android ] + needs: [ run-tests-project ] uses: ./.github/workflows/extension-publish-all.yml with: release-version: 'latest-unstable' export-example-project: name: Export the example project for target platforms - needs: [ build-linux, build-macos, build-windows, build-web, build-android ] + needs: [ run-tests-project ] uses: ./.github/workflows/example-export-project.yml secrets: inherit with: diff --git a/.github/workflows/tests-run-project.yml b/.github/workflows/tests-run-project.yml new file mode 100644 index 0000000..c9aba31 --- /dev/null +++ b/.github/workflows/tests-run-project.yml @@ -0,0 +1,54 @@ +name: Run Tests + +on: + workflow_call: + +# Make sure jobs cannot overlap. +concurrency: + group: test-${{ github.ref }}-project + cancel-in-progress: true + +env: + GODOT_VERSION: "4.3.0-stable" + +jobs: + export-publish: + strategy: + fail-fast: false + matrix: + include: + - platform: linux + arch: x86_64 + preset: "Linux - x86_64" + runs-on: ubuntu-latest + + name: Run the tests project (${{ matrix.preset }}) + runs-on: ${{ matrix.runs-on }} + steps: + - uses: actions/checkout@v4 + + # Set up prerequisites. + + - name: Install Godot ${{ env.GODOT_VERSION }} + uses: chickensoft-games/setup-godot@v2 + with: + version: ${{ env.GODOT_VERSION }} + use-dotnet: false + include-templates: true + + - name: Verify Godot + shell: bash + run: | + godot --version + + - name: Download GDSiON artifacts + uses: actions/download-artifact@v4 + with: + path: tests/bin + pattern: libgdsion-* + merge-multiple: true + + # Run the tests. + + - name: Run tests + uses: ./.github/actions/run-godot-tests