-
Notifications
You must be signed in to change notification settings - Fork 461
Expand file tree
/
Copy pathproject-standards.yml
More file actions
55 lines (48 loc) · 3.93 KB
/
project-standards.yml
File metadata and controls
55 lines (48 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{% metadata_file .yamato/project.metafile %} # All configuration that is used to create different configurations (used in for loops) is taken from this file.
---
# DESCRIPTION--------------------------------------------------------------------------
# This job is responsible for validating project compliance with NGO coding standards and conventions
# Standards validation includes:
# Code formatting compliance
# Project structure validation
# Coding convention adherence
# Solution file synchronization
# CONFIGURATION STRUCTURE--------------------------------------------------------------
# Jobs configurations are generated using nested loops through:
# 1. For all NGO projects (testproject, testproject-tools-interation, minimalproject)
# 2. For default platform only (Ubuntu) since standards would not vary between platforms (no need for checks on more platforms)
# 3. For default editor version (trunk) since standards would not vary between editors (no need for checks on more editors)
# TECHNICAL CONSTRAINTS---------------------------------------------------------------
# Requires .NET SDK installed (should be preinstalled on the image so we just check for version)
# Needs Unity Editor for solution synchronization
# Uses custom standards validation tool (netcode.standards)
# Generates no test artifacts (pass/fail only). Eventual failure will be visible in the logs
# QUALITY THOUGHTS--------------------------------------------------------------------
# While testproject validation would be sufficient, since it validates both project and package (where package is our main concern) jobs for all projects are being generated to ensure that we conform to quality standards in all projects.
# TODO: consider modifying the approach and adding checks for minimal supported editor. In case of NGOv1.X it has proven to yield different results (But since NGOv2.X support starts from 6000.0 editor it's not that time pressuring)
# To see where this job is included (in trigger job definitions) look into _triggers.yml file
#------------------------------------------------------------------------------------
{% for project in projects.all -%}
{% for platform in test_platforms.default -%}
{% for editor in validation_editors.default -%}
standards_{{ platform.name }}_{{ project.name }}_{{ editor }}:
name: Standards Check - NGO {{ project.name }} [{{ platform.name }}, {{ editor }}]
agent:
type: {{ platform.type }}
image: {{ platform.image }}
flavor: {{ platform.flavor }}
{% if platform.model %}
model: {{ platform.model }} # This is set only in platforms where we want non-default model to use (more information in project.metafile)
{% endif %}
commands:
# .NET environment setup. Ensures required .NET SDK and formatting tools are available
- dotnet --version
- dotnet format --version
- unity-downloader-cli --fast --wait -u {{ editor }} -c editor {% if platform.name == "mac" %} --arch arm64 {% endif %} # For macOS we use ARM64 models. Downloads basic editor
- .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
- dotnet run --project=dotnet-tools/netcode.standards -- --project={{ project.path }} --fix # Auto-fix formatting issues
- 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)
- '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
{% endfor -%}
{% endfor -%}
{% endfor -%}