-
Notifications
You must be signed in to change notification settings - Fork 2
Centralize tool versions and improve build consistency #36
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
1a057a6
1b2cc2c
ac5697b
ce14abe
6074e3b
4b39647
dc0b5be
3025129
38d3733
fb64c63
881d415
33da196
c587f47
f5fdda3
0d6b35e
79b706f
959a88d
09869f6
5ce6442
39cfff9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Tool versions for asdf version manager | ||
| # See: https://asdf-vm.com/ | ||
| # | ||
| # Note: For mdbook and plugin versions, see versions.toml | ||
| # Use the install scripts in better-code/ to install the correct versions | ||
| rust stable | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,90 +8,121 @@ We're migrating from using Jekyll to using | |||||||||||||
| [mdBook](https://github.com/rust-lang/mdBook). The mdBook version is located in | ||||||||||||||
| the `./better-code` directory and includes automated CI/CD deployment to GitHub Pages. | ||||||||||||||
|
|
||||||||||||||
| ## Installing and updating mdBook | ||||||||||||||
| The published book is available at: https://stlab.github.io/better-code/ | ||||||||||||||
|
|
||||||||||||||
| Install [Rust and | ||||||||||||||
| Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html): | ||||||||||||||
| ## Prerequisites | ||||||||||||||
|
|
||||||||||||||
| Linux and macOS: | ||||||||||||||
| Install [Rust and Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html): | ||||||||||||||
|
|
||||||||||||||
| ``` | ||||||||||||||
| **Linux and macOS:** | ||||||||||||||
| ```bash | ||||||||||||||
| curl https://sh.rustup.rs -sSf | sh | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| On Windows, you can download the installer from | ||||||||||||||
| [here](https://win.rustup.rs/). | ||||||||||||||
| **Windows:** | ||||||||||||||
| Download the installer from [here](https://win.rustup.rs/). | ||||||||||||||
|
|
||||||||||||||
| Once you have Rust and Cargo installed, you can install or upgrade mdBook by running: | ||||||||||||||
| ## Installing mdBook and Plugins | ||||||||||||||
|
|
||||||||||||||
| ``` | ||||||||||||||
| cargo install mdbook | ||||||||||||||
| **Important**: To ensure consistency between local development and CI, all tool | ||||||||||||||
| versions are centrally managed in `versions.toml`. Use the provided installation | ||||||||||||||
| scripts to automatically install the correct versions: | ||||||||||||||
|
||||||||||||||
| ``` | |
| cargo install mdbook | |
| **Important**: To ensure consistency between local development and CI, all tool | |
| versions are centrally managed in `versions.toml`. Use the provided installation | |
| scripts to automatically install the correct versions: |
This doesn't belong in the installation instructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed and made a pass to tighten up the README.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't these steps handled on demand by cargo as part of the build? They are dependencies, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because cargo doesn't auto-install tools as part of cargo build. I went down this path a few different times and failed.
sean-parent marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
sean-parent marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
sean-parent marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems redundant with item 4 above.
sean-parent marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Install mdBook and plugins using versions from ../versions.toml | ||
| # This ensures consistency between local development and CI | ||
|
|
||
| $ErrorActionPreference = "Stop" | ||
|
|
||
| $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
| $VersionsFile = Join-Path (Split-Path -Parent $ScriptDir) "versions.toml" | ||
|
|
||
| # Function to parse TOML and extract version | ||
|
||
| function Get-ToolVersion { | ||
| param ( | ||
| [string]$Tool, | ||
| [string]$Section = "" | ||
| ) | ||
|
|
||
| $content = Get-Content $VersionsFile -Raw | ||
|
|
||
| if ($Section) { | ||
| # Extract from section like [mdbook-plugins] | ||
| $pattern = "(?ms)\[$Section\].*?$Tool\s*=\s*`"([^`"]+)`"" | ||
| } else { | ||
| # Extract from top-level section like [mdbook] | ||
| $pattern = "(?ms)\[$Tool\].*?version\s*=\s*`"([^`"]+)`"" | ||
| } | ||
|
|
||
| if ($content -match $pattern) { | ||
| return $Matches[1] | ||
| } | ||
| return $null | ||
| } | ||
|
|
||
| # Function to get all plugins from [mdbook-plugins] section | ||
| function Get-MdbookPlugins { | ||
| $content = Get-Content $VersionsFile -Raw | ||
| $plugins = @{} | ||
|
|
||
| if ($content -match '(?ms)\[mdbook-plugins\](.*?)(\[|$)') { | ||
| $section = $Matches[1] | ||
| $lines = $section -split "`n" | ||
|
|
||
| foreach ($line in $lines) { | ||
| if ($line -match '^([a-zA-Z0-9_-]+)\s*=\s*"([^"]+)"') { | ||
| $plugins[$Matches[1]] = $Matches[2] | ||
| } | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return $plugins | ||
| } | ||
|
|
||
| Write-Host "Reading versions from $VersionsFile..." -ForegroundColor Cyan | ||
|
|
||
| # Install mdBook | ||
| $MdbookVersion = Get-ToolVersion -Tool "mdbook" | ||
| if ($MdbookVersion) { | ||
| Write-Host "`nInstalling mdBook $MdbookVersion..." -ForegroundColor Cyan | ||
| cargo install mdbook --version $MdbookVersion | ||
| } else { | ||
| Write-Host "Error: Could not find mdbook version in versions.toml" -ForegroundColor Red | ||
| exit 1 | ||
| } | ||
|
|
||
| # Install mdBook plugins | ||
| Write-Host "`nInstalling mdBook plugins..." -ForegroundColor Cyan | ||
|
|
||
| $plugins = Get-MdbookPlugins | ||
| foreach ($plugin in $plugins.GetEnumerator()) { | ||
| Write-Host "Installing $($plugin.Key) $($plugin.Value)..." -ForegroundColor Cyan | ||
| cargo install $plugin.Key --version $plugin.Value | ||
| } | ||
|
|
||
| Write-Host "`n✓ Installation complete!" -ForegroundColor Green | ||
| Write-Host "`nInstalled versions:" -ForegroundColor Cyan | ||
| mdbook --version | ||
| cargo install --list | Select-String "mdbook" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to have powershell scripts in here for running on windows, we need to do the build on Windows too, to test them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test.