From 40ff876e23a7ad073c5f69314860650d14f34134 Mon Sep 17 00:00:00 2001 From: Ernesto Casablanca Date: Mon, 20 Nov 2023 00:24:47 +0000 Subject: [PATCH] feat: add utility script to run the ci pipeline locally --- README.md | 5 +++++ docs/source/conf.py | 2 +- script/local-ci.bat | 6 ++++++ script/local-ci.sh | 5 +++++ src/spotted/data/user.py | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 script/local-ci.bat create mode 100755 script/local-ci.sh diff --git a/README.md b/README.md index 96dae272..98f5b4c2 100644 --- a/README.md +++ b/README.md @@ -372,6 +372,11 @@ pip3 install -e .[lint] - **Run** `black --check src tests` to make sure the code is formatted correctly. If it is not, you can run `black src` to format it automatically - **Run** `isort --check-only src tests` to make sure the imports are sorted correctly. If they are not, you can run `isort src` to sort them automatically +### Scripts + +The `scripts` folder contains some utility scripts that can be used to simulate the whole CI pipeline locally. +Make sure to have the dev dependencies installed before running them. + ## 📚 Documentation [Link to the documentation](https://unict-dmi.github.io/Telegram-SpottedDMI-Bot/) diff --git a/docs/source/conf.py b/docs/source/conf.py index edb3edb4..cc0558b7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,8 +11,8 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os -import sys import shutil +import sys sys.path.insert(0, os.path.abspath("../..")) # path to the actual project root folder diff --git a/script/local-ci.bat b/script/local-ci.bat new file mode 100644 index 00000000..825f624a --- /dev/null +++ b/script/local-ci.bat @@ -0,0 +1,6 @@ +@echo off +rem Run all the tests and linters in the CI pipeline locally +pytest tests +pylint src tests +black --check src tests +isort --check-only src tests diff --git a/script/local-ci.sh b/script/local-ci.sh new file mode 100755 index 00000000..790f63c2 --- /dev/null +++ b/script/local-ci.sh @@ -0,0 +1,5 @@ +# Run all the tests and linters in the CI pipeline locally +pytest tests || (echo "Tests failed" && exit 1) +pylint src tests || (echo "Pylint failed" && exit 1) +black --check src tests || (echo "Black failed" && exit 1) +isort --check-only src tests || (echo "Isort failed" && exit 1) diff --git a/src/spotted/data/user.py b/src/spotted/data/user.py index d9d75d3a..0424d6b1 100644 --- a/src/spotted/data/user.py +++ b/src/spotted/data/user.py @@ -1,7 +1,7 @@ """Users management""" from dataclasses import dataclass -from random import choice from datetime import datetime +from random import choice from telegram import Bot