75 lines
2.8 KiB
YAML
75 lines
2.8 KiB
YAML
version: '3'
|
|
|
|
services:
|
|
build:
|
|
build:
|
|
context: .
|
|
target: builder
|
|
volumes:
|
|
- ./bin:/output
|
|
command: sh -c "cp /app/tarballer-freebsd /output/ && cp /app/tarballer-darwin /output/ && cp /app/tarballer-linux /output/ && chmod +x /output/tarballer-freebsd /output/tarballer-darwin /output/tarballer-linux"
|
|
|
|
test:
|
|
build:
|
|
context: .
|
|
target: tester
|
|
volumes:
|
|
- ./bin:/output
|
|
- ./test:/test
|
|
- .:/workdir
|
|
working_dir: /workdir
|
|
depends_on:
|
|
- build
|
|
command: |
|
|
sh -c "# Clean up existing test directories
|
|
rm -rf /test/complex /test/complex-extracted &&
|
|
|
|
# Create complex directory structure
|
|
mkdir -p /test/complex/dir1/subdir1/subsubdir1 &&
|
|
mkdir -p /test/complex/dir1/subdir2 &&
|
|
mkdir -p /test/complex/dir2/subdir1 &&
|
|
|
|
# Create files at different levels
|
|
echo 'root level file' > /test/complex/rootfile.txt &&
|
|
echo 'level 1 file in dir1' > /test/complex/dir1/file1.txt &&
|
|
echo 'level 1 file in dir2' > /test/complex/dir2/file2.txt &&
|
|
echo 'level 2 file in subdir1' > /test/complex/dir1/subdir1/file3.txt &&
|
|
echo 'level 2 file in subdir2' > /test/complex/dir1/subdir2/file4.txt &&
|
|
echo 'level 3 file in subsubdir1' > /test/complex/dir1/subdir1/subsubdir1/file5.txt &&
|
|
|
|
# Create a symbolic link with a relative path instead of absolute
|
|
cd /test/complex/dir2 && ln -s ../rootfile.txt symlink.txt && cd /workdir &&
|
|
|
|
# Print the original structure for reference
|
|
echo '=== ORIGINAL DIRECTORY STRUCTURE ===' &&
|
|
find /test/complex -type f -o -type l | sort &&
|
|
|
|
# Create the tarball
|
|
/bin/tarballer -source /test/complex -output /workdir/complex.tar.gz -prefix complex-app &&
|
|
|
|
# Extract the tarball
|
|
mkdir -p /test/complex-extracted &&
|
|
tar -xzf /workdir/complex.tar.gz -C /test/complex-extracted &&
|
|
|
|
# Verify the extracted structure
|
|
echo '=== EXTRACTED DIRECTORY STRUCTURE ===' &&
|
|
find /test/complex-extracted -type f -o -type l | sort &&
|
|
|
|
# Verify file content matches
|
|
echo '=== VERIFYING FILE CONTENTS ===' &&
|
|
cat /test/complex/rootfile.txt &&
|
|
echo ' <-- Original: rootfile.txt' &&
|
|
cat /test/complex-extracted/complex-app/rootfile.txt &&
|
|
echo ' <-- Extracted: rootfile.txt' &&
|
|
|
|
cat /test/complex/dir1/subdir1/subsubdir1/file5.txt &&
|
|
echo ' <-- Original: deep nested file5.txt' &&
|
|
cat /test/complex-extracted/complex-app/dir1/subdir1/subsubdir1/file5.txt &&
|
|
echo ' <-- Extracted: deep nested file5.txt' &&
|
|
|
|
# Test symlink
|
|
echo '=== TESTING SYMLINK ===' &&
|
|
ls -la /test/complex/dir2/symlink.txt &&
|
|
ls -la /test/complex-extracted/complex-app/dir2/symlink.txt &&
|
|
|
|
echo 'All tests completed successfully!'" |