Continuous Integration Testing (CI)

Definition

Continuous Integration (CI) is a method for automating the integration of code changes made by multiple contributors to a single software project. It is a primary DevOps best practice that allows developers to frequently merge code changes into a central repository where builds and tests are executed. Automated tools are used to confirm the new code is bug-free before integration.

Wiki - Continuous Integration

Command Line Tool

GdUnit4 provides a command line tool that allows you to automate your testing workflow, including CI.

For more details please show at Command Line Tool

Howto deploy with GitHub Action

To deploy with GitHub Actions, you need to create a new workflow file in the .github/workflows/ directory and name it ci.yml. Please visit GitHub Workflows Page

Using the gdUnit4-action

This GitHub Action automates the execution of GdUnit4 unit tests within the Godot Engine 4.x environment. It provides flexibility in configuring the Godot version, GdUnit4 version, test paths, and other parameters to suit your testing needs.
Find here on GitHub Marketplace gdUnit4-action

Example workflow: (Please note that this is just an example and needs to be adapted to your project environment.)

name: ci-pr-example
run-name: ${{ github.head_ref || github.ref_name }}-ci-pr-example

on:
  pull_request:
    paths-ignore:
      - '**.yml'
      - '**.md'
  workflow_dispatch:


concurrency:
  group: ci-pr-example${{ github.event.number }}
  cancel-in-progress: true


jobs:
  unit-test:
    name: "CI Unit Test"
    runs-on: 'ubuntu-22.04'
    timeout-minutes: 10 # The overall timeout
    permissions:
      actions: write
      checks: write
      contents: write
      pull-requests: write
      statuses: write

    steps:
      # checkout your repository
      - uses: actions/checkout@v4
        with:
          lfs: true
      # run tests by using the gdUnit4-action with Godot version 4.2.1 and the latest GdUnit4 release 
      - uses: MikeSchulze/gdUnit4-action@v1.0.2
        with:
          godot-version: '4.2.1'
          paths: |
            res://project/tests/
          timeout: 5
          report-name: test_report.xml      

Howto deploy with GitLab CI

You have to create a new workflow file on GitLab and named it .gitlab-ci.yml. Please visit GitLab CI Documentation for more detaild instructions

Thanks to mzoeller to providing this example workflow.

image: barichello/godot-ci:4.0.0

cache:
  key: import-assets
  paths:
    - .import/

stages:
  - export
  - tests
  - deploy

variables:
  EXPORT_NAME: $CI_PROJECT_NAME
  GIT_SUBMODULE_STRATEGY: recursive

linux:
  stage: export
  script:
    - mkdir -v -p build/linux
    - godot -v --export "Linux/X11" build/linux/$EXPORT_NAME.x86_64
  artifacts:
    name: $EXPORT_NAME-$CI_JOB_NAME
    paths:
      - build/linux

gdunit4:
  stage: tests
  dependencies:
    - linux
  script:
    - export GODOT_BIN=/usr/local/bin/godot
    - ./runtest.sh -a ./test || if [ $? -eq 101 ]; then echo "warnings"; elif [ $? -eq 0 ]; then echo "success"; else exit 1; fi
  artifacts:
    when: always
    reports:
      junit: ./reports/report_1/results.xml

document version v4.2.1


Copyright © 2021-2024 Mike Schulze. Distributed by an MIT license.