-
Notifications
You must be signed in to change notification settings - Fork 38
202 lines (176 loc) · 6.89 KB
/
automated_tests.yml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
name: "Automated Tests"
on:
workflow_dispatch:
push:
paths:
- ".github/workflows/automated_tests.yml"
- ".github/actions/**"
- "dotfiles/**"
- "pyproject.toml"
- "uv.lock"
branches:
- master
- main
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- ".github/workflows/automated_tests.yml"
- ".github/actions/**"
- "dotfiles/**"
- "pyproject.toml"
- "uv.lock"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test-dotfiles:
# runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest"]
runs-on: ${{ matrix.os }}
steps:
# - name: Install APT dependencies
# if: startsWith(matrix.os, 'ubuntu')
# run: |
# apt-get update
# apt-get install -y git zsh
- name: Checkout repository
uses: actions/checkout@v4
- name: Copy repository to /home/runner/
run: |
if [ -d /home/runner ]; then homedir="/home/runner"; else homedir="/Users/runner"; fi
mkdir -p ${homedir}/.local/share/chezmoi
cp -a . ${homedir}/.local/share/chezmoi
# ----------------------------------------------
# Create config file
# ----------------------------------------------
- name: Create config file
run: |
if [ -d /home/runner ]; then homedir="/home/runner"; else homedir="/Users/runner"; fi
mkdir -p ${homedir}/.config/chezmoi
cat > ${homedir}/.config/chezmoi/chezmoi.toml<< EOF
[data]
dev_computer = false
email = "[email protected]"
github_user = "natelandau"
homelab_member = false
is_ci_workflow = true # Set true only in CI test
personal_computer = false
use_secrets = false
xdgCacheDir = "${homedir}/.cache"
xdgConfigDir = "${homedir}/.config"
xdgDataDir = "${homedir}/.local/share"
xdgStateDir = "${homedir}/.local/state"
EOF
# ----------------------------------------------
# Install chezmoi
# ----------------------------------------------
- name: Install chezmoi
run: |
sh -c "$(curl -fsLS get.chezmoi.io)"
# ----------------------------------------------
# Run chezmoi apply
# ----------------------------------------------
- name: Run chezmoi apply
run: |
./bin/chezmoi apply
# ----------------------------------------------
# UBUNTU: Confirm dotfiles are installed
# ----------------------------------------------
- name: Confirm dotfiles are installed
if: startsWith(matrix.os, 'ubuntu')
run: |
if [ -d /home/runner ]; then homedir="/home/runner"; else homedir="/Users/runner"; fi
echo "------- Testing files -------"
cd /home/runner
# echo "pwd: $(pwd)"
# ls -al
existing_files=(
.zshrc
.bashrc
.config/git/config
.ssh/config
.config/dotfile_source/080-linux.sh
.local/share/sed/stopwords.sed
)
missing_files=(
.config/dotfile_source/080-macos.sh
Library
)
installed_packages=(
jq
pygmentize
)
# Confirm files exist
for file in ${existing_files[@]}; do
if [ ! -e "${homedir}/$file" ]; then
echo "$file not found"
exit 1
fi
done
# Confirm files don't exist
for file in ${missing_files[@]} ; do
if [ -e "${homedir}/$file "]; then
echo "$file found"
exit 1
fi
done
# Confirm packages are installed
for package in ${installed_packages[@]}; do
if [ ! $(command -v $package) ]; then
echo "$package not found"
exit 1
fi
done
# ----------------------------------------------
# MACOS: Confirm dotfiles are installed
# ----------------------------------------------
- name: Confirm dotfiles are installed
if: startsWith(matrix.os, 'macos')
run: |
if [ -d /home/runner ]; then homedir="/home/runner"; else homedir="/Users/runner"; fi
echo "------- Testing files -------"
cd ${homedir}
existing_files=(
.zshrc
.bashrc
.config/git/config
.config/nano/nanorc
.ssh/config
.config/dotfile_source/080-macos.sh
.local/share/sed/stopwords.sed
)
missing_files=(
.config/dotfile_source/080-linux.sh
)
installed_packages=(
jq
pygmentize
)
# Confirm files exist
for file in ${existing_files[@]}; do
if [ ! -e "${homedir}/$file" ]; then
echo "$file not found"
exit 1
fi
done
# Confirm files don't exist
for file in ${missing_files[@]} ; do
if [ -e "${homedir}/$file" ]; then
echo "$file found"
exit 1
fi
done
# Confirm packages are installed
for package in ${installed_packages[@]}; do
if [ ! $(command -v $package) ]; then
echo "$package not found"
exit 1
fi
done