Skip to content

added config support #7

added config support

added config support #7

Workflow file for this run

name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
run: |
# Install compatible version for Rust 1.80.1
cargo install cargo-llvm-cov --version 0.6.15
- name: Generate code coverage
run: cargo llvm-cov --package refaktor-core --lcov --output-path lcov.info
- name: Check coverage threshold
run: |
# Run coverage and capture output
COVERAGE_OUTPUT=$(cargo llvm-cov --package refaktor-core 2>&1)
echo "$COVERAGE_OUTPUT"
# Extract coverage percentage from the TOTAL line
COVERAGE=$(echo "$COVERAGE_OUTPUT" | grep "^TOTAL" | awk '{print $10}' | sed 's/%//')
echo "Coverage: ${COVERAGE}%"
# Check if coverage is at least 95%
if (( $(echo "${COVERAGE} < 95.00" | bc -l) )); then
echo "Coverage is below 95% threshold: ${COVERAGE}%"
exit 1
fi
echo "Coverage meets 95% threshold: ${COVERAGE}%"
- name: Generate HTML report
run: cargo llvm-cov --package refaktor-core --html
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: target/llvm-cov/html/
check-msrv:
name: Check MSRV
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust 1.80.1
uses: dtolnay/rust-toolchain@1.80.1
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Check MSRV
run: |
# Downgrade half package for MSRV compatibility
cargo update half@2.6.0 --precise 2.4.1 || true
cargo check --all-targets
self-referential-demo:
name: Self-Referential Demo
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install ripgrep
run: |
if ! command -v rg &> /dev/null; then
echo "Installing ripgrep..."
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
sudo apt-get update && sudo apt-get install -y ripgrep
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
brew install ripgrep
else # windows
choco install ripgrep
fi
fi
shell: bash
- name: Build refaktor
run: cargo build --release
- name: Test refaktor -> smart_search_and_replace
run: |
echo "=== Testing refaktor rename to smart_search_and_replace ==="
# Use refaktor to rename itself
./target/release/refaktor --auto-init=repo plan refaktor smart_search_and_replace
./target/release/refaktor apply
# Verify the rename worked by checking key files
if [ -f "refaktor-core/Cargo.toml" ]; then
echo "ERROR: refaktor-core/Cargo.toml still exists!"
exit 1
fi
if [ ! -f "smart-search-and-replace-core/Cargo.toml" ]; then
echo "ERROR: smart-search-and-replace-core/Cargo.toml not found!"
exit 1
fi
# Verify no instances of "refaktor" remain in the codebase (case-insensitive)
echo "Checking for remaining instances of 'refaktor'..."
if rg -i "refaktor" --type-not binary; then
echo "ERROR: Found remaining instances of 'refaktor' in the codebase!"
exit 1
fi
echo "✓ No instances of 'refaktor' found"
# Clean and rebuild with new name
rm -rf target
cargo build --release
# Verify the new binary exists and works
./target/release/smart_search_and_replace --version
shell: bash
- name: Test smart_search_and_replace -> refaktor
run: |
echo "=== Testing smart_search_and_replace rename back to refaktor ==="
# Use smart_search_and_replace to rename itself back
./target/release/smart_search_and_replace plan smart_search_and_replace refaktor
./target/release/smart_search_and_replace apply
# Verify the rename worked
if [ -f "smart-search-and-replace-core/Cargo.toml" ]; then
echo "ERROR: smart-search-and-replace-core/Cargo.toml still exists!"
exit 1
fi
if [ ! -f "refaktor-core/Cargo.toml" ]; then
echo "ERROR: refaktor-core/Cargo.toml not found!"
exit 1
fi
# Verify no instances of "smart_search_and_replace" or "smart-search-and-replace" remain
echo "Checking for remaining instances of 'smart_search_and_replace' or 'smart-search-and-replace'..."
if rg "(smart_search_and_replace|smart-search-and-replace|smartsearchandreplace)" --type-not binary; then
echo "ERROR: Found remaining instances of 'smart_search_and_replace' in the codebase!"
exit 1
fi
echo "✓ No instances of 'smart_search_and_replace' found"
# Clean and rebuild with original name
rm -rf target
cargo build --release
# Final verification
./target/release/refaktor --version
./target/release/refaktor --help
shell: bash
- name: Verify git status is clean
run: |
# The working directory should be clean after the round-trip
if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: Working directory is not clean after round-trip!"
git status
git diff
exit 1
fi
echo "✓ Working directory is clean - round-trip successful!"
shell: bash