Skip to content

Commit

Permalink
more compact and quicker code
Browse files Browse the repository at this point in the history
Signed-off-by: Nischay Mamidi <NischayPro@gmail.com>
  • Loading branch information
Nischay-Pro committed Sep 13, 2023
1 parent b5d2e77 commit ab6cccb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ upgrade-deps:
rm requirements/app.txt
rm requirements/test.txt

ifneq ($(docker), yes)
ifneq ($(skip-test), yes)
# Run tests only if not in docker
make test
endif
Expand Down
18 changes: 12 additions & 6 deletions ci/update-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,33 @@ fi
# Check if we can run docker without sudo
if ! docker ps > /dev/null 2>&1; then
echo "Docker is not running without sudo. Please add your user to the docker group and try again."
echo "You may use the following command to do so:"
echo "sudo usermod -aG docker $USER"
echo "You will need to log out and log back in for this to take effect."
exit 1
fi

SOURCE_DIR=$(pwd)/../

TEMP_DIR=$(mktemp -d)

# Copy the current directory to the temp directory
cp -r ../ $TEMP_DIR
# Copy the build files to the temp directory
cp -r ../ci $TEMP_DIR/ci
cp -r ../requirements $TEMP_DIR/requirements
cp -r ../Makefile $TEMP_DIR

cd $TEMP_DIR

PYTHON_VERSIONS=(3.8 3.9 3.10 3.11)

for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}"
do
# Remove container if it exists
docker rm --force flexmeasures-update-packages-$PYTHON_VERSION || true
# Check if container exists and remove it
docker container inspect flexmeasures-update-packages-$PYTHON_VERSION > /dev/null 2>&1 && docker rm --force flexmeasures-update-packages-$PYTHON_VERSION
# Build the docker image
docker build --build-arg=PYTHON_VERSION=$PYTHON_VERSION -t flexmeasures-update-packages:$PYTHON_VERSION . -f ci/Dockerfile.update
# Build flexmeasures
docker run --name flexmeasures-update-packages-$PYTHON_VERSION -it flexmeasures-update-packages:$PYTHON_VERSION make upgrade-deps docker=yes
docker run --name flexmeasures-update-packages-$PYTHON_VERSION -it flexmeasures-update-packages:$PYTHON_VERSION make upgrade-deps skip-test=yes
# Copy the requirements to the source directory
docker cp flexmeasures-update-packages-$PYTHON_VERSION:/app/requirements/$PYTHON_VERSION $SOURCE_DIR/requirements/
# Remove the container
Expand All @@ -47,7 +52,8 @@ do
done

# Clean up docker builder cache
# docker builder prune --all -f
echo "You can clean up the docker builder cache with the following command:"
echo "docker builder prune --all -f"

# Remove the temp directory
rm -rf $TEMP_DIR

0 comments on commit ab6cccb

Please sign in to comment.