Skip to content

Commit 2b6a1aa

Browse files
committed
Added new job for fixing linter
1 parent e392082 commit 2b6a1aa

1 file changed

Lines changed: 53 additions & 1 deletion

File tree

.yamato/project-standards.yml

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,59 @@ standards_{{ platform.name }}_{{ project.name }}_{{ editor }}:
5454
- .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath {{ project.path }} -quit # This command is used to invoke Unity in a "headless" mode. It's used to sync the project
5555
- dotnet run --project=dotnet-tools/netcode.standards -- --project={{ project.path }} --fix # Auto-fix formatting issues
5656
- git checkout -- {{ project.path }}/Packages/manifest.json {{ project.path }}/Packages/packages-lock.json {{ project.path }}/ProjectSettings/ProjectVersion.txt 2>/dev/null || true # Restore files that Unity may have modified (we only want to check code formatting)
57-
- 'git diff --exit-code || (echo "ERROR: Code formatting issues found. Run dotnet run --project=dotnet-tools/netcode.standards -- --project={{ project.path }} --fix locally and commit the changes." && exit 1)' # Fail if formatter made any changes
57+
- 'git diff --exit-code || (echo "ERROR: Code formatting issues found. Fix by EITHER running locally: dotnet run --project=dotnet-tools/netcode.standards -- --project={{ project.path }} --fix (then commit), OR triggering the standards_fix_and_push job in Yamato on this branch to auto-fix and push the changes." && exit 1)' # Fail if formatter made any changes
5858
{% endfor -%}
5959
{% endfor -%}
60+
{% endfor -%}
61+
62+
# AUTO-FIX & PUSH JOB-----------------------------------------------------------------
63+
# This job is intentionally NOT wired into any trigger pipeline (see _triggers.yml / _run-all.yml).
64+
# It is meant to be run MANUALLY from Yamato against the branch that has a failing standards check.
65+
# It runs the SAME `netcode.standards --fix` the check job runs (for every project), then commits
66+
# and pushes the resulting formatting changes back to that branch so the standards check passes.
67+
# It exists because fixing locally requires a matching installed editor + SyncSolution + the pinned
68+
# SDK (global.json); this job removes that setup burden.
69+
# Pushing reuses NETCODE_GITHUB_TOKEN (same token as the release automation in ngo-publish.yml).
70+
# LIMITATION: cannot push to pull requests opened from forks (no write access to fork branches);
71+
# those still need the local --fix workflow. Protected branches will reject the push by design.
72+
#------------------------------------------------------------------------------------
73+
74+
{% for platform in test_platforms.default -%}
75+
{% for editor in validation_editors.default -%}
76+
standards_fix_and_push_{{ platform.name }}_{{ editor }}:
77+
name: Standards Fix and Push - NGO (all projects) [{{ platform.name }}, {{ editor }}]
78+
agent:
79+
type: {{ platform.type }}
80+
image: {{ platform.image }}
81+
flavor: {{ platform.flavor }}
82+
{% if platform.model %}
83+
model: {{ platform.model }}
84+
{% endif %}
85+
commands:
86+
- dotnet --version
87+
- dotnet format --version
88+
- unity-downloader-cli --fast --wait -u {{ editor }} -c editor {% if platform.name == "mac" %} --arch arm64 {% endif %} # Downloads basic editor
89+
{% for project in projects.all %}
90+
- .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath {{ project.path }} -quit # Sync solution so csproj references resolve (required by the style pass)
91+
- dotnet run --project=dotnet-tools/netcode.standards -- --project={{ project.path }} --fix # Auto-fix formatting issues
92+
- git checkout -- {{ project.path }}/Packages/manifest.json {{ project.path }}/Packages/packages-lock.json {{ project.path }}/ProjectSettings/ProjectVersion.txt 2>/dev/null || true # Restore files Unity may have modified
93+
{% endfor %}
94+
- |
95+
if [ -z "$(git status --porcelain)" ]; then
96+
echo "No formatting changes to push; branch already conforms to standards."
97+
exit 0
98+
fi
99+
if [ -z "$NETCODE_GITHUB_TOKEN" ]; then
100+
echo "ERROR: NETCODE_GITHUB_TOKEN is not set; cannot push fixes." && exit 1
101+
fi
102+
if [ -z "$GIT_BRANCH" ]; then
103+
echo "ERROR: GIT_BRANCH is not set; run this job against a branch, not a detached revision." && exit 1
104+
fi
105+
git config user.name "netcode-automation"
106+
git config user.email "svc-netcode-sdk@unity3d.com"
107+
git add -A
108+
git commit -m "Apply netcode.standards formatting fixes"
109+
git remote set-url origin "https://x-access-token:${NETCODE_GITHUB_TOKEN}@github.com/Unity-Technologies/com.unity.netcode.gameobjects.git"
110+
git push origin "HEAD:${GIT_BRANCH}"
111+
{% endfor -%}
60112
{% endfor -%}

0 commit comments

Comments
 (0)