Skip to content

Commit

Permalink
Diff Generator Output (#662)
Browse files Browse the repository at this point in the history
* 4.3 project update... apparently opening the project did this ¯\_(ツ)_/¯

* add workflow to diff generated output

* generate to /tmp

* Example generator change.

* generate to .build

* don't sandbox

* try just using build products

* don't sparse checkout since we need to switch branches

* cleaner output

* tweaked diff

* filter for changes in the generator

* use the right name for the workflow!
  • Loading branch information
samdeane authored Jan 31, 2025
1 parent 0f9413d commit b451b6e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This workflow checks to see if the Generator code has changed.
# If it has, we run the new generator, and the version from the target branch,
# and then we diff the two outputs.

name: Generator

on:
pull_request:
branches: [ "main" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-diff
cancel-in-progress: true

jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
generator: ${{ steps.filter.outputs.generator }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
generator:
- 'Generator/**'
# JOB to run the diff - only runs if changes were detected in Generator/
diff-generator:
needs: changes
if: ${{ needs.changes.outputs.generator == 'true' }}
runs-on: macos-14

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
generator:
- 'Generator/**'
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "16.2"
- name: Build This Branch
run: swift build --target SwiftGodot --scratch-path .build/New
- name: Checkout Target Branch
run: git checkout ${{ github.event.pull_request.base.sha }}
- name: Build Target Branch
run: swift build --target SwiftGodot --scratch-path .build/Old
- name: Diff generated
run: diff --recursive --color=auto --minimal .build/New/plugins/outputs/swiftgodot/SwiftGodot/destination/CodeGeneratorPlugin/ .build/Old/plugins/outputs/swiftgodot/SwiftGodot/destination/CodeGeneratorPlugin/ | sed -e 's/diff\(.*\)\/\(.*\).swift/\n\2.swift:/'


2 changes: 1 addition & 1 deletion Generator/Generator/Printer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Printer {

fileprivate static let preamble =
"""
// This file is autogenerated, do not edit
// This file is auto-generated, do not edit.
@_implementationOnly import GDExtension
#if CUSTOM_BUILTIN_IMPLEMENTATIONS
Expand Down
2 changes: 1 addition & 1 deletion Testbed/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config_version=5

config/name="GDExtension Test Project"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.1")
config/features=PackedStringArray("4.3")
config/icon="res://icon.png"

[native_extensions]
Expand Down

0 comments on commit b451b6e

Please sign in to comment.