diff options
| -rw-r--r-- | .gitlab-ci.yml | 14 | ||||
| -rw-r--r-- | Pipfile | 7 | ||||
| -rw-r--r-- | bot/cogs/off_topic_names.py | 11 | ||||
| -rw-r--r-- | docker/base.Dockerfile (renamed from docker/Dockerfile.base) | 2 | ||||
| -rw-r--r-- | docker/bot.Dockerfile (renamed from docker/Dockerfile) | 6 | ||||
| -rw-r--r-- | scripts/deploy.sh | 10 |
6 files changed, 29 insertions, 21 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3edfb2bf8..f7aee8165 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,14 @@ image: pythondiscord/bot-ci:latest variables: - PIPENV_CACHE_DIR: "$CI_PROJECT_DIR/pipenv-cache" + PIPENV_CACHE_DIR: "/root/.cache/pipenv" + PIP_CACHE_DIR: "/root/.cache/pip" cache: paths: - - "$CI_PROJECT_DIR/pipenv-cache" - - "$CI_PROJECT_DIR/.venv" + - "/root/.cache/pip/" + - "/root/.cache/pipenv/" + - "/usr/local/lib/python3.6/site-packages/" stages: - test @@ -19,8 +21,10 @@ test: stage: test script: - - pipenv install --dev --deploy - - pipenv run lint + - ls /root/.cache/ + - pipenv install --dev --deploy --system + - python -m flake8 + - ls /root/.cache/ build: tags: @@ -40,9 +40,12 @@ python_version = "3.6" [scripts] start = "python -m bot" lint = "python -m flake8" -build = "docker build -t pythondiscord/bot:latest -f docker/Dockerfile ." + +build = "docker build -t pythondiscord/bot:latest -f docker/bot.Dockerfile ." push = "docker push pythondiscord/bot:latest" -buildbase = "docker build -t pythondiscord/bot-base:latest -f docker/Dockerfile.base ." + +buildbase = "docker build -t pythondiscord/bot-base:latest -f docker/base.Dockerfile ." pushbase = "docker push pythondiscord/bot-base:latest" + buildci = "docker build -t pythondiscord/bot-ci:latest -f docker/ci.Dockerfile ." pushci = "docker push pythondiscord/bot-ci:latest" diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py index bcf3148f8..ac2e1269c 100644 --- a/bot/cogs/off_topic_names.py +++ b/bot/cogs/off_topic_names.py @@ -19,19 +19,22 @@ class OffTopicName(Converter): @staticmethod async def convert(ctx: Context, argument: str): + allowed_characters = ("-", "’", "'", "`") + if not (2 <= len(argument) <= 96): raise BadArgument("Channel name must be between 2 and 96 chars long") - elif not all(c.isalnum() or c == '-' for c in argument): + elif not all(c.isalnum() or c in allowed_characters for c in argument): raise BadArgument( - "Channel name must only consist of" - " alphanumeric characters or minus signs" + "Channel name must only consist of " + "alphanumeric characters, minus signs or apostrophes." ) elif not argument.islower(): raise BadArgument("Channel name must be lowercase") - return argument + # Replace some unusable apostrophe-like characters with "’". + return argument.replace("'", "’").replace("`", "’") async def update_names(bot: Bot, headers: dict): diff --git a/docker/Dockerfile.base b/docker/base.Dockerfile index 2f6929e0d..de2c68c13 100644 --- a/docker/Dockerfile.base +++ b/docker/base.Dockerfile @@ -22,6 +22,6 @@ ENV PIPENV_IGNORE_VIRTUALENVS=1 ENV PIPENV_NOSPIN=1 ENV PIPENV_HIDE_EMOJIS=1 -RUN pipenv install +RUN pipenv install --deploy --system # usage: FROM pythondiscord/bot-base:latest diff --git a/docker/Dockerfile b/docker/bot.Dockerfile index 2db1ee24a..4713e1f0e 100644 --- a/docker/Dockerfile +++ b/docker/bot.Dockerfile @@ -5,12 +5,10 @@ ENV PIPENV_IGNORE_VIRTUALENVS=1 ENV PIPENV_NOSPIN=1 ENV PIPENV_HIDE_EMOJIS=1 -RUN pip install pipenv - COPY . /bot WORKDIR /bot -RUN pipenv sync +RUN pipenv install --deploy --system ENTRYPOINT ["/sbin/tini", "--"] -CMD ["pipenv", "run", "start"] +CMD ["python", "-m", "bot"] diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 50ec87f59..070d0ec26 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -5,22 +5,22 @@ if [[ $CI_COMMIT_REF_SLUG == 'master' ]]; then echo "Connecting to docker hub" echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - changed_lines=$(git diff HEAD~1 HEAD docker/Dockerfile.base | wc -l) + changed_lines=$(git diff HEAD~1 HEAD docker/base.Dockerfile | wc -l) if [ $changed_lines != '0' ]; then - echo "Dockerfile.base was changed" + echo "base.Dockerfile was changed" echo "Building bot base" - docker build -t pythondiscord/bot-base:latest -f docker/Dockerfile.base . + docker build -t pythondiscord/bot-base:latest -f docker/base.Dockerfile . echo "Pushing image to Docker Hub" docker push pythondiscord/bot-base:latest else - echo "Dockerfile.base was not changed, not building" + echo "base.Dockerfile was not changed, not building" fi echo "Building image" - docker build -t pythondiscord/bot:latest -f docker/Dockerfile . + docker build -t pythondiscord/bot:latest -f docker/bot.Dockerfile . echo "Pushing image" docker push pythondiscord/bot:latest |