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

Use official Jenkins CI to build and test winp #116

Merged
merged 26 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
de9e390
Use consistent OutDir and set binary name as TargetName
VladRassokhin Oct 6, 2022
4bdf19d
Update build scripts
VladRassokhin Oct 6, 2022
aea5afd
tests: fix unit tests failing
pbo-linaro Apr 3, 2024
e8a4d3b
build: migrate to Visual Studio 2019
pbo-linaro Apr 3, 2024
870324d
doc: announce Visual Studio update
pbo-linaro Apr 25, 2024
fd7623e
build: integrate c++ build with maven
pbo-linaro Apr 25, 2024
0d3cec5
remove committed binaries
pbo-linaro Apr 25, 2024
9e5fc88
do not commit any binary again
pbo-linaro Apr 25, 2024
1d7c97d
ci: remove appveyor
pbo-linaro Apr 3, 2024
b741718
ci: run job on windows only, with full virtual machine
pbo-linaro Apr 25, 2024
dd5928c
Update DEVELOPER.md
basil Apr 26, 2024
bdd14e5
Update DEVELOPER.md
basil Apr 26, 2024
6f0ff79
Update Jenkinsfile
basil Apr 26, 2024
bf77f59
Maven build improvements
basil Apr 26, 2024
95a37b8
fix capitalization
basil Apr 26, 2024
a4bd1ea
fix build status link
basil Apr 26, 2024
c8eb980
Try shrinking the diff? If tests pass I will keep this commit
basil Apr 26, 2024
f0d4514
Removing assumptions out of paranoia (will revert this commit before …
basil Apr 26, 2024
3ecb413
Paranoia satisfied
basil Apr 26, 2024
723a4b3
Remove old build script
basil Apr 26, 2024
b8e56d2
Rename script to minimize diff
basil Apr 26, 2024
4aec6d3
Plumb through native configuration
basil Apr 26, 2024
c2ab56d
Improve readme
basil Apr 26, 2024
526ee24
Plumb native configuration to tests
basil Apr 26, 2024
94efbd2
fix readme
basil Apr 26, 2024
ca6f126
Back to release configuration by default, now that debug has been tested
basil Apr 26, 2024
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
29 changes: 15 additions & 14 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
WinP Developer info
---

## Prerequisites

In order to build the project, you need MSBuild 15.0, Microsoft Visual Studio 2019, and BuildTools v142.
Toolchains for x86 and x64 targets should also be installed.
Furthermore, Windows SDK 10.0.16299 should be installed.
The `JAVA_HOME` environment variable should point to your Java installation (>= 11).

## Building

In order to build and test the project, use the `build.cmd` script available in the repository.
In order to build the project, you need MSbuild 15.0 and Microsoft Visual Studio 2017 with Windows XP support and BuildTools v140.
To build and test the project, run `mvn clean verify`:

* `build.cmd cleanbuild` - Build and test the release version of the JAR file.
* `mvn clean verify` - Build and test the release version of the JAR file.
Code will not be signed automatically.
* `build.cmd cleanbuild Debug` - Build and test the Debug configuration of the library.
* `mvn clean verify -Dnative.configuration=Debug` - Build and test the Debug configuration of the library.
This version simplifies debugging of the native part of the library (see below).

## Testing

* Right now all tests are implemented in Java part of the library (JUnit Framework).
There is no fully native tests.
* All tests are being automatically invoked by `build.cmd`
* Tests run from Maven, and the selected 32/64-bit mode depends on the Java version,
* All tests are automatically invoked by `mvn clean verify`.
* Tests run from Maven, and the selected 32/64-bit mode depends on the Java version,
which can be passed to maven using the `JAVA_HOME` environment variable.
* Generally you need to run `build.cmd cleanbuild Debug` and `build.cmd cleanbuild Release` on 3 configurations
* 32-bit Windows, 32-bit Java
* 64-bit Windows, 64-bit Java
* 64-bit Windows, 32-bit Java (WoW64 mode)

Note that WinP behavior may differ depending on the Windows version, permissions, run mode (desktop/service), etc.
Ideally, tests should be executed on all target platforms.

## Continuous Integration

Project has a continuous integration flow being hosted by AppVeyor ([project page](https://ci.appveyor.com/project/oleg-nenashev/winp)).
This CI instance automates testing of Debug and Release configurations,
The project has a [CI pipeline](https://ci.jenkins.io/job/jenkinsci-libraries/job/winp)
that automates testing of the release configuration,
but it does not provide full coverage of possible system configurations.
See [the appveyor.yml file](./appveyor.yml) for more details.

## Debugging

### Debugging Java part

Java part of the library can be debugged independently or within a project using standard tools available in the Java Development Kit.

### Debugging Native part

In order to debug native parts of the library attach your debugger (e.g. from Microsoft Visual Studio UI) to the `java.exe` process.
Expand Down
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* easy Linux/Windows testing and produces incrementals. The only feature that relates to plugins is
* allowing one to test against multiple Jenkins versions.
*/
buildPlugin(useContainerAgent: true, configurations: [
[platform: 'linux', jdk: 21],
[platform: 'linux', jdk: 17],
buildPlugin(useContainerAgent: false, configurations: [
[platform: 'windows', jdk: 21],
[platform: 'windows', jdk: 17],
basil marked this conversation as resolved.
Show resolved Hide resolved
])

16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Windows process management library (WinP)

[![Build status](https://ci.appveyor.com/api/projects/status/0w6ivhpkt20d88md?svg=true)](https://ci.appveyor.com/project/oleg-nenashev/winp)
[![Build status](https://ci.jenkins.io/job/jenkinsci-libraries/job/winp/job/master/badge/icon)](https://ci.jenkins.io/job/jenkinsci-libraries/job/winp/job/master/)

This project develops a library that lets you control Windows processes better, beyond what's available in JDK.
This project develops a library that lets you control Windows processes better, beyond what's available in JDK.

Features summary:

Expand All @@ -28,7 +28,7 @@ Starting with 1.29, this library is published at:
## Java support

Starting with 1.29, this library requires Java 11 or newer.

WinP Library includes native libraries for all supported platforms, hence it can run on both 32bit and 64bit Java versions without any additional configuration.

## Platform support
Expand All @@ -37,22 +37,20 @@ The library supports _x86_ and _amd64_ architectures.
ARM architecture is not supported.
Please raise an issue to the library if you need ARM support && ready to provide proper test environment.

:exclamation: It is **not recommended** to use WinP with _32bit_ Java on a _64bit_ operating system.
In such case the library will be running in the WoW64 mode;
:exclamation: It is **not recommended** to use WinP with _32bit_ Java on a _64bit_ operating system.
In such case the library will be running in the WoW64 mode;
and it will be unable to properly work with 64bit processes in the system.
E.g. any process information query call (e.g. Environment variables retrieval) may fail if you run it against 64bit process.

## Supported Windows versions

The current version of WinP is known to work correctly on the following Windows versions:

* Windows XP SP2 and above
* Windows Server 2003 and above
* Windows 10 and above
* Windows Server 2019 and above
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW do you know if this is dropping support for Windows Server 2016? I am definitely OK with dropping support for Windows Server 2012, since its extended end date of October 2023 has already passed, but I wonder if there may be Jenkins users still using Windows Server 2016. Jenkins users might still be using Windows Server 2016 since although its mainstream end date was in January of 2022, its extended end date isn't until 2027. Keeping support for it would be ideal if it isn't prohibitively costly, but dropping support wouldn't be the end of the world — after all, we dropped support for CentOS 7 — but this would need to be communicated broadly to existing users (in the changelog and upgrade guide) and might be worth highlighting on the developer list in case others have a strong opinion about this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to go ahead with this PR, but I am still hoping for a response to this comment, after which we can update the Release Notes/Upgrade Guide if necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked for information about which windows version was officially supported with default sdk for VS 2019, and found only Windows 10 and Server 2019. After all, Microsoft is trying to kill previous versions and force people to migrate, so we should not expect more than this.

Regarding our dependencies and windows functions used, I think it's pretty safe to say that Server 2016 should keep supported, as we don't use any "recent" API function.

Finally, people staying on a previous version of Windows probably prefer to stay on a previous version of Jenkins as well (it's more "stable" you know), so I would not worry too much about this.


Other Windows product lines are not being actively tested though WinP may work there.

:exclamation: Minimal required Windows version is a subject to change in next releases of WinP.

## License

[MIT License][license]
Expand Down
55 changes: 0 additions & 55 deletions appveyor.yml

This file was deleted.

64 changes: 27 additions & 37 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
@echo off
setlocal
set PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\amd64
set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140

set VS2019=C:\Program Files (x86)\Microsoft Visual Studio\2019
set VS=

if exist "%VS2019%\Community\" set VS=%VS2019%\Community
if exist "%VS2019%\Enterprise\" set VS=%VS2019%\Enterprise
if "%VS%" == "" (
echo Can't find VS2019 install
exit /b 1
)

call "%VS%/VC/Auxiliary/Build/vcvarsall.bat" amd64 || exit /b 1
set BUIDROOT=%cd%

:getopts
Expand All @@ -11,39 +20,28 @@ if "%2"=="" (
set configuration=%2%
)

if "%3"=="" (
echo No target version specified, will determine it from POM
REM TODO: Apply some MADSKILLZ to do it without the temporary file?
call mvn -q -Dexec.executable="cmd.exe" -Dexec.args="/c echo ${project.version}" --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec > version.txt
for /f "delims=" %%x in (version.txt) do set version=%%x
) else (
echo Setting MVN project version to the externally defined %3%
set version=%3%
)
echo Target version is %version%

if "%1"=="" (goto :default) else (goto :%1)
goto :exit

:default
goto :cleanbuild
goto :build

:cleanbuild
:clean
echo ### Cleaning the %configuration% build directory
cd %BUIDROOT%\native
msbuild winp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32"
if %errorlevel% neq 0 exit /b %errorlevel%
msbuild winp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64"
if %errorlevel% neq 0 exit /b %errorlevel%
msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="Win32"
msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32"
if %errorlevel% neq 0 exit /b %errorlevel%
msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="x64"
msbuild sendctrlc\sendctrlc.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64"
if %errorlevel% neq 0 exit /b %errorlevel%
msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="Win32"
msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="Win32"
if %errorlevel% neq 0 exit /b %errorlevel%
msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=Release /verbosity:minimal /nologo /p:Platform="x64"
msbuild ..\native_test\testapp\testapp.vcxproj /t:Clean /p:Configuration=%configuration% /verbosity:minimal /nologo /p:Platform="x64"
if %errorlevel% neq 0 exit /b %errorlevel%
goto :build
goto :exit

:build
echo ### Building the %configuration% configuration
Expand All @@ -59,29 +57,21 @@ msbuild sendctrlc\sendctrlc.vcxproj /p:Configuration=%configuration% /nologo /p:
if %errorlevel% neq 0 exit /b %errorlevel%

echo ### Building test applications
msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=Release /nologo /p:Platform="Win32"
msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=%configuration% /nologo /p:Platform="Win32"
if %errorlevel% neq 0 exit /b %errorlevel%
msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=Release /nologo /p:Platform="x64"
msbuild ..\native_test\testapp\testapp.vcxproj /verbosity:minimal /p:Configuration=%configuration% /nologo /p:Platform="x64"
if %errorlevel% neq 0 exit /b %errorlevel%

echo ### Updating WinP resource files for the %configuration% build
echo ### Copying WinP resource files for the %configuration% build
cd %BUIDROOT%
COPY native\%configuration%\winp.dll src\main\resources\winp.dll
if %errorlevel% neq 0 exit /b %errorlevel%
COPY native\x64\%configuration%\winp.dll src\main\resources\winp.x64.dll
if %errorlevel% neq 0 exit /b %errorlevel%
COPY native\sendctrlc\Win32\%configuration%\sendctrlc.exe src\main\resources\sendctrlc.exe
if not exist target\classes mkdir target\classes
COPY native\Win32\%configuration%\winp.dll target\classes\
if %errorlevel% neq 0 exit /b %errorlevel%
COPY native\sendctrlc\x64\%configuration%\sendctrlc.exe src\main\resources\sendctrlc.x64.exe
COPY native\x64\%configuration%\winp.x64.dll target\classes\
if %errorlevel% neq 0 exit /b %errorlevel%

echo ### Build and Test winp.jar for %version%
cd %BUIDROOT%
call mvn -q --batch-mode versions:set -DnewVersion=%version%
COPY native\sendctrlc\Win32\%configuration%\sendctrlc.exe target\classes\
if %errorlevel% neq 0 exit /b %errorlevel%
call mvn --batch-mode clean package verify
if %errorlevel% neq 0 exit /b %errorlevel%
goto :exit
COPY native\sendctrlc\x64\%configuration%\sendctrlc.x64.exe target\classes\

:exit
endlocal
18 changes: 10 additions & 8 deletions native/sendctrlc/sendctrlc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand All @@ -69,19 +69,21 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<TargetName>sendctrlc.x64</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(MSBuildProjectDirectory)\$(Platform)\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<TargetName>sendctrlc.x64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
14 changes: 8 additions & 6 deletions native/winp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand All @@ -66,26 +66,28 @@
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include\;$(JAVA_HOME)\include\win32;</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>winp.x64</TargetName>
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include\;$(JAVA_HOME)\include\win32;</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include\;$(JAVA_HOME)\include\win32;</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>winp.x64</TargetName>
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include\;$(JAVA_HOME)\include\win32;</IncludePath>
</PropertyGroup>
Expand Down
Loading