mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-08 08:22:19 +03:00
CI: store and reuse OpenSSH Server docker image used for tests
Supersedes #588 Fixes #665 Closes #685
This commit is contained in:
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -85,10 +85,8 @@ jobs:
|
|||||||
cd bin
|
cd bin
|
||||||
cmake $TOOLCHAIN_OPTION -DCRYPTO_BACKEND=$CRYPTO_BACKEND -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION ..
|
cmake $TOOLCHAIN_OPTION -DCRYPTO_BACKEND=$CRYPTO_BACKEND -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION ..
|
||||||
cmake --build .
|
cmake --build .
|
||||||
pushd ../tests
|
export OPENSSH_SERVER_IMAGE=ghcr.io/libssh2/ci_tests_openssh_server:$(git rev-parse --short=20 HEAD:../tests/openssh_server)
|
||||||
docker build -t libssh2/openssh_server openssh_server
|
ctest -VV --output-on-failure
|
||||||
popd
|
|
||||||
CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test
|
|
||||||
cmake --build . --target package
|
cmake --build . --target package
|
||||||
fuzzer:
|
fuzzer:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
66
.github/workflows/openssh_server.yml
vendored
Normal file
66
.github/workflows/openssh_server.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
# Copyright (c) 2022 Marc Hoersken
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
name: OpenSSH Server Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- shell: bash
|
||||||
|
id: hash
|
||||||
|
run: echo "::set-output name=hash::$(git rev-parse --short=20 HEAD:tests/openssh_server)"
|
||||||
|
|
||||||
|
- shell: bash
|
||||||
|
id: poll
|
||||||
|
run: docker manifest inspect ghcr.io/${{ github.repository_owner }}/ci_tests_openssh_server:${{ steps.hash.outputs.hash }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- uses: docker/metadata-action@v3
|
||||||
|
id: meta
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository_owner }}/ci_tests_openssh_server
|
||||||
|
tags: |
|
||||||
|
type=raw,value=${{ steps.hash.outputs.hash }}
|
||||||
|
if: ${{ steps.poll.outcome == 'failure' }}
|
||||||
|
|
||||||
|
- uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./tests/openssh_server
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
if: ${{ steps.poll.outcome == 'failure' }}
|
||||||
@@ -112,10 +112,9 @@ script:
|
|||||||
- |
|
- |
|
||||||
if [ "$B" = "cmake" ]; then
|
if [ "$B" = "cmake" ]; then
|
||||||
mkdir bin
|
mkdir bin
|
||||||
cd tests
|
cd bin
|
||||||
docker build -t libssh2/openssh_server openssh_server
|
export OPENSSH_SERVER_IMAGE=ghcr.io/libssh2/ci_tests_openssh_server:$(git rev-parse --short=20 HEAD:../tests/openssh_server)
|
||||||
cd ../bin
|
cmake $TOOLCHAIN_OPTION -DCRYPTO_BACKEND=$CRYPTO_BACKEND -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION .. && cmake --build . && ctest -VV --output-on-failure && cmake --build . --target package
|
||||||
cmake $TOOLCHAIN_OPTION -DCRYPTO_BACKEND=$CRYPTO_BACKEND -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION .. && cmake --build . && CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test && cmake --build . --target package
|
|
||||||
fi
|
fi
|
||||||
- |
|
- |
|
||||||
if [ "$B" = "fuzzer" ]; then
|
if [ "$B" = "fuzzer" ]; then
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ before_test:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- ps: cd _builds
|
- ps: $env:OPENSSH_SERVER_IMAGE=[string] (& bash -c "echo ghcr.io/libssh2/ci_tests_openssh_server:$(git rev-parse --short=20 HEAD:tests/openssh_server)")
|
||||||
- ps: ctest -VV -C $($env:CONFIGURATION) --output-on-failure
|
- ps: cd _builds; ctest -VV -C $($env:CONFIGURATION) --output-on-failure
|
||||||
|
|
||||||
on_failure:
|
on_failure:
|
||||||
- ps: if(Test-Path _builds/CMakeFiles/CMakeOutput.log) { cat _builds/CMakeFiles/CMakeOutput.log }
|
- ps: if(Test-Path _builds/CMakeFiles/CMakeOutput.log) { cat _builds/CMakeFiles/CMakeOutput.log }
|
||||||
|
|||||||
@@ -143,8 +143,26 @@ static int run_command(char **output, const char *command, ...)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *openssh_server_image(void)
|
||||||
|
{
|
||||||
|
return getenv("OPENSSH_SERVER_IMAGE");
|
||||||
|
}
|
||||||
|
|
||||||
static int build_openssh_server_docker_image(void)
|
static int build_openssh_server_docker_image(void)
|
||||||
{
|
{
|
||||||
|
const char *container_image_name = openssh_server_image();
|
||||||
|
if(container_image_name != NULL) {
|
||||||
|
int ret = run_command(NULL, "docker pull --quiet %s",
|
||||||
|
container_image_name);
|
||||||
|
if(ret == 0) {
|
||||||
|
ret = run_command(NULL, "docker tag %s libssh2/openssh_server",
|
||||||
|
container_image_name);
|
||||||
|
if(ret == 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return run_command(NULL, "docker build --quiet "
|
return run_command(NULL, "docker build --quiet "
|
||||||
"-t libssh2/openssh_server "
|
"-t libssh2/openssh_server "
|
||||||
"openssh_server");
|
"openssh_server");
|
||||||
@@ -164,11 +182,10 @@ static int start_openssh_server(char **container_id_out)
|
|||||||
"libssh2/openssh_server",
|
"libssh2/openssh_server",
|
||||||
container_host_port);
|
container_host_port);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return run_command(container_id_out,
|
return run_command(container_id_out,
|
||||||
"docker run --rm -d -p 22 "
|
"docker run --rm -d -p 22 "
|
||||||
"libssh2/openssh_server");
|
"libssh2/openssh_server");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stop_openssh_server(char *container_id)
|
static int stop_openssh_server(char *container_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user