-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Saffron CI | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
run: | ||
name: Run saffron e2e tests | ||
|
||
runs-on: ["ubuntu-latest"] | ||
|
||
strategy: | ||
matrix: | ||
rust_toolchain_version: ["1.74"] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Use shared Rust toolchain setting up steps | ||
uses: ./.github/actions/toolchain-shared | ||
with: | ||
rust_toolchain_version: ${{ matrix.rust_toolchain_version }} | ||
|
||
- name: Apply the Rust smart cacheing | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build the saffron cli binary | ||
run: | | ||
cargo build --release --bin saffron | ||
- name: Run the saffron e2e encoding tests | ||
run: | | ||
./saffron/test-encoding.sh saffron/fixtures/lorem.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
proptest-regressions | ||
fixtures/lorem.bin | ||
fixtures/lorem-decoded.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Run encode and decode | ||
cargo run --bin saffron encode -i fixtures/lorem.txt -o fixtures/lorem.bin | ||
cargo run --bin saffron decode -i fixtures/lorem.bin -o fixtures/lorem-decoded.txt | ||
# Check if input file is provided | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <input_file>" | ||
exit 1 | ||
fi | ||
|
||
INPUT_FILE="$1" | ||
ENCODED_FILE="${INPUT_FILE%.*}.bin" | ||
DECODED_FILE="${INPUT_FILE%.*}-decoded${INPUT_FILE##*.}" | ||
|
||
# Ensure input file exists | ||
if [ ! -f "$INPUT_FILE" ]; then | ||
echo "Error: Input file '$INPUT_FILE' does not exist" | ||
exit 1 | ||
fi | ||
|
||
# Run encode | ||
echo "Encoding $INPUT_FILE to $ENCODED_FILE" | ||
if ! cargo run --bin saffron encode -i "$INPUT_FILE" -o "$ENCODED_FILE"; then | ||
echo "Encoding failed" | ||
exit 1 | ||
fi | ||
|
||
# Run decode | ||
echo "Decoding $ENCODED_FILE to $DECODED_FILE" | ||
if ! cargo run --bin saffron decode -i "$ENCODED_FILE" -o "$DECODED_FILE"; then | ||
echo "Decoding failed" | ||
exit 1 | ||
fi | ||
|
||
# Compare files | ||
if cmp -s fixtures/lorem.txt fixtures/lorem-decoded.txt; then | ||
echo "Files are identical" | ||
echo "Comparing original and decoded files..." | ||
if cmp -s "$INPUT_FILE" "$DECODED_FILE"; then | ||
echo "✓ Success: Files are identical" | ||
echo "Cleaning up temporary files..." | ||
rm -f "$ENCODED_FILE" "$DECODED_FILE" | ||
exit 0 | ||
else | ||
echo "Files differ" | ||
diff fixtures/lorem.txt fixtures/lorem-decoded.txt | ||
echo "✗ Error: Files differ" | ||
echo "Keeping temporary files for inspection" | ||
diff "$INPUT_FILE" "$DECODED_FILE" | ||
exit 1 | ||
fi | ||
fi |