-
Notifications
You must be signed in to change notification settings - Fork 42
Updating for Ruby 3.4 and Cookstyle #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5c7bccd
Updating for Ruby 3.4 and Cookstyle
johnmccrae a870458
Too many Ruby installs, kiiling them all
johnmccrae be34d69
Too many Ruby installs, kiiling them all
johnmccrae 125a4af
Too many Ruby installs, kiiling them all
johnmccrae f48c255
Too many Ruby installs, kiiling them all
johnmccrae 6847371
Too many Ruby installs, kiiling them all
johnmccrae a60c82f
Too many Ruby installs, kiiling them all
johnmccrae c84dda9
Too many Ruby installs, kiiling them all
johnmccrae 2ec0e03
Too many Ruby installs, kiiling them all
johnmccrae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/**/*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.4.2 | ||
johnmccrae marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.