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

chore: add DEB/RPM packages #264

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
99 changes: 99 additions & 0 deletions .github/scripts/cargo_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/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"

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

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

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

# 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

# Tests on debug
if [ "$DEBUG_OR_RELEASE" = "debug" ]; then
# shellcheck disable=SC2086
cargo test --target "$TARGET" $FEATURES --workspace -- --nocapture $SKIP_SERVICES_TESTS
fi

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
229 changes: 39 additions & 190 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,169 +9,53 @@ on:
type: string

jobs:
centos7-tests:
uses: ./.github/workflows/build_centos7.yml
secrets: inherit
with:
toolchain: ${{ inputs.toolchain }}
archive-name: centos7_tests
commands: |
set -ex
cd crate/cli
cargo build
cd ../server
cargo build
cd ../pkcs11/provider
cargo build
cd ../../..

# Check binaries
target/debug/ckms -h
target/debug/cosmian_kms_server -h

cargo test --workspace -- --nocapture
artifacts: |
target/debug/ckms
target/debug/cosmian_kms_server
target/debug/libckms_pkcs11.so

rhel9-tests:
rhel9:
uses: ./.github/workflows/build_rhel9.yml
secrets: inherit
with:
toolchain: ${{ inputs.toolchain }}
archive-name: rhel9_tests
commands: |
set -ex
cd crate/cli
cargo build
cd ../server
cargo build
cd ../pkcs11/provider
cargo build
cd ../../..

# Check binaries
target/debug/ckms -h
target/debug/cosmian_kms_server -h

cargo test --workspace -- --nocapture
artifacts: |
target/debug/ckms
target/debug/cosmian_kms_server
target/debug/libckms_pkcs11.so
archive-name: rhel9
target: x86_64-unknown-linux-gnu
debug_or_release: debug

fips-centos7-test:
uses: ./.github/workflows/build_centos7.yml
secrets: inherit
with:
toolchain: ${{ inputs.toolchain }}
archive-name: fips_centos7_tests
commands: |
set -ex
cd crate/cli
cargo build --features fips
cd ../server
cargo build --features fips
cd ../pkcs11/provider
cargo build
cd ../../..

# Check binaries
target/debug/ckms -h
target/debug/cosmian_kms_server -h

cargo test --workspace --features fips -- --nocapture
artifacts: |
/usr/local/openssl
target/debug/ckms
target/debug/cosmian_kms_server
target/debug/libckms_pkcs11.so

ubuntu-20-tests:
fips-ubuntu-20:
uses: ./.github/workflows/build_generic.yml
secrets: inherit
with:
toolchain: ${{ inputs.toolchain }}
distribution: ubuntu-20.04
archive-name: ubuntu_20_04_tests
commands: |
set -ex
cd crate/cli
cargo build
cd ../server
cargo build
cd ../pkcs11/provider
cargo build
cd ../../..

# Check binaries
target/debug/ckms -h
target/debug/cosmian_kms_server -h

cargo test --workspace -- --nocapture --skip test_mysql --skip test_pgsql --skip test_redis
archive-name: fips_ubuntu_20_04
target: x86_64-unknown-linux-gnu
debug_or_release: debug
features: fips
skip_services_tests: --skip test_mysql --skip test_pgsql --skip test_redis --skip google_cse
artifacts: |
target/debug/ckms
target/debug/cosmian_kms_server
target/debug/libckms_pkcs11.so

fips-ubuntu-20-tests:
uses: ./.github/workflows/build_generic.yml
secrets: inherit
with:
toolchain: ${{ inputs.toolchain }}
distribution: ubuntu-20.04
archive-name: fips_ubuntu_20_04_tests
commands: |
set -ex
cd crate/cli
cargo build --features fips
cd ../server
cargo build --features fips
cd ../pkcs11/provider
cargo build
cd ../../..
/usr/local/openssl

# Check binaries
target/debug/ckms -h
target/debug/cosmian_kms_server -h
ubuntu:
strategy:
fail-fast: false
matrix:
include:
- distribution: ubuntu-20.04
archive-name: ubuntu_20_04

