1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-31 00:03:08 +03:00

ci: add MSVC and UWP builds to GitHub Actions

- add MSVC jobs to GitHub Actions. They are similar to the 'Build-only'
  jobs we have on AppVeyor CI, though only the ARM64 Windows one is
  identical. Major disadvantage is that we don't run tests here. Major
  advantage is they only take a few minutes to complete, compared to
  an hour on AppVeyor, so WinCNG build results now appear quicker.

  Docker tests might be possible, but my light attempts failed.
  Finding ZLIB also failed, so we still miss an MSVC test with it.

  Tool versions as of now: Server 2022, VS2022, OpenSSL 1.1.1

- add UWP builds for both ARM64 and x64. This hasn't been CI tested
  before.

  (We could probably enable UWP on AppVeyor CI as well.
  I haven't tried.)

- fix two uncovered UWP issues in tests.

- rename internal macro `LIBSSH2_WINDOWS_APP` to `LIBSSH2_WINDOWS_UWP`.

  Follow-up to 2addafb77b

- fold long lines and quote truthy values in `.github/workflows/ci.yml`.

Closes #1010
This commit is contained in:
Viktor Szakats
2023-04-26 21:43:45 +00:00
parent 23029a9d36
commit f4a4c05dc3
5 changed files with 67 additions and 20 deletions

View File

@ -26,18 +26,18 @@ jobs:
compiler: [gcc, clang]
address_size: [64]
crypto_backend: [OpenSSL, Libgcrypt, mbedTLS]
enable_zlib_compression: [OFF, ON]
enable_zlib_compression: ['OFF', 'ON']
b: [cmake]
include:
- compiler: gcc
address_size: 64
crypto_backend: OpenSSL
enable_zlib_compression: OFF
enable_zlib_compression: 'OFF'
b: configure
- compiler: clang
address_size: 64
crypto_backend: OpenSSL
enable_zlib_compression: OFF
enable_zlib_compression: 'OFF'
b: configure
env:
CC: ${{ matrix.compiler }}
@ -57,7 +57,9 @@ jobs:
MBEDTLSVER=mbedtls-3.4.0
curl -L https://github.com/Mbed-TLS/mbedtls/archive/$MBEDTLSVER.tar.gz | tar -xzf -
cd mbedtls-$MBEDTLSVER
cmake $TOOLCHAIN_OPTION -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DCMAKE_INSTALL_PREFIX:PATH=../usr .
cmake $TOOLCHAIN_OPTION \
-DUSE_SHARED_MBEDTLS_LIBRARY=ON \
-DCMAKE_INSTALL_PREFIX:PATH=../usr .
make -j3 install
cd ..
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/usr/lib" >> $GITHUB_ENV
@ -75,7 +77,11 @@ jobs:
run: |
mkdir bin
cd bin
cmake $TOOLCHAIN_OPTION -DENABLE_WERROR=ON -DCRYPTO_BACKEND=$CRYPTO_BACKEND -DBUILD_SHARED_LIBS=ON -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION ..
cmake $TOOLCHAIN_OPTION \
-DENABLE_WERROR=ON \
-DBUILD_SHARED_LIBS=ON \
-DCRYPTO_BACKEND=$CRYPTO_BACKEND \
-DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION ..
cmake --build .
export OPENSSH_SERVER_IMAGE=ghcr.io/libssh2/ci_tests_openssh_server:$(git rev-parse --short=20 HEAD:../tests/openssh_server)
ctest -VV --output-on-failure
@ -109,3 +115,44 @@ jobs:
./configure --enable-debug --enable-static --disable-shared --with-crypto=openssl
make -j3
make check VERBOSE=1
build_msvc:
name: msvc
runs-on: windows-latest
timeout-minutes: 30
strategy:
matrix:
include:
- { arch: x64 , plat: windows, crypto: WinCNG , log: 'OFF', shared: 'OFF', zlib: 'OFF' }
- { arch: x64 , plat: windows, crypto: WinCNG , log: 'ON' , shared: 'ON' , zlib: 'OFF' }
- { arch: x64 , plat: windows, crypto: OpenSSL, log: 'OFF', shared: 'ON' , zlib: 'OFF' }
- { arch: x64 , plat: uwp , crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' }
- { arch: arm64, plat: windows, crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' }
- { arch: arm64, plat: uwp , crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' }
- { arch: x86 , plat: windows, crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' }
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Configure with CMake
shell: bash
run: |
archgen=${{matrix.arch}}; [ "${archgen}" = 'x86' ] && archgen='Win32'
if [ "${{matrix.plat}}" = 'uwp' ]; then
system='WindowsStore'
options='-DCMAKE_SYSTEM_VERSION=10.0'
else
system='Windows'
fi
cmake . -B bld ${options} \
-DCMAKE_SYSTEM_NAME=${system} \
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DCMAKE_GENERATOR_PLATFORM=${archgen} \
-DVCPKG_TARGET_TRIPLET=${{matrix.arch}}-${{matrix.plat}} \
-DENABLE_WERROR=ON \
-DENABLE_DEBUG_LOGGING=${{matrix.log}} \
-DBUILD_SHARED_LIBS=${{matrix.shared}} \
-DCRYPTO_BACKEND=${{matrix.crypto}} \
-DENABLE_ZLIB_COMPRESSION=${{matrix.zlib}}
- name: Build with CMake
run: |
cmake --build bld --config Release --target package

View File

@ -251,7 +251,7 @@ static struct agent_ops agent_ops_unix = {
};
#endif /* PF_UNIX */
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP)
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP)
/* Code to talk to Pageant was taken from PuTTY.
*
* Portions copyright Robert de Bath, Joris van Rantwijk, Delian
@ -354,16 +354,16 @@ static struct agent_ops agent_ops_pageant = {
agent_transact_pageant,
agent_disconnect_pageant
};
#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) */
#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) */
static struct {
const char *name;
struct agent_ops *ops;
} supported_backends[] = {
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP)
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP)
{"Pageant", &agent_ops_pageant},
{"OpenSSH", &agent_ops_openssh},
#endif
#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) */
#ifdef PF_UNIX
{"Unix", &agent_ops_unix},
#endif /* PF_UNIX */

View File

@ -41,7 +41,7 @@
#include "agent.h"
#include <errno.h>
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP)
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP)
#include <stdlib.h> /* for getenv() */
@ -347,4 +347,4 @@ struct agent_ops agent_ops_openssh = {
agent_transact_openssh,
agent_disconnect_openssh
};
#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) */
#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_UWP) */

