Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .expeditor/run_windows_tests.ps1

This file was deleted.

87 changes: 87 additions & 0 deletions .expeditor/scripts/install_ruby.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
param(
[Parameter(Mandatory = $true)]
[string]$RubyVersion
)

$ErrorActionPreference = "Stop"

Write-Output "--- Pruning the PATH to remove any existing 'C:\tools' segments"
$pathSegments = $env:Path -split ';'
# Filter out segments that start with "C:\tools"
$filteredSegments = $pathSegments | Where-Object { $_ -notlike "C:\tools*" }
# Join the remaining segments back together
$env:Path = $filteredSegments -join ';'

Write-Output "--- Here is the updated PATH: $env:Path"

Write-Output "--- Is Ruby already installed? Trying Get-Command ruby"
$rubyInstalled = Get-Command ruby -ErrorAction SilentlyContinue
if ($rubyInstalled) {
Write-Output "Ruby is already installed at $($rubyInstalled.Source)"
} else {
Write-Output "Ruby is not installed."
}

Write-Output "--- Is Ruby already installed? Trying Get-Childitem"
$rubies = Get-ChildItem -Path "C:\" -Filter "ruby.exe" -Recurse -ErrorAction SilentlyContinue
if ($rubies) {
Write-Output "Found ($rubies.Count) Ruby installations."
Write-Output "They are located at:"
foreach ($ruby in $rubies) {
Write-Output $ruby.FullName
Write-Output "--- What version is this Ruby? Trying ruby --version"
& $ruby.FullName "--version"
}
} else {
Write-Output "No Ruby installations found."
}

Write-Output "--- Now deleting all the Ruby installations found"
foreach ($ruby in $rubies) {
Remove-Item -Path $ruby.DirectoryName -Recurse -Force
Write-Output "Deleted Ruby installation at $($ruby.FullName)"
}

Write-Output "--- Removing any existing Ruby installations from C:\ruby"
if (Test-Path -Path "C:\ruby") {
Write-Output "--- Removing C:\ruby directory"
Remove-Item -Path "C:\ruby" -Recurse -Force
} else {
Write-Output "--- C:\ruby directory does not exist, skipping removal"
}

Write-Output "--- Removing any existing Ruby installations that are installed with Chocolatey"
choco uninstall ruby --version 3.1.6.1 -y -f
choco uninstall ruby --version 3.4.4.2 -y -f

Write-Output "--- Installing Ruby $RubyVersion and MSYS2 using Chocolatey"
choco install ruby --version $RubyVersion --force -y
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
if (-not $?) { throw "Failed to install Ruby $RubyVersion." }

$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")

Write-Output "--- Installing MSYS2 for Ruby $RubyVersion"

Write-Output "--- I am on Drive: $((Get-Location).Drive.Root)"

Write-Output "--- Searching for existing MSYS2 installations"
$devkits = Get-ChildItem $((Get-Location).Drive.Root) "Msys64" -Directory -Recurse -ErrorAction SilentlyContinue
foreach ($devkit in $devkits) {
Write-Output "Found MSYS2 installation at: $($devkit.FullName)"
}

Write-Output "--- Removing existing MSYS2 installations, if they exist"
foreach ($devkit in $devkits) {
Remove-Item -Path $devkit.DirectoryName -Recurse -Force
Write-Output "Deleted MSYS2 installation at $($devkit.FullName)"
}

Write-Output "--- Updating PATH using refreshenv"
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
Write-Output "--- Installing MSYS2 and configuring Ruby DevKit"
choco install msys2 --params "/NoUpdate" --force -y
Update-SessionEnvironment
ridk install 2 3
41 changes: 41 additions & 0 deletions .expeditor/scripts/run_windows_tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Stop script execution when a non-terminating error occurs
$ErrorActionPreference = "Stop"

Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv

