Skip to content

ci: [Backport] Introduced vetting test on PRs and corrected package version to match "current state of the package" #3550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .yamato/_run-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ run_quick_checks:
dependencies:
- .yamato/package-pack.yml#package_pack_-_ngo_ubuntu
- .yamato/project-standards.yml#standards_ubuntu_testproject_trunk
# Run API validation to early-detect all new APIs that would force us to release new minor version of the package. Note that for this to work the package version in package.json must correspond to "actual package state" which means that it should be higher than last released version
- .yamato/vetting-test.yml#vetting_test

# Runs all package tests
run_all_package_tests:
Expand Down
2 changes: 2 additions & 0 deletions .yamato/_triggers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ develop_nightly:
# Build player for webgl platform on trunk and 2021 editors
- .yamato/project-updated-dependencies-test.yml#updated-dependencies_testproject_NGO_ubuntu_trunk
- .yamato/project-updated-dependencies-test.yml#updated-dependencies_testproject_NGO_win_2021.3
# Run API validation to early-detect all new APIs that would force us to release new minor version of the package. Note that for this to work the package version in package.json must correspond to "actual package state" which means that it should be higher than last released version
- .yamato/vetting-test.yml#vetting_test


# Run all tests on weekly bases
Expand Down
1 change: 1 addition & 0 deletions .yamato/package-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ package_pack_-_ngo_{{ platform.name }}:
variables:
XRAY_PROFILE: "supported ./pvpExceptions.json"
commands:
- python Tools/scripts/release.py # Needed to ensure that CHANGELOG is properly formatted for this test due to the fact that we have bumped package version (to properly perform vetting tests)
- upm-pvp pack "com.unity.netcode.gameobjects" --output upm-ci~/packages
- upm-pvp xray --packages "upm-ci~/packages/com.unity.netcode.gameobjects*.tgz" --results pvp-results
- upm-pvp require {% if platform.name == "win" %}"%XRAY_PROFILE%"{% else %}"$XRAY_PROFILE"{% endif %} --results pvp-results --allow-missing
Expand Down
5 changes: 3 additions & 2 deletions .yamato/project.metafile
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ validation_editors:
- 6000.1
- 6000.2
- trunk


minimal:
- 2021.3

# Scripting backends used by Standalone RunTimeTests---------------------------------------------------

scripting_backends:
Expand Down
25 changes: 25 additions & 0 deletions .yamato/vetting-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% 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 configuration defines vetting tests for the Tools package which allows to validate if the package is in releasable state. This is important in particular because of API validation that allows to detect if we are introducing any new APIs that will force us to bump package version to new minor
# If this test fails with new API error we should either make those API internal OR bump package version to new minor (note that the package version reflects the current package state)

# Note that we are packing the package only (no project context) so if package have any soft dependencies then project should be used to test it (to enable those APIs)
{% for editor in validation_editors.minimal -%}
vetting_test:
name: MP Tools - Vetting Test (Win, {{editor}} LTS)
agent: { type: Unity::VM, flavor: b1.large, image: package-ci/win11:v4 }
commands:
- python Tools/scripts/release.py # Needed to ensure that CHANGELOG is properly formatted for this test
- npm install -g "upm-ci-utils@stable" --registry https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-npm
- unity-downloader-cli --fast --wait --unity-version {{ editor }} --components editor --arch x64
- upm-ci package pack --package-path com.unity.netcode.gameobjects
- upm-ci package test -u .Editor --package-path com.unity.netcode.gameobjects --type vetting-tests
artifacts:
logs:
paths:
- pvp-results/*
- test-results/**
- upm-ci~/test-results/**
- upm-ci~/upm-ci.log
{% endfor -%}
78 changes: 78 additions & 0 deletions Tools/scripts/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""
NGO release script
- Update changelogs + validation exception file based on manifest version
"""
#!/usr/bin/env python3
import datetime
import json
import os
import re

package_name = 'com.unity.netcode.gameobjects'

def update_changelog(new_version):
changelog_entry = f'## [{new_version}] - {datetime.date.today().isoformat()}'
changelog_path = f'{package_name}/CHANGELOG.md'
print(changelog_entry)

if not os.path.exists(changelog_path):
print(f"Error: CHANGELOG.md file not found at {changelog_path}")
return

with open(changelog_path, 'rb') as f:
changelog_text = f.read()

changelog_text_decoded = changelog_text.decode("utf-8")
if '## [Unreleased]' in changelog_text_decoded:
# Replace the `Unreleased` section with the new version entry
print("Found `## [Unreleased]` section. Updating it.")
changelog_text = re.sub(br'## \[Unreleased\]', bytes(changelog_entry, 'UTF-8'), changelog_text)
else:
# `Unreleased` section does not exist, so prepend the new entry at the top
print("No `## [Unreleased]` section found. Prepending the new entry.")
changelog_text = bytes(f"{changelog_entry}\n\n", 'UTF-8') + changelog_text

with open(changelog_path, 'wb') as f:
f.write(changelog_text)

def update_validation_exceptions(new_version):
validation_file = f'{package_name}/ValidationExceptions.json'
if not os.path.exists(validation_file):
return

with open(validation_file, 'rb') as f:
json_text = f.read()
data = json.loads(json_text)
updated = False
for exceptionElements in ["WarningExceptions", "ErrorExceptions"]:
exceptions = data.get(exceptionElements)

if exceptions is not None:
for exception in exceptions:
if 'PackageVersion' in exception:
exception['PackageVersion'] = new_version
updated = True

if not updated:
return

with open(validation_file, "w", encoding="UTF-8") as json_file:
json.dump(data, json_file, ensure_ascii=False, indent=2)
json_file.write("\n") # Add newline cause Py JSON does not
print(f" updated `{validation_file}`")


def get_manifest_json_version(filename):
with open(filename, 'rb') as f:
json_text = f.read()
data = json.loads(json_text)

return data['version']

if __name__ == '__main__':
print(f"Current working directory: {os.getcwd()}")
manifest_path = f'{package_name}/package.json'
version = get_manifest_json_version(manifest_path)
update_validation_exceptions(version)

update_changelog(version)
2 changes: 1 addition & 1 deletion com.unity.netcode.gameobjects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.unity.netcode.gameobjects",
"displayName": "Netcode for GameObjects",
"description": "Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.",
"version": "1.13.0",
"version": "1.14.0",
"unity": "2021.3",
"dependencies": {
"com.unity.nuget.mono-cecil": "1.10.1",
Expand Down