-
Notifications
You must be signed in to change notification settings - Fork 326
246 lines (204 loc) · 8.25 KB
/
install.yml
File metadata and controls
246 lines (204 loc) · 8.25 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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: Install Script Test
on:
schedule:
# Run daily at 6:00 AM UTC
- cron: '0 6 * * *'
workflow_dispatch:
pull_request:
paths:
- 'install-gh-aw.sh'
- 'scripts/test-install-script.sh'
- '.github/workflows/install.yml'
permissions:
contents: read
jobs:
test-install:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-22.04
- macos-latest
- windows-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Test install script detection logic
shell: bash
run: |
chmod +x scripts/test-install-script.sh
./scripts/test-install-script.sh
- name: Test install script (dry run - check platform detection)
shell: bash
run: |
chmod +x install-gh-aw.sh
# Extract just the platform detection part without actually downloading
OS=$(uname -s)
ARCH=$(uname -m)
echo "Testing platform detection:"
echo " OS: $OS"
echo " ARCH: $ARCH"
# Run the script but capture the output before it tries to download
# We'll use a fake version to test URL construction
set +e
# Cross-platform timeout implementation
if command -v timeout > /dev/null 2>&1; then
# Linux has timeout command
timeout 10s ./install-gh-aw.sh v999.999.999 2>&1 | tee install-output.log || true
else
# macOS and others - use Perl-based timeout (available by default on macOS)
perl -e 'alarm shift; exec @ARGV' 10 ./install-gh-aw.sh v999.999.999 2>&1 | tee install-output.log || true
fi
set -e
# Verify platform was detected
if grep -q "Detected OS:" install-output.log; then
echo "✅ OS detection working"
else
echo "❌ OS detection failed"
cat install-output.log
exit 1
fi
if grep -q "Detected architecture:" install-output.log; then
echo "✅ Architecture detection working"
else
echo "❌ Architecture detection failed"
cat install-output.log
exit 1
fi
if grep -q "Platform:" install-output.log; then
echo "✅ Platform string constructed"
else
echo "❌ Platform string construction failed"
cat install-output.log
exit 1
fi
echo ""
echo "Platform detection results:"
grep "Detected OS:" install-output.log || true
grep "Detected architecture:" install-output.log || true
grep "Platform:" install-output.log || true
- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: install-test-${{ matrix.os }}
path: install-output.log
retention-days: 7
if-no-files-found: ignore
- name: Test full install script (without dummy version)
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x install-gh-aw.sh
# Run the full installation script without version to get latest release
echo "Running full installation script to test complete flow..."
./install-gh-aw.sh
# Verify the installation worked
INSTALL_DIR="$HOME/.local/share/gh/extensions/gh-aw"
# Determine expected binary name based on OS
if [[ "$RUNNER_OS" == "Windows" ]]; then
BINARY_NAME="gh-aw.exe"
else
BINARY_NAME="gh-aw"
fi
BINARY_PATH="$INSTALL_DIR/$BINARY_NAME"
# Check if binary exists
if [ ! -f "$BINARY_PATH" ]; then
echo "❌ Binary not found at $BINARY_PATH"
exit 1
fi
echo "✅ Binary found at $BINARY_PATH"
# Check if binary is executable
if [ ! -x "$BINARY_PATH" ]; then
echo "❌ Binary is not executable"
exit 1
fi
echo "✅ Binary is executable"
# Run version command to verify binary works
if "$BINARY_PATH" version; then
echo "✅ Binary version command works"
else
echo "❌ Binary version command failed"
exit 1
fi
# Run help command to verify binary works
if "$BINARY_PATH" --help > /dev/null 2>&1; then
echo "✅ Binary help command works"
else
echo "❌ Binary help command failed"
exit 1
fi
echo ""
echo "✅ Full installation test passed!"
report-failure:
name: Report Installation Failures
runs-on: ubuntu-latest
needs: test-install
if: failure()
permissions:
issues: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Create issue on failure
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const workflowUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const title = '🚨 Install Script Test Failed';
const body = `The install script test workflow failed.
**Workflow Run:** ${workflowUrl}
**Triggered by:** ${context.eventName}
**Commit:** ${context.sha.substring(0, 7)}
## Details
The install script testing workflow detected failures when testing the \`install-gh-aw.sh\` script across different platforms.
Please review the workflow logs to identify which platform(s) failed and investigate the issue.
## Affected Platforms
This workflow tests the install script on:
- Ubuntu (latest and 22.04)
- macOS (latest ARM and Intel-based 13)
- Windows (latest)
## Next Steps
1. Check the [workflow run logs](${workflowUrl}) for detailed error messages
2. Review changes to \`install-gh-aw.sh\` that may have caused the failure
3. Test the install script locally on the affected platform(s)
4. Fix the issue and verify with \`scripts/test-install-script.sh\`
---
*This issue was automatically created by the install script test workflow.*`;
// Check if there's already an open issue
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'install-script,automated',
per_page: 10
});
const existingIssue = issues.data.find(issue =>
issue.title === title
);
if (existingIssue) {
// Add a comment to existing issue
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: `Another failure detected:\n\n${body}`
});
console.log(`Added comment to existing issue #${existingIssue.number}`);
} else {
// Create new issue
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['bug', 'install-script', 'automated']
});
console.log(`Created new issue #${issue.data.number}`);
}