View File

@ -97,7 +97,7 @@
# include <winapifamily.h>
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
# define LIBSSH2_WINDOWS_APP
# define LIBSSH2_WINDOWS_UWP
# endif
# endif
#endif

View File

@ -61,6 +61,14 @@
#define LIBSSH2_SOCKET_MASK "%d"
#endif
#ifdef LIBSSH2_WINDOWS_UWP
#define popen(x, y) (NULL)
#define pclose(x) (-1)
#elif defined(WIN32)
#define popen _popen
#define pclose _pclose
#endif
static int have_docker = 0;
int openssh_fixture_have_docker(void)
@ -102,11 +110,7 @@ static int run_command_varg(char **output, const char *command, va_list args)
}
fprintf(stdout, "Command: %s\n", command_buf);
#ifdef WIN32
pipe = _popen(buf, "r");
#else
pipe = popen(buf, "r");
#endif
if(!pipe) {
fprintf(stderr, "Unable to execute command '%s'\n", command);
return -1;
@ -118,11 +122,7 @@ static int run_command_varg(char **output, const char *command, va_list args)
buf_len = strlen(buf);
}
#ifdef WIN32
ret = _pclose(pipe);
#else
ret = pclose(pipe);
#endif
if(ret) {
fprintf(stderr, "Error running command '%s' (exit %d): %s\n",
command, ret, buf);