Add mise config and use ruff for Python linting/tidying

This commit is contained in:
Dave Rolsky 2024-12-14 14:45:43 -06:00
parent 7ad7c57bed
commit fe9ef8cc9c
No known key found for this signature in database
4 changed files with 35 additions and 61 deletions

View File

@ -11,15 +11,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Configure Git - name: Install mise
run: |
git config --global user.email "jdoe@example.com"
git config --global user.name "J. Doe"
- name: Run install-dev-tools.sh
run: | run: |
set -e set -e
mkdir $HOME/bin set -x
./dev/bin/install-dev-tools.sh curl https://mise.run | sh
mise install
- name: Run precious - name: Run precious
run: | run: |
PATH=$PATH:$HOME/bin precious lint -a mise exec -- precious lint -a

View File

@ -1,51 +0,0 @@
#!/bin/bash
set -eo pipefail
set -x
function run() {
echo "$1"
eval "$1"
}
function install_tools() {
curl --silent --location \
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
sh
run "ubi --project houseabsolute/precious --in $HOME/bin"
run "ubi --project houseabsolute/omegasort --in $HOME/bin"
run "ubi --project koalaman/shellcheck --in $HOME/bin"
run "ubi --project mvdan/sh --in $HOME/bin --exe shfmt"
run "ubi --project crate-ci/typos --in $HOME/bin"
run "npm install prettier"
run "curl -L https://cpanmin.us/ -o $HOME/bin/cpanm"
run "chmod 0755 $HOME/bin/cpanm"
run "$HOME/bin/cpanm --sudo --notest Perl::Tidy"
}
if [ "$1" == "-v" ]; then
set -x
fi
mkdir -p "$HOME"/bin
set +e
echo ":$PATH:" | grep --extended-regexp ":$HOME/bin:" >&/dev/null
# shellcheck disable=SC2181
if [ "$?" -eq "0" ]; then
path_has_home_bin=1
fi
set -e
if [ -z "$path_has_home_bin" ]; then
PATH=$HOME/bin:$PATH
fi
install_tools
echo "Tools were installed into $HOME/bin."
if [ -z "$path_has_home_bin" ]; then
echo "You should add $HOME/bin to your PATH."
fi
exit 0

10
mise.toml Normal file
View File

@ -0,0 +1,10 @@
[tools]
node = "22.11.0"
"npm:prettier" = "3.4.1"
ruff = "0.8.3"
shellcheck = "v0.10.0"
shfmt = "v3.10.0"
taplo = "0.9.3"
typos = "1.28.1"
"ubi:houseabsolute/omegasort" = "v0.1.3"
"ubi:houseabsolute/precious" = "v0.7.3"

View File

@ -24,10 +24,28 @@ ok_exit_codes = 0
lint_failure_exit_codes = 2 lint_failure_exit_codes = 2
ignore_stderr = "Begin Error Output Stream" ignore_stderr = "Begin Error Output Stream"
[commands."ruff for linting"]
type = "both"
include = [ "**/*.py" ]
cmd = "ruff"
lint_flags = [ "check" ]
tidy_flags = [ "check", "--fix" ]
ok_exit_codes = 0
lint_failure_exit_codes = 1
[commands."ruff for tidying"]
type = "both"
include = [ "**/*.py" ]
cmd = "ruff"
lint_flags = [ "format", "--check" ]
tidy_flags = [ "format" ]
ok_exit_codes = 0
lint_failure_exit_codes = 1
[commands.prettier-md] [commands.prettier-md]
type = "both" type = "both"
include = [ "**/*.md" ] include = [ "**/*.md" ]
cmd = [ "./node_modules/.bin/prettier", "--no-config", "--print-width", "100", "--prose-wrap", "always" ] cmd = [ "prettier", "--no-config", "--print-width", "100", "--prose-wrap", "always" ]
lint_flags = "--check" lint_flags = "--check"
tidy_flags = "--write" tidy_flags = "--write"
ok_exit_codes = 0 ok_exit_codes = 0
@ -37,7 +55,7 @@ ignore_stderr = [ "Code style issues" ]
[commands.prettier-yml] [commands.prettier-yml]
type = "both" type = "both"
include = [ "**/*.yml" ] include = [ "**/*.yml" ]
cmd = [ "./node_modules/.bin/prettier", "--no-config" ] cmd = [ "prettier", "--no-config" ]
lint_flags = "--check" lint_flags = "--check"
tidy_flags = "--write" tidy_flags = "--write"
ok_exit_codes = 0 ok_exit_codes = 0