aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2024-02-20 20:37:26 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-20 20:42:08 +0100
commit424fed172845fbba7f79eb6379a1bd11b268e712 (patch)
treed269daf727b13f3af459195ee878b6272b034bc4
parentbf60cdad8821937b53868e74c16c1824140f8def (diff)
downloadwee-slack-424fed172845fbba7f79eb6379a1bd11b268e712.tar.gz
Format built file after building if ruff is available
-rw-r--r--.github/workflows/wee-slack.yml6
-rwxr-xr-xbuild.sh7
2 files changed, 13 insertions, 0 deletions
diff --git a/.github/workflows/wee-slack.yml b/.github/workflows/wee-slack.yml
index fdbee42..d7e6fcf 100644
--- a/.github/workflows/wee-slack.yml
+++ b/.github/workflows/wee-slack.yml
@@ -44,6 +44,12 @@ jobs:
steps:
- uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: "3.12"
+ - uses: abatilo/actions-poetry@v3
+ - run: poetry install
+
- name: Install WeeChat, tmux and python3-websocket
run: |
sudo apt-get update
diff --git a/build.sh b/build.sh
index 9472572..3ec64a5 100755
--- a/build.sh
+++ b/build.sh
@@ -16,3 +16,10 @@ contents="$(cat slack/python_compatibility.py slack/util.py slack/shared.py slac
echo "$contents" | grep -v '^from __future__' | grep -E '^(import|from) ' | sort -u
echo "$contents" | grep -Ev '^(import|from) ' | sed 's/^\( \+\)\(import\|from\) .*/\1pass/'
) > build/slack.py
+
+ruff_cmd="$(poetry run sh -c 'command -v ruff' 2>/dev/null || command -v ruff)"
+
+if [ -x "$ruff_cmd" ]; then
+ "$ruff_cmd" check -q --fix-only --target-version py37 build/slack.py
+ "$ruff_cmd" format -q --target-version py37 build/slack.py
+fi