Skip to content

Commit af0276d

Browse files
committed
refactor: add test.sh and workflow to test dotfiles setup
1 parent fb8bc70 commit af0276d

File tree

4 files changed

+597
-6
lines changed

4 files changed

+597
-6
lines changed

.config/gh-dash/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
prSections:
22
- title: Opened
3-
filters: is:open
3+
filters: is:open is:pr involves:@me -author:@me
44
- title: Mine
55
filters: is:open is:pr author:@me
66
layout:
@@ -11,8 +11,6 @@ prSections:
1111
layout:
1212
repo:
1313
width: 6
14-
- title: Involved
15-
filters: is:open involves:@me -author:@me
1614
issuesSections:
1715
- title: My Issues
1816
filters: is:open author:@me

.config/install.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ install_homebrew() {
136136
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
137137

138138
# Add to shell profiles
139+
# shellcheck disable=SC2016
139140
if ! grep -q "linuxbrew" "$HOME/.profile" 2>/dev/null; then
140141
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> "$HOME/.profile"
141142
fi
142143

143144
if [ -f "$HOME/.zshrc" ]; then
145+
# shellcheck disable=SC2016
144146
if ! grep -q "linuxbrew" "$HOME/.zshrc"; then
145147
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> "$HOME/.zshrc"
146148
fi
@@ -279,12 +281,15 @@ stow_dotfiles() {
279281
print_header "Stowing dotfiles..."
280282

281283
# Navigate to parent of dotfiles directory to run stow
282-
local parent_dir="$(dirname "$DOTFILES")"
283-
local dotfiles_name="$(basename "$DOTFILES")"
284+
local parent_dir
285+
local dotfiles_name
286+
parent_dir="$(dirname "$DOTFILES")"
287+
dotfiles_name="$(basename "$DOTFILES")"
284288
cd "$parent_dir"
285289

286290
# Backup existing dotfiles that might conflict
287-
local backup_dir="$HOME/.dotfiles-backup-$(date +%Y%m%d-%H%M%S)"
291+
local backup_dir
292+
backup_dir="$HOME/.dotfiles-backup-$(date +%Y%m%d-%H%M%S)"
288293
local needs_backup=false
289294

290295
# Common dotfiles that might exist and aren't symlinks

.github/workflows/test.yml

Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
name: Test Dotfiles
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
workflow_dispatch:
9+
10+
jobs:
11+
syntax-validation:
12+
name: Syntax Validation
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Install validation tools
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y shellcheck zsh yamllint
22+
23+
# Install taplo for TOML validation
24+
curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-linux-x86_64.gz | gunzip -c > /tmp/taplo
25+
sudo install -m 755 /tmp/taplo /usr/local/bin/taplo
26+
27+
- name: Run syntax validation
28+
run: |
29+
chmod +x ./test.sh
30+
./test.sh
31+
32+
test-macos:
33+
name: Test on macOS
34+
runs-on: macos-latest
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Run install script
40+
run: |
41+
# Run install script in non-interactive mode with --no-gui
42+
bash .config/install.sh --no-gui
43+
env:
44+
CI: true
45+
NONINTERACTIVE: 1
46+
47+
- name: Debug stow results
48+
run: |
49+
echo "=== Checking dotfiles in home directory ==="
50+
ls -la ~/ | grep -E "^l.*\." || echo "No symlinks found"
51+
echo ""
52+
echo "=== Checking specific dotfiles ==="
53+
for file in .zshrc .zshenv .gitconfig; do
54+
if [ -L ~/$file ]; then
55+
echo "✓ ~/$file is a symlink -> $(readlink ~/$file)"
56+
elif [ -e ~/$file ]; then
57+
echo "✗ ~/$file exists but is not a symlink"
58+
else
59+
echo "✗ ~/$file does not exist"
60+
fi
61+
done
62+
63+
- name: Verify Homebrew environment
64+
run: |
65+
if [ -d "/opt/homebrew" ]; then
66+
eval "$(/opt/homebrew/bin/brew shellenv)"
67+
else
68+
eval "$(/usr/local/bin/brew shellenv)"
69+
fi
70+
echo "Homebrew prefix: $(brew --prefix)"
71+
echo "PATH: $PATH"
72+
73+
- name: Verify zsh configuration loads
74+
run: |
75+
# Source Homebrew environment first
76+
if [ -d "/opt/homebrew" ]; then
77+
eval "$(/opt/homebrew/bin/brew shellenv)"
78+
else
79+
eval "$(/usr/local/bin/brew shellenv)"
80+
fi
81+
82+
# Try to load zsh config
83+
if [ -f ~/.zshrc ]; then
84+
zsh -c "source ~/.zshenv 2>/dev/null; source ~/.zshrc && echo 'zsh config loaded successfully'" || echo "zsh config has errors but continuing"
85+
else
86+
echo "~/.zshrc not found"
87+
exit 1
88+
fi
89+
90+
- name: Verify git configuration
91+
run: |
92+
if [ -L ~/.gitconfig ]; then
93+
echo "✓ .gitconfig is a symlink"
94+
else
95+
echo "✗ .gitconfig is not a symlink"
96+
ls -la ~/.gitconfig || echo "✗ .gitconfig does not exist"
97+
exit 1
98+
fi
99+
100+
echo "Git aliases:"
101+
git config --list | grep "^alias\." | head -5 || echo "No git aliases found"
102+
103+
if git config --list | grep -q "alias\.d=diff"; then
104+
echo "✓ git alias 'd' configured correctly"
105+
else
106+
echo "✗ git alias 'd' not found"
107+
exit 1
108+
fi
109+
110+
- name: Verify tmux configuration exists
111+
run: |
112+
if [ -d "/opt/homebrew" ]; then
113+
eval "$(/opt/homebrew/bin/brew shellenv)"
114+
else
115+
eval "$(/usr/local/bin/brew shellenv)"
116+
fi
117+
118+
if [ -L ~/.config/tmux ]; then
119+
echo "✓ .config/tmux is a symlink"
120+
ls -la ~/.config/tmux/tmux.conf || echo "tmux.conf not found"
121+
else
122+
echo "Note: .config/tmux may not be symlinked yet"
123+
fi
124+
125+
- name: List installed tools
126+
run: |
127+
if [ -d "/opt/homebrew" ]; then
128+
eval "$(/opt/homebrew/bin/brew shellenv)"
129+
else
130+
eval "$(/usr/local/bin/brew shellenv)"
131+
fi
132+
133+
echo "=== Installed CLI Tools ==="
134+
for cmd in zsh git stow fzf rg fd bat eza starship gh yazi; do
135+
if command -v $cmd >/dev/null 2>&1; then
136+
version=$($cmd --version 2>&1 | head -1 || echo "version unknown")
137+
echo "✓ $cmd: $version"
138+
else
139+
echo "✗ $cmd: not installed"
140+
fi
141+
done
142+
143+
test-ubuntu:
144+
name: Test on Ubuntu
145+
runs-on: ubuntu-latest
146+
steps:
147+
- name: Checkout repository
148+
uses: actions/checkout@v4
149+
150+
- name: Run install script
151+
run: |
152+
# Run install script in non-interactive mode with --no-gui
153+
bash .config/install.sh --no-gui
154+
env:
155+
CI: true
156+
NONINTERACTIVE: 1
157+
158+
- name: Debug stow results
159+
run: |
160+
echo "=== Checking dotfiles in home directory ==="
161+
ls -la ~/ | grep -E "^l.*\." || echo "No symlinks found"
162+
echo ""
163+
echo "=== Checking specific dotfiles ==="
164+
for file in .zshrc .zshenv .gitconfig; do
165+
if [ -L ~/$file ]; then
166+
echo "✓ ~/$file is a symlink -> $(readlink ~/$file)"
167+
elif [ -e ~/$file ]; then
168+
echo "✗ ~/$file exists but is not a symlink"
169+
else
170+
echo "✗ ~/$file does not exist"
171+
fi
172+
done
173+
174+
- name: Verify Homebrew environment
175+
run: |
176+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
177+
echo "Homebrew prefix: $(brew --prefix)"
178+
echo "PATH: $PATH"
179+
180+
- name: Verify zsh configuration loads
181+
run: |
182+
# Source Homebrew environment first
183+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
184+
185+
# Try to load zsh config
186+
if [ -f ~/.zshrc ]; then
187+
zsh -c "source ~/.zshenv 2>/dev/null; source ~/.zshrc && echo 'zsh config loaded successfully'" || echo "zsh config has errors but continuing"
188+
else
189+
echo "~/.zshrc not found"
190+
exit 1
191+
fi
192+
193+
- name: Verify git configuration
194+
run: |
195+
if [ -L ~/.gitconfig ]; then
196+
echo "✓ .gitconfig is a symlink"
197+
else
198+
echo "✗ .gitconfig is not a symlink"
199+
ls -la ~/.gitconfig || echo "✗ .gitconfig does not exist"
200+
exit 1
201+
fi
202+
203+
echo "Git aliases:"
204+
git config --list | grep "^alias\." | head -5 || echo "No git aliases found"
205+
206+
if git config --list | grep -q "alias\.d=diff"; then
207+
echo "✓ git alias 'd' configured correctly"
208+
else
209+
echo "✗ git alias 'd' not found"
210+
exit 1
211+
fi
212+
213+
- name: List installed tools
214+
run: |
215+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
216+
217+
echo "=== Installed CLI Tools ==="
218+
for cmd in zsh git stow fzf rg fd bat eza starship gh yazi; do
219+
if command -v $cmd >/dev/null 2>&1; then
220+
version=$($cmd --version 2>&1 | head -1 || echo "version unknown")
221+
echo "✓ $cmd: $version"
222+
else
223+
echo "✗ $cmd: not installed"
224+
fi
225+
done
226+
227+
test-stow-structure:
228+
name: Test Stow Structure
229+
runs-on: ubuntu-latest
230+
steps:
231+
- name: Checkout repository
232+
uses: actions/checkout@v4
233+
234+
- name: Install stow
235+
run: sudo apt-get update && sudo apt-get install -y stow
236+
237+
- name: Verify .stowrc exists
238+
run: |
239+
if [ -f .stowrc ]; then
240+
echo "✓ .stowrc found"
241+
cat .stowrc
242+
else
243+
echo "✗ .stowrc not found"
244+
exit 1
245+
fi
246+
247+
- name: Verify .stow-local-ignore exists
248+
run: |
249+
if [ -f .stow-local-ignore ]; then
250+
echo "✓ .stow-local-ignore found"
251+
echo "Ignored patterns:"
252+
head -10 .stow-local-ignore
253+
else
254+
echo "✗ .stow-local-ignore not found"
255+
exit 1
256+
fi
257+
258+
- name: Test stow dry-run from parent directory
259+
run: |
260+
cd ..
261+
echo "Testing stow operations (dry-run) from parent directory..."
262+
stow -n -v dotfiles 2>&1 | tee stow-output.log
263+
264+
# Check for conflicts
265+
if grep -i "conflict" stow-output.log; then
266+
echo "⚠️ Stow conflicts detected"
267+
cat stow-output.log
268+
exit 1
269+
else
270+
echo "✓ No stow conflicts detected"
271+
fi
272+
273+
- name: Test actual stow
274+
run: |
275+
cd ..
276+
# Actually create symlinks
277+
stow -v dotfiles
278+
279+
# Verify symlinks were created
280+
echo "=== Verifying symlinks ==="
281+
[ -L ~/.zshrc ] && echo "✓ .zshrc symlinked" || echo "✗ .zshrc not symlinked"
282+
[ -L ~/.zshenv ] && echo "✓ .zshenv symlinked" || echo "✗ .zshenv not symlinked"
283+
[ -L ~/.gitconfig ] && echo "✓ .gitconfig symlinked" || echo "✗ .gitconfig not symlinked"
284+
285+
# Check .config directory
286+
if [ -L ~/.config ] || [ -d ~/.config ]; then
287+
echo "✓ .config exists"
288+
ls -la ~/.config/ | head -10
289+
else
290+
echo "✗ .config not found"
291+
fi
292+
293+
- name: Verify stow respects .stow-local-ignore
294+
run: |
295+
# These should NOT be symlinked
296+
if [ -L ~/.git ] || [ -e ~/.git ]; then
297+
echo "✗ .git was stowed (should be ignored)"
298+
exit 1
299+
else
300+
echo "✓ .git correctly ignored"
301+
fi
302+
303+
if [ -L ~/README.md ] || [ -e ~/README.md ]; then
304+
echo "✗ README.md was stowed (should be ignored)"
305+
exit 1
306+
else
307+
echo "✓ README.md correctly ignored"
308+
fi

0 commit comments

Comments
 (0)