|
| 1 | +# Runs on game directory files for: |
| 2 | +# - Push to master/main |
| 3 | +# - Pull requests to master/main/dev |
| 4 | +name: Godot CI |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: ['master', 'main'] |
| 9 | + paths: |
| 10 | + - 'game/**' # Only runs when game files change |
| 11 | + pull_request: |
| 12 | + branches: ['master', 'main', 'dev'] |
| 13 | + paths: |
| 14 | + - 'game/**' # Only runs when game files change |
| 15 | + |
| 16 | +jobs: |
| 17 | + # Spellcheck checks |
| 18 | + spell-check: |
| 19 | + name: 'Spellcheck' |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - uses: streetsidesoftware/cspell-action@v6 |
| 24 | + with: |
| 25 | + config: '.vscode/cspell.json' |
| 26 | + incremental_files_only: false |
| 27 | + root: './game' |
| 28 | + |
| 29 | + # Formatting and linting checks |
| 30 | + format-and-lint-check: |
| 31 | + name: 'GDScript Formatting Check' |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + # Install GDScript toolkit for formatting |
| 38 | + - name: Setup GDScript toolkit |
| 39 | + uses: Scony/godot-gdscript-toolkit@4.2.0 |
| 40 | + |
| 41 | + # Run formatting check |
| 42 | + - name: Check formatting |
| 43 | + run: | |
| 44 | + cd game |
| 45 | + gdformat --check ./ |
| 46 | +
|
| 47 | + # Run linting check |
| 48 | + - name: Run linting |
| 49 | + run: | |
| 50 | + cd game |
| 51 | + gdlint ./ |
| 52 | +
|
| 53 | + # Runs visual tests with specific graphics drivers |
| 54 | + visual-tests: |
| 55 | + name: 'Visual Tests (${{ matrix.render-driver }})' |
| 56 | + runs-on: ubuntu-latest |
| 57 | + # Prevents duplicate workflows on PRs from same repository |
| 58 | + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name |
| 59 | + env: |
| 60 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 61 | + DOTNET_NOLOGO: true |
| 62 | + strategy: |
| 63 | + fail-fast: false |
| 64 | + matrix: |
| 65 | + render-driver: [vulkan] # Can add opengl3 if needed |
| 66 | + steps: |
| 67 | + # Checkout with LFS and submodules |
| 68 | + - name: Checkout code |
| 69 | + uses: actions/checkout@v4 |
| 70 | + with: |
| 71 | + lfs: true |
| 72 | + submodules: 'recursive' |
| 73 | + |
| 74 | + # Setup .NET environment |
| 75 | + - name: Setup .NET |
| 76 | + uses: actions/setup-dotnet@v4.0.0 |
| 77 | + with: |
| 78 | + global-json-file: global.json |
| 79 | + |
| 80 | + - name: Restore dependencies |
| 81 | + run: dotnet restore |
| 82 | + |
| 83 | + # Setup graphics drivers |
| 84 | + - name: Add graphics repositories |
| 85 | + run: | |
| 86 | + sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list |
| 87 | + sudo add-apt-repository -n ppa:kisak/kisak-mesa |
| 88 | +
|
| 89 | + # Install and cache graphics packages |
| 90 | + - name: Install graphics drivers |
| 91 | + uses: awalsh128/cache-apt-pkgs-action@v1.4.1 |
| 92 | + with: |
| 93 | + packages: mesa-vulkan-drivers binutils |
| 94 | + version: 1.0 |
| 95 | + |
| 96 | + # Setup Godot environment |
| 97 | + - name: Setup Godot |
| 98 | + uses: chickensoft-games/setup-godot@v2.0.0 |
| 99 | + with: |
| 100 | + version: global.json |
| 101 | + |
| 102 | + # Generate C# bindings |
| 103 | + - name: Generate .NET Bindings |
| 104 | + working-directory: ./game |
| 105 | + run: godot --headless --build-solutions --quit || exit 0 |
| 106 | + |
| 107 | + # Run the actual tests |
| 108 | + - name: Run Tests |
| 109 | + working-directory: ./game |
| 110 | + run: | |
| 111 | + xvfb-run godot --audio-driver Dummy --rendering-driver ${{ matrix.render-driver }} --run-tests --quit-on-finish --coverage |
0 commit comments