Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish to crates.io

on:
release:
types: [created]

jobs:
publish:
runs-on: ubuntu-latest

environment:
name: crates-io
url: https://crates.io/crates/libpgfmt

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Install stable Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry and build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-release-

- name: Run tests
run: cargo test

- name: Verify version matches tag
run: |
TAG="${GITHUB_REF#refs/tags/v}"
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
if [ "$TAG" != "$CARGO_VERSION" ]; then
echo "Tag v$TAG does not match Cargo.toml version $CARGO_VERSION"
exit 1
fi

- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Testing
on:
pull_request:
push:
branches: ["*"]
paths-ignore:
- "*.md"
tags-ignore: ["*"]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable, nightly]

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: clippy, rustfmt

- name: Cache cargo registry and build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.rust }}-

- name: Check formatting
run: cargo fmt --check

- name: Run clippy
run: cargo clippy -- -D warnings

- name: Run tests
run: cargo test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt
entry: cargo fmt --check
language: system
types: [rust]
pass_filenames: false

- id: cargo-clippy
name: cargo clippy
entry: cargo clippy -- -D warnings
language: system
types: [rust]
pass_filenames: false

- id: cargo-test
name: cargo test
entry: cargo test
language: system
types: [rust]
pass_filenames: false
stages: [pre-push]
18 changes: 18 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

libpgfmt is a Rust library for formatting PostgreSQL-specific SQL and PL/pgSQL.

## Build Commands

```sh
cargo build
cargo test
cargo test <test_name> # run a single test
cargo clippy # lint
cargo fmt --check # check formatting
cargo fmt # auto-format
```
248 changes: 248 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading