-
Notifications
You must be signed in to change notification settings - Fork 38
134 lines (118 loc) · 4.82 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
---
name: "Automated Tests"
on:
workflow_dispatch:
push:
paths:
- ".github/workflows/automated-tests.yml"
- ".github/actions/**"
- "dotfiles/**"
branches:
- master
- main
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- ".github/workflows/automated-tests.yml"
- ".github/actions/**"
- "dotfiles/**"
concurrency:
group: ${{ github.workflow }}-${{ 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
# ----------------------------------------------
# Checkout repository
# ----------------------------------------------
- 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
echo '[data]' > ${homedir}/.config/chezmoi/chezmoi.toml
echo ' email = "[email protected]"' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' github_user = "natelandau"' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' home_network = false' >> ${homedir}/.config/chezmoi/chezmoi.toml
echo ' use_secrets = false' >> ${homedir}/.config/chezmoi/chezmoi.toml
# ----------------------------------------------
# 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: |
echo "------- Testing files -------"
cd /home/runner
# echo "pwd: $(pwd)"
# ls -al
# Confirm files exist
for file in .zshrc .bashrc .gitconfig .shell .ssh/config .shell/sourced/080-linux.sh; do
if [ ! -e $file ]; then
echo "$file not found"
exit 1
fi
done
# Confirm files don't exist
for file in Library .shell/sourced/080-macos.sh; do
if [ -e $file ]; then
echo "$file found"
exit 1
fi
done
# ----------------------------------------------
# MACOS: Confirm dotfiles are installed
# ----------------------------------------------
- name: Confirm dotfiles are installed
if: startsWith(matrix.os, 'macos')
run: |
echo "------- Testing files -------"
cd /Users/runner
# Confirm files exist
for file in .zshrc .bashrc .gitconfig .shell .ssh/config Library .shell/sourced/080-macos.sh; do
if [ ! -e $file ]; then
echo "$file not found"
exit 1
fi
done
# Confirm files don't exist
for file in .shell/sourced/080-linux.sh; do
if [ -e $file ]; then
echo "$file found"
exit 1
fi
done