Skip to content

Commit e7d0fc6

Browse files
committed
use shared scripts/e2e-test.sh
1 parent 03de154 commit e7d0fc6

File tree

4 files changed

+130
-278
lines changed

4 files changed

+130
-278
lines changed

.github/workflows/e2e.yml

Lines changed: 2 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -45,135 +45,6 @@ jobs:
4545
fi
4646
shell: bash
4747

48-
# For these tests, we want ripgrep to ignore the same files as refaktor
49-
- name: Setup .rgignore
48+
- name: Run e2e test
5049
run: |
51-
cp .rfignore .rgignore
52-
echo .rgignore >> .git/info/exclude
53-
54-
- name: Build refaktor
55-
run: |
56-
cargo build --release
57-
./target/release/refaktor --version
58-
59-
- name: Test refaktor -> smart_search_and_replace
60-
run: |
61-
echo "=== Testing refaktor rename to smart_search_and_replace ==="
62-
63-
# Use refaktor to rename itself using plan/apply
64-
./target/release/refaktor plan refaktor smart_search_and_replace --preview table
65-
./target/release/refaktor apply
66-
67-
# Verify no instances of "refaktor" remain in the codebase (case-insensitive)
68-
echo "Checking for remaining instances of 'refaktor'..."
69-
if rg -i refaktor; then
70-
echo "ERROR: Found remaining instances of 'refaktor' in the codebase!"
71-
exit 1
72-
fi
73-
74-
# Verify the rename worked by checking key dirs / files
75-
if [ -d "refaktor-core" ]; then
76-
echo "ERROR: refaktor-core directory still exists!"
77-
exit 1
78-
fi
79-
if [ ! -f "smart-search-and-replace-core/Cargo.toml" ]; then
80-
echo "ERROR: smart-search-and-replace-core/Cargo.toml not found!"
81-
exit 1
82-
fi
83-
84-
echo "✓ No instances of 'refaktor' found"
85-
shell: bash
86-
87-
- name: Test undo
88-
run: |
89-
echo "=== Testing undo functionality ==="
90-
91-
# Undo the rename
92-
./target/release/refaktor undo latest
93-
94-
# Verify the undo worked
95-
if [ -f "smart-search-and-replace-core/Cargo.toml" ]; then
96-
echo "ERROR: smart-search-and-replace-core/Cargo.toml still exists!"
97-
exit 1
98-
fi
99-
100-
# The working directory should be clean after the undo
101-
if [ -n "$(git status --porcelain)" ]; then
102-
echo "ERROR: Working directory is not clean after undo!"
103-
git status
104-
git diff
105-
exit 1
106-
fi
107-
108-
echo "✓ Working directory is clean - undo successful!"
109-
shell: bash
110-
111-
- name: Test redo
112-
run: |
113-
echo "=== Testing redo functionality ==="
114-
115-
# Redo the rename
116-
./target/release/refaktor redo latest
117-
118-
# Verify no instances of "refaktor" remain in the codebase (case-insensitive)
119-
echo "Checking for remaining instances of 'refaktor'..."
120-
if rg -i "refaktor"; then
121-
echo "ERROR: Found remaining instances of 'refaktor' in the codebase!"
122-
exit 1
123-
fi
124-
echo "✓ No instances of 'refaktor' found"
125-
shell: bash
126-
127-
- name: Build smart_search_and_replace
128-
run: |
129-
rm -rf target
130-
cargo build --release
131-
./target/release/smart_search_and_replace --version
132-
133-
- name: Test smart_search_and_replace -> refaktor
134-
run: |
135-
echo "=== Testing smart_search_and_replace rename back to refaktor ==="
136-
137-
# Use smart_search_and_replace to rename itself back
138-
./target/release/smart_search_and_replace rename smart_search_and_replace refaktor --preview table
139-
140-
# Verify the rename worked
141-
if [ -f "smart-search-and-replace-core/Cargo.toml" ]; then
142-
echo "ERROR: smart-search-and-replace-core/Cargo.toml still exists!"
143-
exit 1
144-
fi
145-
if [ ! -f "refaktor-core/Cargo.toml" ]; then
146-
echo "ERROR: refaktor-core/Cargo.toml not found!"
147-
exit 1
148-
fi
149-
150-
# Verify no instances of "smart_search_and_replace" or "smart-search-and-replace" remain
151-
echo "Checking for remaining instances of 'smart_search_and_replace' or 'smart-search-and-replace'..."
152-
if rg "(smart_search_and_replace|smart-search-and-replace|smartsearchandreplace)"; then
153-
echo "ERROR: Found remaining instances of 'smart_search_and_replace' in the codebase!"
154-
exit 1
155-
fi
156-
echo "✓ No instances of 'smart_search_and_replace' found"
157-
158-
- name: Build refaktor again
159-
run: |
160-
# Clean and rebuild with original name
161-
rm -rf target
162-
cargo build --release
163-
164-
# Final verification
165-
./target/release/refaktor --version
166-
./target/release/refaktor --help
167-
shell: bash
168-
169-
- name: Verify git status is clean
170-
run: |
171-
# The working directory should be clean after the round-trip
172-
if [ -n "$(git status --porcelain)" ]; then
173-
echo "ERROR: Working directory is not clean after round-trip!"
174-
git status
175-
git diff
176-
exit 1
177-
fi
178-
echo "✓ Working directory is clean - round-trip successful!"
179-
shell: bash
50+
./scripts/e2e-test.sh

docs/src/content/docs/demo.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ different naming conventions.
4747
<br/>
4848

