Skip to content
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

[CI] Split build and tests script in AppVeyor #1372

Merged
46 changes: 46 additions & 0 deletions .NET/Build.CI.cmd
@@ -0,0 +1,46 @@
ECHO ==============================.NET BUILD START==============================

@ECHO off
SETLOCAL EnableDelayedExpansion

ECHO.
ECHO # Building .NET platform
REM vswhere is an optional component for Visual Studio and also installed with Build Tools.
REM vswhere will look for Community, Professional, and Enterprise editions of Visual Studio
REM (only works with Visual Studio 2017 Update 2 or newer installed)
SET vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"

for /f "usebackq tokens=*" %%i in (`!vswhere! -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set VSInstallDir=%%i
)

ECHO.
SET MsBuildVersion=15.0
ECHO # Finding MSBuild !MsBuildVersion!

if EXIST "%VSInstallDir%\MSBuild\!MsBuildVersion!\Bin\MSBuild.exe" (
SET MSBuild="%VSInstallDir%\MSBuild\15.0\Bin\MSBuild.exe" %*
ECHO Found MSBuild !MSBuild!
) else (
ECHO "msbuild.exe" could not be found at "!VSInstallDir!"
EXIT /B
)


ECHO.
ECHO # Restoring NuGet dependencies
CALL "buildtools\nuget" restore

set configuration=Release
ECHO.
ECHO # Generate resources
CALL "!MsBuildDir!\msbuild" Microsoft.Recognizers.Definitions.Common\Microsoft.Recognizers.Definitions.Common.csproj /t:Clean,Build /p:Configuration=%configuration%

ECHO # Building .NET solution (%configuration%)
CALL !MSBuild! Microsoft.Recognizers.Text.sln /t:Clean,Build /p:Configuration=%configuration%
IF %ERRORLEVEL% NEQ 0 (
ECHO # Failed to build .NET Project.
EXIT /b %ERRORLEVEL%
)

ECHO ============================== .NET BUILD END ==============================
75 changes: 2 additions & 73 deletions .NET/Build.cmd
@@ -1,76 +1,5 @@
@ECHO off
SETLOCAL EnableDelayedExpansion

ECHO.
ECHO # Building .NET platform
REM vswhere is an optional component for Visual Studio and also installed with Build Tools.
REM vswhere will look for Community, Professional, and Enterprise editions of Visual Studio
REM (only works with Visual Studio 2017 Update 2 or newer installed)
SET vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
REM This is only used for local build. It executes the same build and test scripts than the CI server.

for /f "usebackq tokens=*" %%i in (`!vswhere! -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set VSInstallDir=%%i
)

ECHO.
SET MsBuildVersion=15.0
ECHO # Finding MSBuild !MsBuildVersion!

if EXIST "%VSInstallDir%\MSBuild\!MsBuildVersion!\Bin\MSBuild.exe" (
SET MSBuild="%VSInstallDir%\MSBuild\15.0\Bin\MSBuild.exe" %*
ECHO Found MSBuild !MSBuild!
) else (
ECHO "msbuild.exe" could not be found at "!VSInstallDir!"
EXIT /B
)

ECHO.
ECHO # Finding VSTest
SET VSTestDir=%VSInstallDir%\Common7\IDE\CommonExtensions\Microsoft\TestWindow

IF NOT EXIST "%VSTestDir%\vstest.console.exe" (
ECHO "vstest.console.exe" could not be found at "%VSTestDir%"
EXIT /B
)

ECHO.
ECHO # Restoring NuGet dependencies
CALL "buildtools\nuget" restore

set configuration=Release
ECHO.
ECHO # Generate resources
CALL "!MsBuildDir!\msbuild" Microsoft.Recognizers.Definitions.Common\Microsoft.Recognizers.Definitions.Common.csproj /t:Clean,Build /p:Configuration=%configuration%

ECHO # Building .NET solution (%configuration%)
CALL !MSBuild! Microsoft.Recognizers.Text.sln /t:Clean,Build /p:Configuration=%configuration%
IF %ERRORLEVEL% NEQ 0 (
ECHO # Failed to build.
EXIT /b %ERRORLEVEL%
)

