-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-general-dotfiles-setup.yml
More file actions
103 lines (85 loc) · 3.77 KB
/
Copy pathtest-general-dotfiles-setup.yml
File metadata and controls
103 lines (85 loc) · 3.77 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
name: Test General Dotfiles Setup (Pre-OS Installation)
on:
push:
branches: [ main ]
paths:
- '**/*.sh'
- '.github/workflows/*.yml'
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install shellcheck
run: sudo apt-get install -y shellcheck
- name: Run shellcheck setup.sh
run: shellcheck -x setup.sh
test-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Make script executable
run: chmod +x setup.sh
- name: Validate setup script
run: |
# Create a modified version of the script for testing
cp setup.sh setup-test.sh
# Modify the script to avoid actual installations and system changes
sed -i 's/sudo apt/echo "Would run apt:"/g' setup-test.sh
sed -i 's/sudo pacman/echo "Would run pacman:"/g' setup-test.sh
sed -i 's/sudo dnf/echo "Would run dnf:"/g' setup-test.sh
sed -i 's/brew install/echo "Would brew install:"/g' setup-test.sh
# Mock the GitHub CLI token retrieval
sed -i 's/GITHUB_TOKEN=$(gh auth token)/GITHUB_TOKEN="mock-github-token"/g' setup-test.sh
# Run the modified script by sourcing it as required and capture output
echo "Running setup script test..."
if source setup-test.sh 2>&1 | tee setup-output.log; then
echo "✅ Setup script ran without fatal errors"
else
echo "❌ Setup script encountered fatal errors"
cat setup-output.log
exit 1
fi
# Check if the success message appears in the output
if grep -q "Dotfiles setup complete" setup-output.log; then
echo "✅ Setup script validation passed - found success message"
else
echo "⚠️ Setup script completed but success message not found (this may be expected in test environment)"
echo "Script output:"
cat setup-output.log
fi
test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Make script executable
run: chmod +x setup.sh
- name: Validate setup script
run: |
# Create a modified version of the script for testing
cp setup.sh setup-test.sh
# Modify the script to avoid actual installations and system changes
sed -i '' 's/sudo apt/echo "Would run apt:"/g' setup-test.sh
sed -i '' 's/sudo pacman/echo "Would run pacman:"/g' setup-test.sh
sed -i '' 's/sudo dnf/echo "Would run dnf:"/g' setup-test.sh
sed -i '' 's/brew install/echo "Would brew install:"/g' setup-test.sh
# Mock the GitHub CLI token retrieval
sed -i '' 's/GITHUB_TOKEN=$(gh auth token)/GITHUB_TOKEN="mock-github-token"/g' setup-test.sh
# Run the modified script by sourcing it as required and capture output
echo "Running setup script test..."
if source setup-test.sh 2>&1 | tee setup-output.log; then
echo "✅ Setup script ran without fatal errors"
else
echo "❌ Setup script encountered fatal errors"
cat setup-output.log
exit 1
fi
# Check if the success message appears in the output
if grep -q "Dotfiles setup complete" setup-output.log; then
echo "✅ Setup script validation passed - found success message"
else
echo "⚠️ Setup script completed but success message not found (this may be expected in test environment)"
echo "Script output:"
cat setup-output.log
fi