Skip to content

Commit 771673d

Browse files
committed
build: adopt Nix for reproducible builds
1 parent 78c0f8a commit 771673d

File tree

90 files changed

+8129
-869
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+8129
-869
lines changed

.github/copilot-instructions.md

Lines changed: 138 additions & 147 deletions
Large diffs are not rendered by default.

.github/scripts/README.md

Lines changed: 324 additions & 0 deletions
Large diffs are not rendered by default.

.github/scripts/benchmarks.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
set -x
4+
5+
# SQLite tests - always available, runs on filesystem
6+
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
7+
source "$SCRIPT_DIR/common.sh"
8+
9+
init_build_env "$@"
10+
setup_test_logging
11+
setup_fips_openssl_env
12+
13+
# Ensure required tools are available when running outside Nix
14+
require_cmd cargo "Cargo is required to build and run tests. Install Rust (rustup) and retry."
15+
16+
echo "========================================="
17+
echo "Benchmarks tests"
18+
echo "========================================="
19+
20+
echo "Building benchmarks..."
21+
cargo bench "${FEATURES_FLAG[@]}" --no-run
22+
23+
echo "Benchmarks completed successfully."

.github/scripts/build_packages.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/scripts/build_ui.sh

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,30 @@
99
# Exit on error, print commands
1010
set -ex
1111

12-
if [ -n "$FEATURES" ]; then
13-
CARGO_FEATURES="--features $FEATURES"
12+
# Args: --variant fips|non-fips (default: fips)
13+
VARIANT="fips"
14+
while [ $# -gt 0 ]; do
15+
case "$1" in
16+
-v | --variant)
17+
VARIANT="${2:-}"
18+
shift 2 || true
19+
;;
20+
*) shift ;; # ignore
21+
esac
22+
done
23+
24+
case "$VARIANT" in
25+
fips | non-fips) : ;;
26+
*)
27+
echo "Error: --variant must be 'fips' or 'non-fips'" >&2
28+
exit 1
29+
;;
30+
esac
31+
32+
if [ "$VARIANT" = "non-fips" ]; then
33+
CARGO_FEATURES=(--features non-fips)
34+
else
35+
CARGO_FEATURES=()
1436
fi
1537

1638
# Install nodejs from nodesource if npm is not installed
@@ -37,7 +59,7 @@ cargo install wasm-pack
3759
# Build WASM component
3860
cd crate/wasm
3961
# shellcheck disable=SC2086
40-
wasm-pack build --target web --release $CARGO_FEATURES
62+
wasm-pack build --target web --release "${CARGO_FEATURES[@]}"
4163

4264
# Copy WASM artifacts to UI directory
4365
WASM_DIR="../../ui/src/wasm/"
@@ -56,7 +78,10 @@ npm audit
5678
# Deploy built UI to root
5779
cd .. # current path: ./
5880

59-
DEST_DIR="crate/server/ui${CARGO_FEATURES:+_non_fips}"
81+
DEST_DIR="crate/server/ui"
82+
if [ "$VARIANT" = "non-fips" ]; then
83+
DEST_DIR="crate/server/ui_non_fips"
84+
fi
6085
rm -rf "$DEST_DIR"
6186
mkdir -p "$DEST_DIR"
6287
cp -R ui/dist "$DEST_DIR"

.github/scripts/build_ui_all.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# Exit on error, print commands
1010
set -ex
1111

12-
bash ./.github/scripts/build_ui.sh
12+
bash ./.github/scripts/build_ui.sh --variant fips
1313
git add crate/server/ui
1414

15-
FEATURES=non-fips bash ./.github/scripts/build_ui.sh
15+
bash ./.github/scripts/build_ui.sh --variant non-fips
1616
git add crate/server/ui_non_fips

.github/scripts/cargo_build.ps1

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ function BuildProject
1010
[string]$BuildType
1111
)
1212

13-
$env:RUST_LOG = "cosmian_kms_cli=error,cosmian_kms_server=error,cosmian_kmip=error,test_kms_server=error"
1413
# Add target
1514
rustup target add x86_64-pc-windows-msvc
1615

@@ -44,24 +43,7 @@ function BuildProject
4443
exit 1
4544
}
4645

47-
if ($BuildType -eq "release")
48-
{
49-
cargo test --lib --workspace --release --features "non-fips" -- --nocapture
50-
if ($LASTEXITCODE -ne 0)
51-
{
52-
Write-Error "Release tests failed with exit code $LASTEXITCODE"
53-
exit $LASTEXITCODE
54-
}
55-
}
56-
else
57-
{
58-
cargo test --lib --workspace --features "non-fips" -- --nocapture
59-
if ($LASTEXITCODE -ne 0)
60-
{
61-
Write-Error "Debug tests failed with exit code $LASTEXITCODE"
62-
exit $LASTEXITCODE
63-
}
64-
}
46+
exit 0
6547
}
6648

6749

.github/scripts/cargo_build.sh

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/scripts/cargo_test.ps1

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
$ErrorActionPreference = "Stop"
2+
Set-StrictMode -Version Latest
3+
$PSNativeCommandUseErrorActionPreference = $true # might be true by default
4+
5+
function TestProject
6+
{
7+
param (
8+
[Parameter(Mandatory = $true)]
9+
[ValidateSet("debug", "release")]
10+
[string]$BuildType
11+
)
12+
13+
$env:RUST_LOG = "cosmian_kms_cli=error,cosmian_kms_server=error,cosmian_kmip=error,test_kms_server=error"
14+
# Add target
15+
rustup target add x86_64-pc-windows-msvc
16+
17+
$env:OPENSSL_DIR = "$env:VCPKG_INSTALLATION_ROOT\packages\openssl_x64-windows-static"
18+
Get-ChildItem -Recurse $env:OPENSSL_DIR
19+
20+
if ($BuildType -eq "release")
21+
{
22+
cargo test --lib --workspace --release --features "non-fips" -- --nocapture
23+
if ($LASTEXITCODE -ne 0)
24+
{
25+
Write-Error "Release tests failed with exit code $LASTEXITCODE"
26+
exit $LASTEXITCODE
27+
}
28+
}
29+
else
30+
{
31+
cargo test --lib --workspace --features "non-fips" -- --nocapture
32+
if ($LASTEXITCODE -ne 0)
33+
{
34+
Write-Error "Debug tests failed with exit code $LASTEXITCODE"
35+
exit $LASTEXITCODE
36+
}
37+
}
38+
}
39+
40+
41+
# Example usage:
42+
# TestProject -BuildType debug
43+
# TestProject -BuildType release

0 commit comments

Comments
 (0)