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
142 changes: 142 additions & 0 deletions .github/workflows/auto-release-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Auto Release on Merge

on:
pull_request:
types: [closed]

permissions:
contents: write

jobs:
prepare_release:
if: github.event.pull_request.merged == true
name: Prepare Release
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.get_version.outputs.version_tag }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Get Version from Cargo.toml
id: get_version
run: |
VERSION=$(grep -m1 'version =' Cargo.toml | cut -d '"' -f 2)
echo "Found version: $VERSION"
echo "version_tag=v$VERSION" >> "$GITHUB_OUTPUT"

- name: Generate Release Notes
env:
TAG: ${{ steps.get_version.outputs.version_tag }}
run: |
cat > release_notes.md <<'EOF'
# PureCode $TAG

## Highlights
- Add a few concise bullets about the most impactful changes.

## Fixes
- Note bug fixes or quality improvements worth calling out.

## Compatibility
- Breaking changes: none.
- Minimum supported Rust: stable.

## Install
```bash
curl -LsSf https://raw.githubusercontent.com/isupervillain/purecode/main/install.sh | sh
```

```powershell
powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/isupervillain/purecode/main/install.ps1 | iex"
```
EOF

- name: Check and Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.get_version.outputs.version_tag }}
SHA: ${{ github.event.pull_request.merge_commit_sha }}
run: |
if gh release view "$TAG" > /dev/null 2>&1; then
echo "Error: Release $TAG already exists."
exit 1
else
echo "Creating release $TAG for commit $SHA"
gh release create "$TAG" --target "$SHA" --notes-file release_notes.md
fi

build_and_upload:
needs: prepare_release
name: Build and Upload Assets
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: purecode
asset_name: purecode-x86_64-unknown-linux-gnu.tar.gz
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: purecode
asset_name: purecode-x86_64-unknown-linux-musl.tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: purecode.exe
asset_name: purecode-x86_64-pc-windows-msvc.zip
- os: macos-13
target: x86_64-apple-darwin
artifact_name: purecode
asset_name: purecode-x86_64-apple-darwin.tar.gz
- os: macos-14
target: aarch64-apple-darwin
artifact_name: purecode
asset_name: purecode-aarch64-apple-darwin.tar.gz

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}

- name: Install musl-tools (Linux musl)
if: contains(matrix.target, 'musl')
run: |
sudo apt-get update
sudo apt-get install -y musl-tools

- name: Build Release
run: cargo build --release --target ${{ matrix.target }}

- name: Package (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar -czf ../../../${{ matrix.asset_name }} ${{ matrix.artifact_name }}
cd -

- name: Package (Windows)
if: runner.os == 'Windows'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ matrix.asset_name }} ${{ matrix.artifact_name }}
cd -

- name: Upload Release Asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.prepare_release.outputs.release_tag }}
run: |
gh release upload "$TAG" "${{ matrix.asset_name }}"
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
build-and-test:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact_name: purecode-linux-amd64
asset_name: purecode
- os: macos-latest
artifact_name: purecode-macos-amd64
asset_name: purecode
- os: windows-latest
artifact_name: purecode-windows-amd64.exe
asset_name: purecode.exe

steps:
- uses: actions/checkout@v3

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

- name: Build Release
run: cargo build --release

- name: Run Tests
run: cargo test --release

- name: Upload Artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: target/release/${{ matrix.asset_name }}
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Cargo
# will have compiled files and executables
debug
target

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Generated by cargo mutants
# Contains mutation testing data
**/mutants.out*/

# RustRover
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- id: purecode
name: purecode
entry: purecode
language: system
pass_filenames: false
stages: [commit-msg, pre-commit]
args: ["--stdin"]
61 changes: 61 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Contributing to PureCode

Thank you for your interest in contributing to `purecode`! We want to make this tool the standard for semantic diff analysis.

## Prerequisites

- **Rust**: You will need a stable Rust toolchain installed. We recommend using [rustup](https://rustup.rs/).
- **Git**: For version control.

## Local Development

1. **Clone the repository**:
```bash
git clone https://github.com/yourusername/purecode.git
cd purecode
```

2. **Build the project**:
```bash
cargo build
```

3. **Run tests**:
```bash
cargo test
```

4. **Run the tool locally**:
You can run the CLI against the repo itself to test changes:
```bash
cargo run -- --base HEAD~1 --head HEAD
```

## Coding Guidelines

- **Idiomatic Rust**: We strive for clean, idiomatic Rust code (Edition 2021).
- **Formatting**: Please run `cargo fmt` before submitting.
- **Linting**: We use `clippy` to catch common mistakes. Please run `cargo clippy` and address warnings.
```bash
cargo clippy -- -D warnings
```
- **Documentation**: Public structs and functions should have documentation comments (`///`).

## Branching and Pull Requests

1. Create a new branch for your feature or fix. We recommend naming it `feature/your-feature-name` or `fix/issue-description`.
2. Make your changes.
3. Add tests for any new logic (especially new classifiers).
4. Ensure all tests pass.
5. Push your branch and open a Pull Request against `main`.

## CI/CD

Our GitHub Actions workflow automatically:
- Builds the project on Linux, macOS, and Windows.
- Runs the test suite.
- (On PRs) Generates binary artifacts that you can download to verify behavior on different OSes.

## Reporting Issues

If you find a bug or have a feature request, please open an issue in the GitHub repository describing the problem and how to reproduce it.
Loading
Loading