cargo test --workspace --features fips -- --nocapture --skip test_mysql --skip test_pgsql --skip test_redis
artifacts: |
/usr/local/openssl
target/debug/ckms
target/debug/cosmian_kms_server
target/debug/libckms_pkcs11.so
- distribution: ubuntu-22.04
archive-name: ubuntu_22_04

ubuntu-22-tests:
- distribution: ubuntu-24.04
archive-name: ubuntu_24_04
uses: ./.github/workflows/build_generic.yml
secrets: inherit
with:
toolchain: ${{ inputs.toolchain }}
distribution: ubuntu-22.04
archive-name: ubuntu_22_04_tests
commands: |
set -ex
cd crate/cli
cargo build
ldd ../../target/debug/ckms | grep ssl && exit 1
cd ../server
cargo build
cd ../pkcs11/provider
cargo build
cd ../../..
distribution: ${{ matrix.distribution }}
archive-name: ${{ matrix.archive-name }}
target: x86_64-unknown-linux-gnu
debug_or_release: debug
skip_services_tests: --skip test_mysql --skip test_pgsql --skip test_redis --skip google_cse

# Check binaries
target/debug/ckms -h
target/debug/cosmian_kms_server -h

cargo test --workspace -- --nocapture --skip test_mysql --skip test_pgsql --skip test_redis
artifacts: |
target/debug/ckms
target/debug/cosmian_kms_server
target/debug/libckms_pkcs11.so

windows-tests:
windows:
uses: ./.github/workflows/build_windows.yml
with:
toolchain: ${{ inputs.toolchain }}
Expand Down Expand Up @@ -203,58 +87,23 @@ jobs:
target/x86_64-pc-windows-msvc/debug/cosmian_kms_server.exe
target/x86_64-pc-windows-msvc/debug/ckms_pkcs11.dll

mac-tests:
mac:
uses: ./.github/workflows/build_generic.yml
with:
toolchain: ${{ inputs.toolchain }}
distribution: macos-12
archive-name: macos_tests
commands: |
set -ex

rustup target add x86_64-apple-darwin
archive-name: macos
target: x86_64-apple-darwin
debug_or_release: debug
skip_services_tests: --skip test_mysql --skip test_pgsql --skip test_redis --skip google_cse

cd crate/cli
cargo build --target x86_64-apple-darwin
otool -L ../../target/x86_64-apple-darwin/debug/ckms | grep openssl && exit 1
cd ../pkcs11/provider
cargo build --target x86_64-apple-darwin
cd ../../server
cargo build --target x86_64-apple-darwin
cd ../..

# Check binaries
target/x86_64-apple-darwin/debug/ckms -h
target/x86_64-apple-darwin/debug/cosmian_kms_server -h
artifacts: |
target/x86_64-apple-darwin/debug/ckms
target/x86_64-apple-darwin/debug/cosmian_kms_server
target/x86_64-apple-darwin/debug/libckms_pkcs11.dylib

macos14-tests:
# MACOS ARM BUILD
macos14:
uses: ./.github/workflows/build_generic.yml
with:
toolchain: ${{ inputs.toolchain }}
distribution: macos-14
archive-name: macos14_tests
commands: |
set -ex

rustup target add aarch64-apple-darwin

cd crate/cli
cargo build --target aarch64-apple-darwin
otool -L ../../target/aarch64-apple-darwin/debug/ckms | grep openssl && exit 1
cd ../pkcs11/provider
cargo build --target aarch64-apple-darwin
cd ../../server
cargo build --target aarch64-apple-darwin
cd ../..

# Check binaries
target/aarch64-apple-darwin/debug/ckms -h
target/aarch64-apple-darwin/debug/cosmian_kms_server -h
artifacts: |
target/aarch64-apple-darwin/debug/ckms
target/aarch64-apple-darwin/debug/cosmian_kms_server
target/aarch64-apple-darwin/debug/libckms_pkcs11.dylib
archive-name: macos14
target: aarch64-apple-darwin
debug_or_release: debug
skip_services_tests: --skip test_mysql --skip test_pgsql --skip test_redis --skip google_cse
Loading
Loading