-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (122 loc) · 5.16 KB
/
Copy pathci.yml
File metadata and controls
131 lines (122 loc) · 5.16 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
name: CI
on:
push:
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
linux:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@1.89.0
with:
components: clippy,rustfmt
- name: Install cargo-audit 0.22.2
run: cargo install cargo-audit --version '=0.22.2' --locked --no-default-features
- name: Audit Rust dependencies
run: cargo audit --deny warnings
- run: cargo fmt --check
- run: cargo clippy --all-targets --locked -- -D warnings
- run: cargo test --locked
- run: cargo build --release --locked
windows:
runs-on: windows-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Validate PowerShell installer syntax
shell: pwsh
run: |
$tokens = $null
$errors = $null
foreach ($script in @("./bootstrap.ps1", "./install-windows.ps1")) {
$errors = $null
[void][System.Management.Automation.Language.Parser]::ParseFile(
(Resolve-Path $script),
[ref]$tokens,
[ref]$errors
)
if ($errors.Count -gt 0) {
$errors | Format-List | Out-String | Write-Error
exit 1
}
}
- name: Test bootstrap JSONC and migration fixtures
shell: pwsh
run: ./tests/bootstrap.Tests.ps1
- name: Test bootstrap uninstall
shell: pwsh
run: |
$testRoot = Join-Path $env:RUNNER_TEMP "bootstrap-uninstall-test"
$env:LOCALAPPDATA = Join-Path $testRoot "LocalAppData"
$env:APPDATA = Join-Path $testRoot "AppData"
$installDir = Join-Path $env:LOCALAPPDATA "Programs\OpenCodeSSHImagePaste"
$configDir = Join-Path $env:APPDATA "OpenCodeSSHImagePaste"
$terminalDir = Join-Path $env:LOCALAPPDATA "Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState"
$terminalSettings = Join-Path $terminalDir "settings.json"
try {
New-Item -ItemType Directory -Force -Path $installDir, $configDir, $terminalDir | Out-Null
Set-Content -Path (Join-Path $installDir "opencode-ssh-image-paste.exe") -Value "test"
Set-Content -Path (Join-Path $configDir "config.toml") -Value "test = true"
@(
'{',
' "actions": [',
' {',
' "command": {"action":"sendInput","input":"latest.png"},',
' "id": "User.OpenCodeSSHImagePaste.AtomicPaste"',
' },',
' {"command":"copy","id":"User.KeepThisAction"}',
' ],',
' "keybindings": [',
' {',
' "keys": "ctrl+alt+shift+f24",',
' "id": "User.OpenCodeSSHImagePaste.AtomicPaste"',
' }',
' ]',
'}'
) | Set-Content -Path $terminalSettings
Set-Content -Path "$terminalSettings.opencode-ssh-image-paste.backup" -Value "backup"
& ./bootstrap.ps1 -Uninstall
if (Test-Path $installDir) { throw "Uninstall did not remove the install directory." }
if (Test-Path $configDir) { throw "Uninstall did not remove the config directory." }
if ((Get-Content -Raw $terminalSettings) -match "OpenCodeSSHImagePaste") {
throw "Uninstall did not remove the Windows Terminal action."
}
if ((Get-Content -Raw $terminalSettings) -notmatch "User.KeepThisAction") {
throw "Uninstall removed an unrelated Windows Terminal action."
}
try {
Get-Content -Raw $terminalSettings | ConvertFrom-Json | Out-Null
} catch {
throw "Uninstall left invalid Windows Terminal JSON: $_"
}
if (Test-Path "$terminalSettings.opencode-ssh-image-paste.backup") {
throw "Uninstall did not remove the Windows Terminal settings backup."
}
New-Item -ItemType Directory -Force -Path $installDir, $configDir | Out-Null
Set-Content -Path (Join-Path $installDir "opencode-ssh-image-paste.exe") -Value "test"
Set-Content -Path (Join-Path $configDir "config.toml") -Value "test = true"
& ./bootstrap.ps1 -Uninstall -KeepConfig
if (Test-Path $installDir) { throw "Uninstall did not remove the install directory." }
if (-not (Test-Path (Join-Path $configDir "config.toml"))) {
throw "-KeepConfig did not preserve the configuration."
}
} finally {
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $testRoot
}
- uses: dtolnay/rust-toolchain@1.89.0
with:
components: clippy,rustfmt
- run: cargo check --tests --locked
- run: cargo clippy --all-targets --locked -- -D warnings
- run: cargo test --locked
- run: cargo build --release --locked