From ea30737ae61e11f1afff06b8f00940846ce9bf83 Mon Sep 17 00:00:00 2001 From: Mark Joshwel Date: Wed, 19 Jun 2024 01:30:04 +0800 Subject: [PATCH] add check.sh scripts --- docs/developing.md | 34 +++++++++++++++++++++++-------- docs/links.md | 14 +++++++++++-- src/spow-telegram-bridge/check.sh | 21 +++++++++++++++++++ src/spow-whatsapp-bridge/check.sh | 24 ++++++++++++++++++++++ src/surplus-on-wheels/check.sh | 21 +++++++++++++++++++ 5 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 src/spow-telegram-bridge/check.sh create mode 100644 src/spow-whatsapp-bridge/check.sh create mode 100644 src/surplus-on-wheels/check.sh diff --git a/docs/developing.md b/docs/developing.md index a954ffd..5cd6ca6 100644 --- a/docs/developing.md +++ b/docs/developing.md @@ -120,6 +120,9 @@ prerequisite software: ### workflow +!!! note + alternatively, run `check.sh` inside `src/surplus-on-wheels` + - formatting s+ow: - run `shfmt s+ow > s+ow.new` - mv `s+ow.new` into `s+ow` @@ -161,10 +164,15 @@ poetry shell after modifying, -1. `mypy bridge.py` -2. `ruff format bridge.py` -3. `ruff check bridge.py` -4. [test the binary](#workflow-for-testing-the-binary) +1. check the source code: + 1. `mypy bridge.py` + 2. `ruff format bridge.py` + 3. `ruff check bridge.py` + + !!! note + alternatively, run `check.sh` inside `src/spow-telegram-bridge` + +2. and then [test the binary](#workflow-for-testing-the-binary) if the bridge behaves nominally, [bump the version](#versioning-surplus-on-wheels-telegram-bridge) and commit! @@ -194,9 +202,19 @@ code, and as such, whenever in doubt, do a diff between mdtest and the bridge co after modifying, -1. [build a binary](#workflow-for-building-a-binary) -2. [test the binary](#workflow-for-testing-the-binary) -3. and if all goes well, [bump the version](#versioning-surplus-on-wheels-whatsapp-bridge) +1. check the source code: + 1. `go fmt bridge.go` + 2. `go vet bridge.go` + 3. `golint bridge.go` + + !!! note + alternatively, run `check.sh` inside `src/spow-whatsapp-bridge` + +2. [build a binary](#workflow-for-building-a-binary) + +3. [test the binary](#workflow-for-testing-the-binary) + +4. and if all goes well, [bump the version](#versioning-surplus-on-wheels-whatsapp-bridge) and commit! ### workflow for bumping dependencies @@ -224,7 +242,7 @@ CGO_ENABLED=1 go build nix users can alternatively run: ```text -nix build .#native +nix build ``` instructions to build a Termux build are located at the diff --git a/docs/links.md b/docs/links.md index a0940fa..66e590b 100644 --- a/docs/links.md +++ b/docs/links.md @@ -37,15 +37,25 @@ https://github.com/markjoshwel/surplus.git ## surplus on wheels: Telegram Bridge - install/update script: - + ``` title="Primary Link" https://surplus.joshwel.co/telegram.sh ``` - + ``` title="Alternative Link" https://raw.githubusercontent.com/markjoshwel/surplus/main/src/spow-telegram-bridge/install.sh ``` +- pipx target + + ``` title="Primary Link" + git+https://forge.joshwel.co/mark/surplus.git#egg=spow-telegram-bridge&subdirectory=src/spow-telegram-bridge + ``` + + ``` title="Alternative Link" + git+https://github.com/markjoshwel/surplus.git#egg=spow-telegram-bridge&subdirectory=src/spow-telegram-bridge + ``` + ## surplus on wheels: WhatsApp Bridge - install/update script: diff --git a/src/spow-telegram-bridge/check.sh b/src/spow-telegram-bridge/check.sh new file mode 100644 index 0000000..5136ae8 --- /dev/null +++ b/src/spow-telegram-bridge/check.sh @@ -0,0 +1,21 @@ +#!/bin/sh +failures=0 + +mypy bridge.py +failures=$((failures + $?)) + +ruff check bridge.py +failures=$((failures + $?)) + +ruff format bridge.py +failures=$((failures + $?)) + +isort --check bridge.py +failures=$((failures + $?)) + +if [ $failures -eq 0 ]; then + printf "\n\nall checks okay! (❁´◡\`❁)\n" +else + printf "\n\nsome checks failed...\n" +fi +exit $failures diff --git a/src/spow-whatsapp-bridge/check.sh b/src/spow-whatsapp-bridge/check.sh new file mode 100644 index 0000000..c50c853 --- /dev/null +++ b/src/spow-whatsapp-bridge/check.sh @@ -0,0 +1,24 @@ +#!/bin/sh +failures=0 + +ORI_HASH=$(md5sum < bridge.go) +FMT_HASH=$(gofmt bridge.go | md5sum) +if ! [ "$FMT_HASH" = "$ORI_HASH" ]; then + printf "formatted file (%s) is not the same as the original file (%s)" "$FMT_HASH" "$ORI_HASH" + failures=$((failures + 1)) +else + printf "formatted file is same as original file - %s (yay!)" "$FMT_HASH" +fi + +go vet bridge.go +failures=$((failures + $?)) + +golint bridge.go +failures=$((failures + $?)) + +if [ $failures -eq 0 ]; then + printf "\n\nall checks okay! (❁´◡\`❁)\n" +else + printf "\n\nsome checks failed...\n" +fi +exit $failures diff --git a/src/surplus-on-wheels/check.sh b/src/surplus-on-wheels/check.sh new file mode 100644 index 0000000..6b8a2e6 --- /dev/null +++ b/src/surplus-on-wheels/check.sh @@ -0,0 +1,21 @@ +#!/bin/sh +failures=0 + +FMT_HASH=$(shfmt s+ow | md5sum) +ORI_HASH=$(md5sum < s+ow) +if ! [ "$FMT_HASH" = "$ORI_HASH" ]; then + printf "formatted file (%s) is not the same as the original file (%s)" "$FMT_HASH" "$ORI_HASH" + failures=$((failures + 1)) +else + printf "formatted file is same as original file - %s (yay!)" "$FMT_HASH" +fi + +shellcheck s+ow +failures=$((failures + $?)) + +if [ $failures -eq 0 ]; then + printf "\n\nall checks okay! (❁´◡\`❁)\n" +else + printf "\n\nsome checks failed...\n" +fi +exit $failures