From b4ad5496beeda264ddef3997cbce03eefe724373 Mon Sep 17 00:00:00 2001 From: Everly <66821749+everlyy@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:14:57 +0100 Subject: [PATCH 1/4] Create mypy.yml Try some things with GitHub workflows --- .github/workflows/mypy.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/mypy.yml diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 0000000..46f0a04 --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,23 @@ +name: mypy + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install mypy + - name: Analysing the code with mypy + run: | + mypy bot/TypoBot.py From c380b3781f87bbdf336305d18d1dff09e087a95c Mon Sep 17 00:00:00 2001 From: Everly <66821749+everlyy@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:16:00 +0100 Subject: [PATCH 2/4] Add `.mypy_cache/` to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 92f9969..fc371da 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ config.py __pycache__/ .venv/ storage.json +.mypy_cache/ From d41f2351c6e36060e2be6e34e6571961c7144abc Mon Sep 17 00:00:00 2001 From: Everly <66821749+everlyy@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:26:12 +0100 Subject: [PATCH 3/4] Change `venv.sh` to work with GitHub actions --- venv.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/venv.sh b/venv.sh index d1c0c76..504e6e5 100755 --- a/venv.sh +++ b/venv.sh @@ -9,7 +9,7 @@ function activate { source $VENV_DIR/bin/activate } -if [[ ! -f "$CONFIG_FILE" ]] then +if [ ! -f "$CONFIG_FILE" ]; then # Create example config file echo "DISCORD_TOKEN = \"token here\"" >> $CONFIG_FILE echo "STORAGE_FILE = \"storage.json\"" >> $CONFIG_FILE @@ -17,10 +17,11 @@ if [[ ! -f "$CONFIG_FILE" ]] then echo "STARBOARD_MINIMUM_STARS = 5" >> $CONFIG_FILE fi -if [[ ! -d "$VENV_DIR" ]] then +if [ ! -d "$VENV_DIR" ]; then # Create virtual environment and install required packages $PYTHON -m venv "$VENV_DIR" activate + pip install --upgrade pip pip install -r "$REQUIREMENTS" else activate From f155b3e02ad37f527bce7254c39ef4438c6a8074 Mon Sep 17 00:00:00 2001 From: Everly <66821749+everlyy@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:26:48 +0100 Subject: [PATCH 4/4] Create GitHub action to analyze code with mypy --- .github/workflows/mypy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 46f0a04..836ddbd 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -14,10 +14,10 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Set up environment run: | - python -m pip install --upgrade pip - pip install mypy + bash venv.sh - name: Analysing the code with mypy run: | + . .venv/bin/activate mypy bot/TypoBot.py