Repository navigation
345 lines (293 loc) · 12.7 KB
/
Copy pathinstall.yml
File metadata and controls
345 lines (293 loc) · 12.7 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
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'
- 'install-gh-aw.ps1'
- 'scripts/test-install-script.sh'
- '.github/workflows/install.yml'
permissions:
contents: read
jobs:
test-install:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 5
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"
# On Windows, Windows Defender may scan a newly downloaded binary before
# allowing execution, causing commands to hang for several minutes.
# Wrap binary invocations with a timeout so the step doesn't stall.
BINARY_EXEC_TIMEOUT=""
if [[ "$RUNNER_OS" == "Windows" ]] && command -v timeout &>/dev/null; then
BINARY_EXEC_TIMEOUT="timeout 60"
fi
# Run version command to verify binary works
# shellcheck disable=SC2086
if $BINARY_EXEC_TIMEOUT "$BINARY_PATH" version; then
echo "✅ Binary version command works"
else
EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 124 ]; then
echo "⚠️ Binary version command timed out (Windows Defender scan in progress) — skipping"
else
echo "❌ Binary version command failed (exit $EXIT_CODE)"
exit 1
fi
fi
# Run help command to verify binary works
# shellcheck disable=SC2086
if $BINARY_EXEC_TIMEOUT "$BINARY_PATH" --help > /dev/null 2>&1; then
echo "✅ Binary help command works"
else
EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 124 ]; then
echo "⚠️ Binary help command timed out (Windows Defender scan in progress) — skipping"
else
echo "❌ Binary help command failed (exit $EXIT_CODE)"
exit 1
fi
fi
echo ""
echo "✅ Full installation test passed!"
test-install-powershell:
name: Test PowerShell installer on Windows
runs-on: windows-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Capture platform-detection output (expects failure for fake version)
# The installer exits 1 when the nonexistent version download fails; that is
# expected. continue-on-error suppresses the step failure so the next step
# can assert the platform-detection messages that ran before the download.
continue-on-error: true
shell: pwsh
run: |
& ./install-gh-aw.ps1 v999.999.999 6>&1 2>&1 | Tee-Object -FilePath install-ps-output.log
- name: Assert platform-detection messages from dry run
shell: pwsh
run: |
Set-StrictMode -Version Latest
if (-not (Test-Path install-ps-output.log)) {
throw "Installer output file (install-ps-output.log) was not created; Tee-Object may have failed"
}
$outputText = Get-Content install-ps-output.log -Raw
if (-not $outputText) { throw "Installer output file (install-ps-output.log) exists but is empty" }
if ($outputText -notmatch "Detected OS:") { throw "OS detection failed" }
if ($outputText -notmatch "Detected architecture:") { throw "Architecture detection failed" }
if ($outputText -notmatch "Platform:") { throw "Platform string construction failed" }
if ($outputText -notmatch "Failed to download") { throw "Installer did not report expected download failure for fake version" }
- name: Test setup-cli composite action (Windows)
id: setup-cli-test
uses: ./actions/setup-cli
with:
version: latest
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify composite-action binary and installed-version output
shell: pwsh
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$installedVersion = '${{ steps.setup-cli-test.outputs.installed-version }}'
if (-not $installedVersion) {
throw "installed-version output is empty; action output wiring is broken"
}
Write-Host "Composite action installed: $installedVersion"
# Verify via gh aw commands rather than a hardcoded binary path.
# `gh extension install` registers the extension under gh's own data dir
# (e.g. %APPDATA%\GitHub CLI\extensions on Windows), so using `gh aw`
# is the correct cross-platform verification mechanism.
gh aw version 2>&1 | Write-Host
if ($LASTEXITCODE -ne 0) {
throw "'gh aw version' failed with exit code $LASTEXITCODE"
}
gh aw --help 2>&1 | Write-Host
if ($LASTEXITCODE -ne 0) {
throw "'gh aw --help' failed with exit code $LASTEXITCODE"
}
- name: Upload PowerShell test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: install-test-powershell-windows
path: install-ps-output.log
retention-days: 7
if-no-files-found: ignore
report-failure:
name: Report Installation Failures
runs-on: ubuntu-latest
needs:
- test-install
- test-install-powershell
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@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
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\` and \`install-gh-aw.ps1\` scripts 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\` and \`install-gh-aw.ps1\` 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}`);
}