Skip to content

fix ci workflows

fix ci workflows #3

Workflow file for this run

name: E2E Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
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
# For these tests, we want ripgrep to ignore the same files as refaktor
- name: Setup .rgignore
run: |
cp .rfignore .rgignore
echo .rgignore >> .git/info/exclude
- name: Build refaktor
run: |
cargo build --release
./target/release/refaktor --version
- name: Test refaktor -> smart_search_and_replace
run: |
echo "=== Testing refaktor rename to smart_search_and_replace ==="
# Use refaktor to rename itself using plan/apply
./target/release/refaktor plan refaktor smart_search_and_replace --preview-format table
./target/release/refaktor apply
# Verify no instances of "refaktor" remain in the codebase (case-insensitive)
echo "Checking for remaining instances of 'refaktor'..."
if rg -i refaktor; then
echo "ERROR: Found remaining instances of 'refaktor' in the codebase!"
exit 1
fi
# Verify the rename worked by checking key dirs / files
if [ -d "refaktor-core" ]; then
echo "ERROR: refaktor-core directory 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
echo "✓ No instances of 'refaktor' found"
shell: bash
- name: Test undo
run: |
echo "=== Testing undo functionality ==="
# Undo the rename
./target/release/refaktor undo latest
# Verify the undo 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
# The working directory should be clean after the undo
if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: Working directory is not clean after undo!"
git status
git diff
exit 1
fi
echo "✓ Working directory is clean - undo successful!"
shell: bash
- name: Test redo
run: |
echo "=== Testing redo functionality ==="
# Redo the rename
./target/release/refaktor redo latest
# Verify no instances of "refaktor" remain in the codebase (case-insensitive)
echo "Checking for remaining instances of 'refaktor'..."
if rg -i "refaktor"; then
echo "ERROR: Found remaining instances of 'refaktor' in the codebase!"
exit 1
fi
echo "✓ No instances of 'refaktor' found"
shell: bash
- name: Build smart_search_and_replace
run: |
rm -rf target
cargo build --release
./target/release/smart_search_and_replace --version
- 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 rename smart_search_and_replace refaktor --preview-format table
# 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)"; 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"
- name: Build refaktor again
run: |
# 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