-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (97 loc) · 3.55 KB
/
ci.yml
File metadata and controls
113 lines (97 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install shellcheck and zsh
run: |
sudo apt-get update
sudo apt-get install -y shellcheck zsh
- name: Install chezmoi
run: sh -c "$(curl -fsLS get.chezmoi.io)" -- -b /usr/local/bin
- name: Render chezmoi templates and run shellcheck
run: |
rendered_dir="$(mktemp -d)"
# Render *.tmpl run scripts so shellcheck can parse them
for tmpl in run_*.sh.tmpl; do
[ -f "$tmpl" ] || continue
out="$rendered_dir/$(basename "${tmpl%.tmpl}")"
chezmoi execute-template --source="$PWD" < "$tmpl" > "$out"
done
# shellcheck does not support zsh; filter zsh-shebanged scripts and
# the vendored fzf-git.sh out of the target set.
targets=()
while IFS= read -r -d '' f; do
case "$f" in
*/dot_zsh/functions/fzf-git.sh) continue ;;
esac
if head -n1 "$f" | grep -qE '^#!.*\bzsh\b'; then
continue
fi
targets+=("$f")
done < <(
find . -type f -name "*.sh" -not -path "./.git/*" -print0
find "$rendered_dir" -type f -name "*.sh" -print0
)
if [ ${#targets[@]} -gt 0 ]; then
shellcheck "${targets[@]}"
else
echo "No shellcheck-eligible scripts in repo (all .sh files are zsh)."
fi
- name: Check zsh syntax
run: |
find . -type f \( -name "*.zsh" -o -name "dot_zshrc" -o -name "executable_*" \) -not -path "./.git/*" -print0 \
| while IFS= read -r -d '' file; do
zsh -n "$file" || exit 1
done
chezmoi-verify:
name: chezmoi verify
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install chezmoi
run: sh -c "$(curl -fsLS get.chezmoi.io)" -- -b /usr/local/bin
- name: chezmoi doctor
run: chezmoi --source="$GITHUB_WORKSPACE" doctor || true
- name: Apply to ephemeral HOME and verify rendered files
run: |
export HOME="$(mktemp -d)"
export CI=1
export XDG_CACHE_HOME="$HOME/.cache"
chezmoi init --apply --source="$GITHUB_WORKSPACE"
test -f "$HOME/.zshrc"
test -f "$HOME/.config/mise/config.toml"
test -f "$HOME/.config/ghostty/config"
test -f "$HOME/.hammerspoon/init.lua"
test -f "$HOME/Library/Application Support/Code/User/settings.json"
test -x "$HOME/.zsh/bin/reload"
grep -F 'idiomatic_version_file_enable_tools = ["ruby"]' "$HOME/.config/mise/config.toml"
grep -F 'appName = "Ghostty"' "$HOME/.hammerspoon/init.lua"
chezmoi verify --source="$GITHUB_WORKSPACE"
- name: Idempotency check
run: |
export HOME="$(mktemp -d)"
export CI=1
export XDG_CACHE_HOME="$HOME/.cache"
chezmoi init --apply --source="$GITHUB_WORKSPACE"
chezmoi apply --source="$GITHUB_WORKSPACE"
status_output="$(chezmoi status --source="$GITHUB_WORKSPACE")"
if [ -n "$status_output" ]; then
echo "::error::chezmoi status is non-empty after re-apply"
echo "$status_output"
exit 1
fi
diff_output="$(chezmoi diff --source="$GITHUB_WORKSPACE")"
if [ -n "$diff_output" ]; then
echo "::error::chezmoi diff is non-empty after re-apply"
echo "$diff_output"
exit 1
fi
chezmoi verify --source="$GITHUB_WORKSPACE"