Restore 100% go by outsourcing lintdown.sh

This commit is contained in:
ChillerDragon 2024-06-24 17:59:59 +08:00
parent 72b008f6d8
commit 0edc8b334b
3 changed files with 5 additions and 50 deletions

View file

@ -31,7 +31,11 @@ jobs:
go-version: '1.22'
- name: Build go snippets in readme
run: ./scripts/compile_readme_snippets.sh
run: |
mkdir -p ~/.local/bin/
wget -O ~/.local/bin/lintdown.sh https://raw.githubusercontent.com/ChillerDragon/lintdown.sh/master/lintdown.sh
chmod +x ~/.local/bin/lintdown.sh
lintdown.sh README.md
test:
runs-on: ubuntu-latest

View file

@ -1,27 +0,0 @@
name: Shell
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
bash:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare
run: |
sudo apt-get update -y
sudo apt-get install shellcheck
mkdir -p ~/.local/bin/
wget -O ~/.local/bin/shfmt https://github.com/mvdan/sh/releases/download/v3.8.0/shfmt_v3.8.0_linux_amd64
chmod +x ~/.local/bin/shfmt
- name: Shellcheck
run: find . -type f -name '*.sh' -print0 | xargs -0 shellcheck
- name: Shell format (shfmt)
run: find . -type f -name '*.sh' -print0 | xargs -0 shfmt -d

View file

@ -1,22 +0,0 @@
#!/bin/bash
mkdir -p tmp
awk '/^```go$/ {p=1}; p; /^```$/ {p=0;print"--- --- ---"}' README.md |
grep -vE '^```(go)?$' |
csplit \
-z -s - '/--- --- ---/' \
'{*}' \
--suppress-matched \
-f tmp/readme_snippet_ -b '%02d.go'
for snippet in ./tmp/readme_snippet_*.go; do
echo "building $snippet ..."
go build -v -o tmp/tmp "$snippet" || exit 1
done
for snippet in ./tmp/readme_snippet_*.go; do
echo "checking format $snippet ..."
if ! diff -u <(echo -n) <(gofmt -d "$snippet"); then
exit 1
fi
done