-
Notifications
You must be signed in to change notification settings - Fork 1
350 lines (288 loc) · 9.59 KB
/
Copy pathci.yml
File metadata and controls
350 lines (288 loc) · 9.59 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
346
347
348
349
350
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
lint:
name: Lint (Rust)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.90.0
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings -A clippy::pedantic -A clippy::nursery
- name: Check documentation
run: cargo doc --no-deps --document-private-items --all-features
lint-powershell:
name: Lint (PowerShell)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Run PSScriptAnalyzer
run: .\tests\Lint.ps1
shell: pwsh
lint-shell-format:
name: Shell Script Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check shell script formatting
run: |
make fmt-shell
if ! git diff --exit-code spec/; then
echo "Shell scripts have formatting issues. Run 'make fmt-shell' locally."
git diff spec/
exit 1
fi
echo "All shell scripts are properly formatted"
lint-shell:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: './spec'
severity: info
lint-yaml:
name: yamllint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install yamllint
run: pip install yamllint
- name: Run yamllint
run: make lint-yaml
test-rust:
name: Rust Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [1.90.0]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.rust }}-cargo-
${{ runner.os }}-cargo-
- name: Build
run: cargo build --verbose
- name: Run unit tests
run: cargo test --verbose
- name: Run integration tests
run: cargo test --verbose --test '*'
- name: Build release
run: cargo build --release
- name: Upload Linux release binary (for other jobs)
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: rb-linux-release
path: target/release/rb
retention-days: 1
docker-build:
name: Build and Push Docker Test Image
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Check for Docker file changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
docker:
- 'Dockerfile'
- 'docker-compose.yml'
- name: Log in to GitHub Container Registry
if: steps.changes.outputs.docker == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
if: steps.changes.outputs.docker == 'true'
run: docker compose build
- name: Push Docker image
if: steps.changes.outputs.docker == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: docker compose push
test-shellspec-linux:
name: ShellSpec Tests (Linux)
runs-on: ubuntu-latest
needs: [test-rust, docker-build]
if: ${{ !cancelled() && needs.test-rust.result == 'success' && (needs.docker-build.result == 'success' || needs.docker-build.result == 'skipped') }}
steps:
- uses: actions/checkout@v4
- name: Download Linux release binary
uses: actions/download-artifact@v4
with:
name: rb-linux-release
path: target/release/
- name: Make binary executable
run: chmod +x target/release/rb
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check for Docker file changes
uses: dorny/paths-filter@v3
id: docker-changes
with:
filters: |
docker:
- 'Dockerfile'
- 'docker-compose.yml'
- name: Pull or build Docker test image
run: |
if [ "${{ steps.docker-changes.outputs.docker }}" = "true" ]; then
echo "Dockerfile changed — building image locally"
docker compose build
else
docker compose pull
fi
- name: Make shellspec executable
run: chmod +x ./shellspec
- name: Run ShellSpec tests in Docker
run: ./shellspec
test-pester-windows:
name: Pester Tests (Windows)
runs-on: windows-latest
needs: test-rust
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.90.0
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: windows-latest-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build Ruby Butler
run: cargo build --release
- name: Setup Ruby Butler test installation from RubyInstaller
run: |
# Download RubyInstaller 3.4.5
$DownloadUrl = "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.4.5-1/rubyinstaller-3.4.5-1-x64.7z"
$ArchivePath = "$env:TEMP\rubyinstaller-3.4.5-1-x64.7z"
$ExtractPath = "$env:TEMP\ruby-extract"
Write-Host "Downloading Ruby installer from $DownloadUrl"
Invoke-WebRequest -Uri $DownloadUrl -OutFile $ArchivePath
# Extract using 7z (available on GitHub Actions Windows runners)
Write-Host "Extracting Ruby installer..."
& 7z x $ArchivePath -o"$ExtractPath"
# Find the extracted Ruby directory (should be rubyinstaller-3.4.5-1-x64)
$ExtractedRubyDir = Get-ChildItem "$ExtractPath" -Directory | Where-Object { $_.Name -like "*rubyinstaller*" } | Select-Object -First 1
if (-not $ExtractedRubyDir) {
throw "Could not find extracted Ruby directory in $ExtractPath"
}
# Create the Ruby Butler expected directory structure
$RubyInstallDir = "$env:USERPROFILE\.rubies\ruby-3.4.5"
New-Item -ItemType Directory -Path (Split-Path $RubyInstallDir -Parent) -Force
# Copy the entire Ruby installation to the Butler expected location
Write-Host "Copying Ruby installation from $($ExtractedRubyDir.FullName) to $RubyInstallDir"
Copy-Item $ExtractedRubyDir.FullName $RubyInstallDir -Recurse -Force
# Verify the setup
Write-Host "Ruby Butler test installation created:"
Get-ChildItem "$RubyInstallDir\bin" | Select-Object Name, Length | Format-Table
# Test that key executables exist
$KeyExecutables = @("ruby.exe", "gem.cmd", "bundle.bat", "irb.bat")
foreach ($Exe in $KeyExecutables) {
$ExePath = "$RubyInstallDir\bin\$Exe"
if (Test-Path $ExePath) {
Write-Host "✓ Found $Exe"
} else {
Write-Warning "✗ Missing $Exe"
}
}
shell: pwsh
- name: Run Pester tests
run: |
$env:RB_TEST_PATH = "${{ github.workspace }}\target\release\rb.exe"
Invoke-Pester tests/ -Output Detailed
shell: pwsh
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.90.0
- name: Install cargo-audit
run: cargo install --force cargo-audit
- name: Run security audit
run: cargo audit
coverage:
name: Code Coverage
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.90.0
components: llvm-tools-preview
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: coverage-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-llvm-cov
run: cargo install --force cargo-llvm-cov
- name: Generate coverage report
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: lcov.info
fail_ci_if_error: false