Skip to content

Lint sync_spec.sh.

Lint sync_spec.sh. #52

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
lint:
name: Lint
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-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
# Only run on pushes to main when Docker files change
if: 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'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
if: steps.changes.outputs.docker == 'true'
run: |
docker compose build
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: Try to pull Docker test image
run: |
docker compose pull
- 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