2023-07-26 16:55:35 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
cleanup() {
|
2023-12-18 23:48:21 -08:00
|
|
|
rm -rf unstructured-api
|
2023-07-26 16:55:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
handle_error() {
|
2023-12-18 23:48:21 -08:00
|
|
|
cleanup
|
|
|
|
exit 1
|
2023-07-26 16:55:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Remove the unstructured-api directory if it exists
|
|
|
|
if [ -d "unstructured-api" ]; then
|
2023-12-18 23:48:21 -08:00
|
|
|
rm -rf unstructured-api
|
2023-07-26 16:55:35 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Clone the repository
|
|
|
|
git clone https://github.com/Unstructured-IO/unstructured-api.git --depth 1
|
|
|
|
|
|
|
|
# Install dependencies and project locally
|
|
|
|
cd unstructured-api && make install && cd ../
|
|
|
|
make install-project-local
|
|
|
|
pip show unstructured | grep Version
|
|
|
|
|
|
|
|
# Run tests and capture exit status
|
|
|
|
(cd unstructured-api && make test)
|
|
|
|
test_exit_status=$?
|
|
|
|
|
|
|
|
# Check the exit status and handle errors
|
|
|
|
if [ $test_exit_status -ne 0 ]; then
|
2023-12-18 23:48:21 -08:00
|
|
|
echo "Test failed, see the error message above."
|
|
|
|
handle_error
|
2023-07-26 16:55:35 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
|
|
|
|
echo "Test and cleanup completed successfully."
|