diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..a839310 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,53 @@ +name: Pre-commit + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +concurrency: + group: pre-commit-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.14" + + - uses: actions/setup-go@v5 + with: + go-version: "1.24.x" + + - name: Install StyLua + run: | + mkdir -p "$HOME/.local/bin" + curl --fail --location --silent --show-error \ + https://github.com/JohnnyMorganz/StyLua/releases/download/v2.5.2/stylua-linux-x86_64.zip \ + --output /tmp/stylua.zip + unzip -q /tmp/stylua.zip -d "$HOME/.local/bin" + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + - name: Install shfmt + run: | + go install mvdan.cc/sh/v3/cmd/shfmt@v3.14.1 + echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" + + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Run pre-commit + # Ghostty is macOS-oriented and is intentionally validated locally; installing it on + # a macOS runner would make this otherwise fast backup check considerably slower. + run: | + python -m pip install --disable-pip-version-check pre-commit==4.6.2 + SKIP=ghostty-validate-config pre-commit run --all-files