4949
:::note
50-
We have an end-to-end integration test that runs all these steps on CI.
50+
We have an end-to-end integration test that runs through all these steps on CI.
5151
:::
5252

5353
<LinkCard
54-
title=".github/workflows/e2e.yml"
55-
href="https://github.com/DocSpring/refaktor/blob/main/.github/workflows/e2e.yml"
56-
description="View the config for this GitHub Actions workflow"
54+
title="scripts/e2e-test.sh"
55+
href="https://github.com/DocSpring/refaktor/blob/main/scripts/e2e-test.sh"
56+
description="View the script we use in our GitHub Actions workflow"
5757
/>

scripts/e2e-test.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ -d /tmp/refaktor-e2e-test ]; then
5+
echo "Removing existing /tmp/refaktor-e2e-test"
6+
rm -rf /tmp/refaktor-e2e-test
7+
fi
8+
9+
echo "Cloning refaktor to /tmp/refaktor-e2e-test"
10+
git clone . /tmp/refaktor-e2e-test
11+
cd /tmp/refaktor-e2e-test
12+
13+
# For these tests, we want ripgrep to ignore the same files as refaktor
14+
cp .rfignore .rgignore
15+
echo .rgignore >> .git/info/exclude
16+
17+
cargo build --release
18+
./target/release/refaktor --version
19+
20+
echo "=== Testing refaktor rename to smart_search_and_replace ==="
21+
22+
# Use refaktor to rename itself using plan/apply
23+
./target/release/refaktor plan refaktor smart_search_and_replace --preview summary
24+
./target/release/refaktor apply
25+
26+
# Verify no instances of "refaktor" remain in the codebase (case-insensitive)
27+
echo "Checking for remaining instances of 'refaktor'..."
28+
if rg -i refaktor; then
29+
echo "ERROR: Found remaining instances of 'refaktor' in the codebase!"
30+
exit 1
31+
fi
32+
33+
# Verify the rename worked by checking key dirs / files
34+
if [ -d "refaktor-core" ]; then
35+
echo "ERROR: refaktor-core directory still exists!"
36+
exit 1
37+
fi
38+
if [ ! -f "smart-search-and-replace-core/Cargo.toml" ]; then
39+
echo "ERROR: smart-search-and-replace-core/Cargo.toml not found!"
40+
exit 1
41+
fi
42+
43+
echo "✓ No instances of 'refaktor' found"
44+
45+
46+
echo "=== Testing undo functionality ==="
47+
48+
# Undo the rename
49+
./target/release/refaktor undo latest
50+
51+
# Verify the undo worked
52+
if [ -f "smart-search-and-replace-core/Cargo.toml" ]; then
53+
echo "ERROR: smart-search-and-replace-core/Cargo.toml still exists!"
54+
exit 1
55+
fi
56+
57+
# The working directory should be clean after the undo
58+
if [ -n "$(git status --porcelain)" ]; then
59+
echo "ERROR: Working directory is not clean after undo!"
60+
git status
61+
git diff
62+
exit 1
63+
fi
64+
65+
echo "✓ Working directory is clean - undo successful!"
66+
67+
68+
echo "=== Testing redo functionality ==="
69+
70+
# Redo the rename
71+
./target/release/refaktor redo latest
72+
73+
# Verify no instances of "refaktor" remain in the codebase (case-insensitive)
74+
echo "Checking for remaining instances of 'refaktor'..."
75+
if rg -i "refaktor"; then
76+
echo "ERROR: Found remaining instances of 'refaktor' in the codebase!"
77+
exit 1
78+
fi
79+
echo "✓ No instances of 'refaktor' found"
80+
81+
rm -rf target
82+
cargo build --release
83+
./target/release/smart_search_and_replace --version
84+
85+
86+
echo "=== Testing smart_search_and_replace rename back to refaktor ==="
87+
88+
# Use smart_search_and_replace to rename itself back
89+
./target/release/smart_search_and_replace rename smart_search_and_replace refaktor --preview summary
90+
91+
# Verify the rename worked
92+
if [ -f "smart-search-and-replace-core/Cargo.toml" ]; then
93+
echo "ERROR: smart-search-and-replace-core/Cargo.toml still exists!"
94+
exit 1
95+
fi
96+
if [ ! -f "refaktor-core/Cargo.toml" ]; then
97+
echo "ERROR: refaktor-core/Cargo.toml not found!"
98+
exit 1
99+
fi
100+
101+
# Verify no instances of "smart_search_and_replace" or "smart-search-and-replace" remain
102+
echo "Checking for remaining instances of 'smart_search_and_replace' or 'smart-search-and-replace'..."
103+
if rg "(smart_search_and_replace|smart-search-and-replace|smartsearchandreplace)"; then
104+
echo "ERROR: Found remaining instances of 'smart_search_and_replace' in the codebase!"
105+
exit 1
106+
fi
107+
echo "✓ No instances of 'smart_search_and_replace' found"
108+
109+
# Clean and rebuild with original name
110+
rm -rf target
111+
cargo build --release
112+
113+
# Final verification
114+
./target/release/refaktor --version
115+
./target/release/refaktor --help
116+
117+
# The working directory should be clean after the round-trip
118+
if [ -n "$(git status --porcelain)" ]; then
119+
echo "ERROR: Working directory is not clean after round-trip!"
120+
git status
121+
git diff
122+
exit 1
123+
fi
124+
echo "✓ Working directory is clean - round-trip successful!"

0 commit comments

Comments
 (0)