unstructured/scripts/check-licenses.sh
Matt Robinson ee2b247297
build: check dependency licenses in CI (#3349)
### Summary

Adds a CI check to ensure that packages added as dependencies are
appropriately licensed. All of the `.txt` files in the `requirements`
directory are checked with the exception of:

- `constraints.txt`, since those are not installed and are instead
conditions on the other dependency files
- `dev.txt`, since those are for local development and not shipped as
part of the `unstructured` package
- `extra-pdf-image.txt` - the `extra-pdf-image.in` since checking
`extra-pdf-image.txt` pulls in NVIDIA GPU related packages with an
`Other/Proprietary` license type, and there's not a good way to exclude
those without adding `Other/Proprietary` to the allowed licenses list.

### Testing

The new `check-licenses` job should pass in CI.
2024-07-11 22:36:01 +00:00

22 lines
534 B
Bash
Executable File

#!/usr/bin/env bash
REQUIREMENTS_FILES=$(find requirements -type f -name "*.txt" \
-name "extra-pdf-image.in" \
! -name "extra-pdf-image.txt" \
! -name "constraints.txt" \
! -name "dev.txt")
for REQUIREMENTS_FILE in $REQUIREMENTS_FILES; do
echo "Checking $REQUIREMENTS_FILE"
liccheck -r "$REQUIREMENTS_FILE"
EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 0 ]; then
echo "All dependencies have authorized licenses."
else
echo "There are dependencies with unauthorized or unknown licenses."
exit 1
fi
done
exit 0