ECHO.
ECHO # Running .NET Tests
SET testcontainer=
FOR /R %%f IN (*Tests.dll) DO (
(ECHO "%%f" | FIND /V "\bin\%configuration%" 1>NUL) || (
SET testcontainer=!testcontainer! "%%f"
)
)
ECHO "!VsTestDir!\vstest.console"
CALL "!VsTestDir!\vstest.console" /Parallel %testcontainer%
IF %ERRORLEVEL% NEQ 0 GOTO TEST_ERROR

ECHO.
ECHO # Running CreateAllPackages.cmd
CALL CreateAllPackages.cmd
IF %ERRORLEVEL% NEQ 0 (
ECHO # Failed to create packages.
EXIT /b -1
)

EXIT /b 0

:TEST_ERROR
ECHO Test failure(s) found!
EXIT /b 1
build.ci.cmd & tests.ci.cmd
48 changes: 48 additions & 0 deletions .NET/tests.ci.cmd
@@ -0,0 +1,48 @@
ECHO ==============================.NET TESTS START==============================

@ECHO off
SETLOCAL EnableDelayedExpansion

SET vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"

for /f "usebackq tokens=*" %%i in (`!vswhere! -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set VSInstallDir=%%i
)

set configuration=Release

ECHO.
ECHO # Finding VSTest
SET VSTestDir=%VSInstallDir%\Common7\IDE\CommonExtensions\Microsoft\TestWindow

IF NOT EXIST "%VSTestDir%\vstest.console.exe" (
ECHO "vstest.console.exe" could not be found at "%VSTestDir%"
EXIT /B
)

ECHO # Running .NET Tests
SET testcontainer=
FOR /R %%f IN (*Tests.dll) DO (
(ECHO "%%f" | FIND /V "\bin\%configuration%" 1>NUL) || (
SET testcontainer=!testcontainer! "%%f"
)
)
ECHO "!VsTestDir!\vstest.console"
CALL "!VsTestDir!\vstest.console" /Parallel %testcontainer%
IF %ERRORLEVEL% NEQ 0 GOTO TEST_ERROR

ECHO.
ECHO # Running CreateAllPackages.cmd
CALL CreateAllPackages.cmd
IF %ERRORLEVEL% NEQ 0 (
ECHO # Failed to create packages.
EXIT /b -1
)

EXIT /b 0

:TEST_ERROR
ECHO .NET Test failure(s) found!
EXIT /b 1

ECHO ============================== .NET TESTS END ==============================
26 changes: 26 additions & 0 deletions Java/build.ci.cmd
@@ -0,0 +1,26 @@
ECHO ==============================JAVA BUILD START==============================

@ECHO off

ECHO # Java environment info
CALL mvn -v

ECHO # Clean resources
DEL /S /Q libraries\recognizers-text-number\src\main\java\com\microsoft\recognizers\text\number\resources\*.java
DEL /S /Q libraries\recognizers-text-number-with-unit\src\main\java\com\microsoft\recognizers\text\numberwithunit\resources\*.java
DEL /S /Q libraries\recognizers-text-date-time\src\main\java\com\microsoft\recognizers\text\datetime\resources\*.java
DEL /S /Q libraries\recognizers-text-choice\src\main\java\com\microsoft\recognizers\text\choice\resources\*.java

ECHO # Generate resources
CALL set MAVEN_OPTS=-Dfile.encoding=utf-8
CALL mvn compile exec:java -pl libraries/resource-generator/

ECHO # Building Java platform
CALL mvn clean package --batch-mode -Dmaven.test.skip=true

IF %ERRORLEVEL% NEQ 0 (
ECHO # Failed to build Java Project.
EXIT /b %ERRORLEVEL%
)

ECHO ============================== JAVA BUILD END ==============================
16 changes: 2 additions & 14 deletions Java/build.cmd
@@ -1,17 +1,5 @@
@ECHO off

ECHO # Java environment info
CALL mvn -v
REM This is only used for local build. It executes the same build and test scripts than the CI server.

ECHO # Clean resources
DEL /S /Q libraries\recognizers-text-number\src\main\java\com\microsoft\recognizers\text\number\resources\*.java
DEL /S /Q libraries\recognizers-text-number-with-unit\src\main\java\com\microsoft\recognizers\text\numberwithunit\resources\*.java
DEL /S /Q libraries\recognizers-text-date-time\src\main\java\com\microsoft\recognizers\text\datetime\resources\*.java
DEL /S /Q libraries\recognizers-text-choice\src\main\java\com\microsoft\recognizers\text\choice\resources\*.java

ECHO # Generate resources
CALL set MAVEN_OPTS=-Dfile.encoding=utf-8
CALL mvn compile exec:java -pl libraries/resource-generator/

ECHO # Building Java platform
CALL mvn package
build.ci.cmd & tests.ci.cmd
5 changes: 5 additions & 0 deletions Java/tests.ci.cmd
@@ -0,0 +1,5 @@
ECHO ==============================JAVA TESTS START==============================

mvn clean install --batch-mode

ECHO ============================== JAVA TESTS END ==============================
33 changes: 33 additions & 0 deletions JavaScript/build.ci.cmd
@@ -0,0 +1,33 @@
ECHO ==============================JAVASCRIPT BUILD START==============================

ECHO.
ECHO # Building Javascript platform

REM Check Node/NPM installation
WHERE /q node
IF ERRORLEVEL 1 (
ECHO Node.js executable not found. Please install it from https://nodejs.org/
EXIT /B
)
WHERE /q npm
IF ERRORLEVEL 1 (
ECHO NPM executable not found. Please install it from https://nodejs.org/
EXIT /B
)

REM Dependencies
ECHO.
ECHO # Installing dependencies
CALL npm i

REM Build Packages
ECHO.
ECHO # Building - npm run build
CALL npm run build

IF %ERRORLEVEL% NEQ 0 (
ECHO # Failed to build JavaScript Project.
EXIT /b %ERRORLEVEL%
)

ECHO ============================== JAVASCRIPT BUILD END ==============================
30 changes: 2 additions & 28 deletions JavaScript/build.cmd
@@ -1,31 +1,5 @@
@ECHO off

ECHO.
ECHO # Building Javascript platform
REM This is only used for local build. It executes the same build and test scripts than the CI server.

REM Check Node/NPM installation
WHERE /q node
IF ERRORLEVEL 1 (
ECHO Node.js executable not found. Please install it from https://nodejs.org/
EXIT /B
)
WHERE /q npm
IF ERRORLEVEL 1 (
ECHO NPM executable not found. Please install it from https://nodejs.org/
EXIT /B
)

REM Dependencies
ECHO.
ECHO # Installing dependencies
CALL npm i

REM Build Packages
ECHO.
ECHO # Building - npm run build
CALL npm run build

REM Tests
ECHO.
ECHO # Running tests - npm run test
CALL npm run test
build.ci.cmd & tests.ci.cmd
5 changes: 5 additions & 0 deletions JavaScript/tests.ci.cmd
@@ -0,0 +1,5 @@
ECHO ==============================JAVASCRIPT TESTS START==============================

npm run test

ECHO ============================== JAVASCRIPT TESTS END ==============================
46 changes: 46 additions & 0 deletions Python/build.ci.cmd
@@ -0,0 +1,46 @@
ECHO ==============================PYTHON BUILD/TEST START==============================

pushd libraries\resource-generator

REM Dependencies
ECHO.
ECHO # Installing Resource Generator Dependencies
CALL pip install -r .\requirements.txt

REM Build Resources
ECHO.
ECHO # Building Resources
CALL python index.py ..\recognizers-number\resource-definitions.json
CALL python index.py ..\recognizers-number-with-unit\resource-definitions.json
CALL python index.py ..\recognizers-date-time\resource-definitions.json
CALL python index.py ..\recognizers-sequence\resource-definitions.json

popd

pip install -e .\libraries\recognizers-text\

pip install -e .\libraries\recognizers-number\

pip install -e .\libraries\recognizers-number-with-unit\

pip install -e .\libraries\recognizers-date-time\

pip install -e .\libraries\recognizers-sequence\

pip install -e .\libraries\recognizers-suite\

pip install -r .\tests\requirements.txt

pytest --tb=line

IF %ERRORLEVEL% == 1 (
ECHO Python Test failure/s found!
EXIT /b %ERRORLEVEL%
) ELSE (
IF %ERRORLEVEL% NEQ 0 (
ECHO # Failed to build Python Project.
EXIT /b %ERRORLEVEL%
)
)

ECHO ============================== PYTHON BUILD/TEST END ==============================