Skip to content

Commit

Permalink
chore: Merge branch 'release/4.17.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuthor committed Jul 5, 2024
2 parents 377efd4 + 10bc566 commit 7d68d43
Show file tree
Hide file tree
Showing 270 changed files with 8,350 additions and 3,261 deletions.
94 changes: 94 additions & 0 deletions .github/scripts/cargo_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

set -ex

# --- Declare the following variables for tests
# export TARGET=x86_64-unknown-linux-gnu
# export DEBUG_OR_RELEASE=debug
# export OPENSSL_DIR=~/Documents/openssl_builds/test_new_build
# export SKIP_SERVICES_TESTS="--skip test_mysql --skip test_pgsql --skip test_redis --skip google_cse"

ROOT_FOLDER=$(pwd)

if [ -z "$TARGET" ]; then
echo "Error: TARGET is not set."
exit 1
fi

if [ "$DEBUG_OR_RELEASE" = "release" ]; then
RELEASE="--release"
fi

if [ -n "$FEATURES" ]; then
FEATURES="--features $FEATURES"
fi

if [ -z "$FEATURES" ]; then
echo "Info: FEATURES is not set."
unset FEATURES
fi

if [ -z "$SKIP_SERVICES_TESTS" ]; then
echo "Info: SKIP_SERVICES_TESTS is not set."
unset SKIP_SERVICES_TESTS
fi

rustup target add "$TARGET"

echo "Building crate/pkcs11/provider"
cd crate/pkcs11/provider
# shellcheck disable=SC2086
cargo build --target $TARGET $RELEASE
cd "$ROOT_FOLDER"

if [ -z "$OPENSSL_DIR" ]; then
echo "Error: OPENSSL_DIR is not set."
exit 1
fi

crates=("crate/server" "crate/cli")
for crate in "${crates[@]}"; do
echo "Building $crate"
cd "$crate"
# shellcheck disable=SC2086
cargo build --target $TARGET $RELEASE $FEATURES
cd "$ROOT_FOLDER"
done

# Debug
# find .

./target/"$TARGET/$DEBUG_OR_RELEASE"/ckms -h
./target/"$TARGET/$DEBUG_OR_RELEASE"/cosmian_kms_server -h

if [ "$(uname)" = "Linux" ]; then
ldd target/"$TARGET/$DEBUG_OR_RELEASE"/ckms | grep ssl && exit 1
ldd target/"$TARGET/$DEBUG_OR_RELEASE"/cosmian_kms_server | grep ssl && exit 1
else
otool -L target/"$TARGET/$DEBUG_OR_RELEASE"/ckms | grep openssl && exit 1
otool -L target/"$TARGET/$DEBUG_OR_RELEASE"/cosmian_kms_server | grep openssl && exit 1
fi

find . -type d -name cosmian-kms -exec rm -rf \{\} \; -print || true
rm -f /tmp/*.json
export RUST_LOG="cosmian_kms_cli=debug,cosmian_kms_server=debug"
# shellcheck disable=SC2086
cargo test --target $TARGET $RELEASE $FEATURES --workspace -- --nocapture $SKIP_SERVICES_TESTS

rm -rf target/"$TARGET"/debian
rm -rf target/"$TARGET"/generate-rpm

if [ -f /etc/redhat-release ]; then
cd crate/cli && cargo build --target "$TARGET" --release && cd -
cd crate/server && cargo build --target "$TARGET" --release && cd -
cargo install cargo-generate-rpm --force
cd "$ROOT_FOLDER"
cargo generate-rpm --target "$TARGET" -p crate/cli
cargo generate-rpm --target "$TARGET" -p crate/server --metadata-overwrite=pkg/rpm/scriptlets.toml
elif [ -f /etc/lsb-release ]; then
cargo install cargo-deb --force
cargo deb --target "$TARGET" -p cosmian_kms_cli --variant fips
cargo deb --target "$TARGET" -p cosmian_kms_cli
cargo deb --target "$TARGET" -p cosmian_kms_server --variant fips
cargo deb --target "$TARGET" -p cosmian_kms_server
fi
50 changes: 50 additions & 0 deletions .github/scripts/windows_build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function Build-Project {
param (
[Parameter(Mandatory=$true)]
[ValidateSet("debug", "release")]
[string]$BuildType
)

# Add target
rustup target add x86_64-pc-windows-msvc

# Build `ckms`
cd crate/cli
if ($BuildType -eq "release") {
cargo build --release --target x86_64-pc-windows-msvc
} else {
cargo build --target x86_64-pc-windows-msvc
}

# Build pkcs11 provider
cd ../pkcs11/provider
if ($BuildType -eq "release") {
cargo build --release --target x86_64-pc-windows-msvc
} else {
cargo build --target x86_64-pc-windows-msvc
}
cd ../../..

# Set up environment for vcpkg
$env:VCPKG_INSTALLATION_ROOT
dir $env:VCPKG_INSTALLATION_ROOT
vcpkg install openssl[fips]

vcpkg integrate install
$env:VCPKGRS_DYNAMIC = 1
$env:OPENSSL_DIR = "$env:VCPKG_INSTALLATION_ROOT\packages\openssl_x64-windows"

# Build `server`
cd crate/server
if ($BuildType -eq "release") {
cargo build --release --target x86_64-pc-windows-msvc
cargo test --release --target x86_64-pc-windows-msvc -p cosmian_kms_server -- --nocapture --skip test_sql_cipher --skip test_sqlite --skip test_mysql --skip test_pgsql --skip test_redis --skip google_cse
} else {
cargo build --target x86_64-pc-windows-msvc
cargo test --target x86_64-pc-windows-msvc -p cosmian_kms_server -- --nocapture --skip test_sql_cipher --skip test_sqlite --skip test_mysql --skip test_pgsql --skip test_redis --skip google_cse
}
}

# Example usage:
# Build-Project -BuildType debug
# Build-Project -BuildType release
Loading

0 comments on commit 7d68d43

Please sign in to comment.