mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Attempt to fix Python on Travis being too old. (#415)
* Attempt to fix Python on Travis being too old. * Fix RUN_THIS.py too. * Fix CI builds blocking. * Fix BuildChecker.csproj Python versioning in Travis.
This commit is contained in:
committed by
Silver
parent
07878ad7a7
commit
518a366c7e
@@ -15,7 +15,7 @@ install:
|
||||
- ps: if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { cinst msbuild-sonarqube-runner }
|
||||
|
||||
before_build:
|
||||
- cmd: py -3.5 RUN_THIS.py
|
||||
- cmd: py -3.5 RUN_THIS.py --no-prompt
|
||||
- cmd: py -3.5 Resources\buildResourcePack.py --resources-dir .\Resources --out .\Resources\ResourcePack.zip --atlas-tool .\Tools\AtlasTool.exe --no-animations --to-stderr
|
||||
- cmd: nuget restore SpaceStation14.sln
|
||||
- ps: if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER -And $env:APPVEYOR_REPO_BRANCH -Eq "master") { MSBuild.SonarQube.Runner.exe begin /k:"ss14" /d:"sonar.host.url=https://sonarqube.com" /d:"sonar.login=$env:sonarqubekey" /d:"sonar.organization=space-wizards" /d:"sonar.exclusions=SFML/**"}
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -81,3 +81,7 @@ NetSerializerDebug.dll
|
||||
Third-Party/extlibs/Mac/
|
||||
# Or the automatically-fetched Windows natives, for that matter.
|
||||
Third-Party/extlibs/Windows/
|
||||
|
||||
# Python stuff
|
||||
__pycache__
|
||||
.mypy_cache
|
||||
|
||||
14
.travis.yml
14
.travis.yml
@@ -7,16 +7,24 @@ os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- deadsnakes
|
||||
|
||||
packages:
|
||||
- python3.6
|
||||
|
||||
before_install:
|
||||
- if [ $TRAVIS_OS_NAME = osx ]; then brew update && brew install python3; fi
|
||||
|
||||
before_script:
|
||||
- "nuget restore SpaceStation14.sln"
|
||||
- "python3 RUN_THIS.py"
|
||||
- "python3.6 RUN_THIS.py --no-prompt"
|
||||
|
||||
script:
|
||||
- "python3 ./Resources/buildResourcePack.py --resources-dir ./Resources --out ./Resources/ResourcePack.zip --no-atlas --no-animations --to-stderr"
|
||||
- "msbuild /p:Configuration=Release /p:Platform=x86 /p:HEADLESS=1 /nologo /m /p:AllowMissingMacNatives=yes SpaceStation14.sln"
|
||||
- "python3.6 ./Resources/buildResourcePack.py --resources-dir ./Resources --out ./Resources/ResourcePack.zip --no-atlas --no-animations --to-stderr"
|
||||
- "msbuild /p:Configuration=Release /p:Platform=x86 /p:HEADLESS=1 /nologo /m /p:AllowMissingMacNatives=yes SpaceStation14.sln /p:Python=python3.6"
|
||||
- "cd packages/NUnit.ConsoleRunner.3.7.0/tools"
|
||||
- "mono --debug nunit3-console.exe ../../../bin/UnitTesting/SS14.UnitTesting.dll"
|
||||
|
||||
|
||||
@@ -13,9 +13,15 @@ If you want to learn more about these kinds of things, check out Microsoft's off
|
||||
https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild
|
||||
-->
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Choose>
|
||||
<When Condition="'$(Python)' == ''">
|
||||
<PropertyGroup>
|
||||
<Python>python3</Python>
|
||||
<Python Condition="'$(OS)'=='Windows_NT' Or '$(OS)'=='Windows'">py -3</Python>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<PropertyGroup>
|
||||
<Python>python3</Python>
|
||||
<Python Condition="'$(OS)'=='Windows_NT' Or '$(OS)'=='Windows'">py -3</Python>
|
||||
<ProjectGuid>{D0DA124B-5580-4345-A02B-9F051F78915F}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
|
||||
40
BuildChecker/git_helper.py
Normal file → Executable file
40
BuildChecker/git_helper.py
Normal file → Executable file
@@ -8,7 +8,9 @@ import shutil
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
SOLUTION_PATH = Path("..") / "SpaceStation14Content.sln"
|
||||
BUILD_CHECKER_PATH = Path(Path(__file__).resolve(strict=True).parent)
|
||||
SS14_ROOT_PATH = Path(BUILD_CHECKER_PATH.parent)
|
||||
SOLUTION_PATH = Path(SS14_ROOT_PATH/"SpaceStation14Content.sln")
|
||||
CURRENT_HOOKS_VERSION = "2" # If this doesn't match the saved version we overwrite them all.
|
||||
QUIET = "--quiet" in sys.argv
|
||||
NO_HOOKS = "--nohooks" in sys.argv
|
||||
@@ -26,12 +28,12 @@ def run_command(command: List[str], capture: bool = False) -> subprocess.Complet
|
||||
completed = None
|
||||
|
||||
if capture:
|
||||
completed = subprocess.run(command, cwd="..", stdout=subprocess.PIPE)
|
||||
completed = subprocess.run(command, cwd=str(SS14_ROOT_PATH), stdout=subprocess.PIPE)
|
||||
else:
|
||||
completed = subprocess.run(command, cwd="..")
|
||||
completed = subprocess.run(command, cwd=str(SS14_ROOT_PATH))
|
||||
|
||||
if completed.returncode != 0:
|
||||
print("Error: command exited with code {}!".format(completed.returncode))
|
||||
raise RuntimeError("Error: command exited with code {}!".format(completed.returncode))
|
||||
|
||||
return completed
|
||||
|
||||
@@ -41,15 +43,11 @@ def update_submodules():
|
||||
Updates all submodules.
|
||||
"""
|
||||
|
||||
# If the status doesn't match, force VS to reload the solution.
|
||||
# status = run_command(["git", "submodule", "status"], capture=True)
|
||||
run_command(["git", "submodule", "update", "--init", "--recursive"])
|
||||
# status2 = run_command(["git", "submodule", "status"], capture=True)
|
||||
status = run_command(["git", "submodule", "update", "--init", "--recursive"], capture=True)
|
||||
|
||||
# Something changed.
|
||||
# if status.stdout != status2.stdout:
|
||||
# print("Git submodules changed. Reloading solution.")
|
||||
# reset_solution()
|
||||
if status.stdout.decode().strip():
|
||||
print("Git submodules changed. Reloading solution.")
|
||||
reset_solution()
|
||||
|
||||
def install_hooks():
|
||||
"""
|
||||
@@ -57,20 +55,20 @@ def install_hooks():
|
||||
"""
|
||||
|
||||
# Read version file.
|
||||
if os.path.isfile("INSTALLED_HOOKS_VERSION"):
|
||||
with open("INSTALLED_HOOKS_VERSION", "r") as f:
|
||||
if os.path.isfile(BUILD_CHECKER_PATH/"INSTALLED_HOOKS_VERSION"):
|
||||
with open(BUILD_CHECKER_PATH/"INSTALLED_HOOKS_VERSION", "r") as f:
|
||||
if f.read() == CURRENT_HOOKS_VERSION:
|
||||
if not QUIET:
|
||||
print("No hooks change detected.")
|
||||
return
|
||||
|
||||
with open("INSTALLED_HOOKS_VERSION", "w") as f:
|
||||
with open(BUILD_CHECKER_PATH/"INSTALLED_HOOKS_VERSION", "w") as f:
|
||||
f.write(CURRENT_HOOKS_VERSION)
|
||||
|
||||
print("Hooks need updating.")
|
||||
|
||||
hooks_target_dir = Path("..")/".git"/"hooks"
|
||||
hooks_source_dir = Path("hooks")
|
||||
hooks_target_dir = SS14_ROOT_PATH/".git"/"hooks"
|
||||
hooks_source_dir = BUILD_CHECKER_PATH/"hooks"
|
||||
|
||||
if not os.path.exists(str(hooks_target_dir)):
|
||||
os.makedirs(str(hooks_target_dir))
|
||||
@@ -86,7 +84,8 @@ def install_hooks():
|
||||
|
||||
def reset_solution():
|
||||
"""
|
||||
Force VS to think the solution has been changed to prompt the user to reload it, thus fixing any load errors.
|
||||
Force VS to think the solution has been changed to prompt the user to reload it,
|
||||
thus fixing any load errors.
|
||||
"""
|
||||
|
||||
with SOLUTION_PATH.open("r") as f:
|
||||
@@ -95,7 +94,10 @@ def reset_solution():
|
||||
with SOLUTION_PATH.open("w") as f:
|
||||
f.write(content)
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
if not NO_HOOKS:
|
||||
install_hooks()
|
||||
update_submodules()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
43
RUN_THIS.py
43
RUN_THIS.py
@@ -2,17 +2,40 @@
|
||||
|
||||
# Import future so people on py2 still get the clear error that they need to upgrade.
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import traceback
|
||||
|
||||
IS_WINDOWS = sys.platform in ("win32", "cygwin")
|
||||
VERSION = sys.version_info
|
||||
NO_PROMPT = "--no-prompt" in sys.argv
|
||||
|
||||
version = sys.version_info
|
||||
if version.major < 3 or (version.major == 3 and version.minor < 5):
|
||||
print("ERROR: You need at least Python 3.5 to build SS14.")
|
||||
sys.exit(1)
|
||||
sane_input = raw_input if VERSION.major < 3 else input
|
||||
|
||||
if IS_WINDOWS:
|
||||
subprocess.run(["py", "-3", "git_helper.py"], cwd="BuildChecker", check=True)
|
||||
else:
|
||||
subprocess.run(["python3", "git_helper.py"], cwd="BuildChecker", check=True)
|
||||
def main():
|
||||
if VERSION.major < 3 or (VERSION.major == 3 and VERSION.minor < 5):
|
||||
print("ERROR: You need at least Python 3.5 to build SS14.")
|
||||
# Need "press enter to exit" stuff because Windows just immediately closes conhost.
|
||||
if not NO_PROMPT:
|
||||
sane_input("Press enter to exit...")
|
||||
exit(1)
|
||||
|
||||
# Import git_helper by modifying the path.
|
||||
ss14_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(os.path.join(ss14_dir, "BuildChecker"))
|
||||
|
||||
try:
|
||||
import git_helper
|
||||
git_helper.main()
|
||||
|
||||
except Exception as e:
|
||||
print("ERROR:")
|
||||
traceback.print_exc()
|
||||
print("This was NOT intentional. If the error is not immediately obvious, ask on Discord or IRC for help.")
|
||||
if not NO_PROMPT:
|
||||
sane_input("Press enter to exit...")
|
||||
exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
if not NO_PROMPT:
|
||||
sane_input("Success! Press enter to exit...")
|
||||
|
||||
Reference in New Issue
Block a user