Skip to content

Commit

Permalink
ci-cd
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorgedavyd committed Jun 3, 2024
1 parent 4f82694 commit 3a870d4
Showing 1 changed file with 3 additions and 40 deletions.
43 changes: 3 additions & 40 deletions requirements.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,7 @@
#!/bin/bash

# Set the project directory and requirements file paths
PROJECT_DIR="lightorch"
REQUIREMENTS_IN="requirements.in"
REQUIREMENTS_TXT="requirements.txt"
pipreqs lightorch --savepath=requirements.in

# Check if pipreqs is installed
if ! command -v pipreqs &> /dev/null; then
echo "pipreqs could not be found. Please install it with 'pip install pipreqs'."
exit 1
fi
pip-compile requirements.in

# Generate requirements.in using pipreqs
echo "Generating ${REQUIREMENTS_IN} with pipreqs..."
pipreqs "$PROJECT_DIR" --force --savepath="$REQUIREMENTS_IN"

# Check if pipreqs succeeded
if [[ $? -ne 0 ]]; then
echo "pipreqs failed to generate ${REQUIREMENTS_IN}. Exiting."
exit 1
fi

# Check if requirements.in exists and is not empty
if [[ ! -s "$REQUIREMENTS_IN" ]]; then
echo "${REQUIREMENTS_IN} is empty or does not exist. Exiting."
exit 1
fi

# Compile requirements.in to requirements.txt using pip-compile
echo "Compiling ${REQUIREMENTS_IN} to ${REQUIREMENTS_TXT} with pip-compile..."
pip-compile --output-file="$REQUIREMENTS_TXT" "$REQUIREMENTS_IN"

# Check if pip-compile succeeded
if [[ $? -ne 0 ]]; then
echo "pip-compile failed to generate ${REQUIREMENTS_TXT}. Exiting."
exit 1
fi

# Remove the intermediate requirements.in file
echo "Removing ${REQUIREMENTS_IN}..."
rm -f "$REQUIREMENTS_IN"

echo "Requirements successfully generated in ${REQUIREMENTS_TXT}."
rm -f requirements.in

0 comments on commit 3a870d4

Please sign in to comment.