Write-Output "--- We are in the Run Windows Tests script"
Write-Output "--- Is Ruby already installed? Trying Get-Childitem"
$rubies = Get-ChildItem -Path "C:\" -Filter "ruby.exe" -Recurse -ErrorAction SilentlyContinue
if ($rubies) {
Write-Output "Found ($rubies.Count) Ruby installations."
Write-Output "They are located at:"
foreach ($ruby in $rubies) {
Write-Output $ruby.FullName
Write-Output "--- What version is this Ruby? Trying ruby --version"
& $ruby.FullName "--version"
}
} else {
Write-Output "No Ruby installations found."
}

Write-Output "--- Here is my path: $env:PATH"

Write-Output "--- Installed Ruby version"
ruby --version

Write-Output "--- Bundle install"

bundle config --local path vendor/bundle
bundle install --jobs=7 --retry=3
if (-not $?) { throw "bundle install failed" }

Write-Output "--- Running Cookstyle"
gem install cookstyle
cookstyle --chefstyle -c .rubocop.yml
if (-not $?) { throw "Cookstyle failed." }

Write-Output "--- Bundle Execute"

bundle exec rake
if (-not $?) { throw "Rake task failed." }
35 changes: 13 additions & 22 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,19 @@ expeditor:
retry:
automatic:
limit: 1
timeout_in_minutes: 30
timeout_in_minutes: 60

steps:
- label: run-specs-ruby-3.1
command:
- .expeditor/scripts/install_ruby.ps1 -RubyVersion "3.1.6.1"
- .expeditor/scripts/run_windows_tests.ps1
agents:
queue: default-windows-2019-privileged

- label: run-specs-ruby-3.0-windows
commands:
- .expeditor/run_windows_tests.ps1

expeditor:
executor:
docker:
host_os: windows
shell: ["powershell", "-Command"]
image: rubydistros/windows-2019:3.0

- label: run-specs-ruby-3.1-windows
commands:
- .expeditor/run_windows_tests.ps1

expeditor:
executor:
docker:
host_os: windows
shell: ["powershell", "-Command"]
image: rubydistros/windows-2019:3.1
- label: run-specs-ruby-3.4
command:
- .expeditor/scripts/install_ruby.ps1 -RubyVersion "3.4.4.2"
- .expeditor/scripts/run_windows_tests.ps1
agents:
queue: default-windows-2019-privileged
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: lint

on:
pull_request:
push:
branches:
- main

concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: false
- uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR
- run: |
bundle install --jobs 4 --retry 3
cookstyle --chefstyle -c .rubocop.yml

33 changes: 33 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: unit

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [windows-2022, windows-2025]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we are not yet supporting windows-2025 in our infrastructure

ruby: ['3.1', '3.4']
name: Unit test on ${{ matrix.os }} with Ruby ${{ matrix.ruby }}
runs-on: ${{ matrix.os }}
env:
RUBYOPT: '--disable-error_highlight'
steps:
- uses: actions/checkout@v4
- name: ruby-setup
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: false
- run: bundle config --local path vendor/bundle
- run: bundle install --jobs 4 --retry 3
- run: bundle exec rake
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pkg
*~

# you should check in your Gemfile.lock in applications, and not in gems
Gemfile.lock
# Gemfile.lock
Gemfile.local

# Do not check in the .bundle directory, or any of the files inside it. Those files are specific to each particular machine, and are used to persist installation options between runs of the bundle install command.
Expand All @@ -20,6 +20,7 @@ binstubs/
# RVM and RBENV ruby version files
.rbenv-version
.rvmrc
.ruby-version

# Documentation
_site/*
Expand Down
16 changes: 16 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
AllCops:
TargetRubyVersion: 3.1
Exclude:
- "spec/data/**/*"
- "vendor/**/*"
- "pkg/**/*"

# these have shellout examples that need to have the tabs that come with the shellout
Layout/IndentationStyle:
Exclude:
- "lib/ohai/plugins/mono.rb"
- "lib/ohai/plugins/darwin/hardware.rb"

Naming/VariableName:
Exclude:
- "lib/win32/**/*"
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.4.2
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ source "https://rubygems.org"
gemspec

group(:development, :test) do
gem "chefstyle", "1.6.2"
gem "rake"
end

group :style do
gem "cookstyle", "~> 8.1"
end

group :debug do
gem "pry"
gem "pry-byebug"
gem "rb-readline"
end
end
Loading