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
11 changes: 10 additions & 1 deletion .github/workflows/build_jruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ jobs:
run: rustup update
- name: Rust Cache
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Cargo build
run: cargo build --locked
- name: Output CHANGELOG
run: cargo run --locked --bin jruby_changelog -- --version "${{inputs.jruby_version}}" | tee "$GITHUB_STEP_SUMMARY"
run: |
set -euo pipefail
{
# 4 backticks so the inner ```ruby fences in the changelog render literally
echo '````'
cargo run --locked --bin jruby_changelog -- --version "${{inputs.jruby_version}}"
echo '````'
Comment thread
schneems marked this conversation as resolved.
} | tee -a "$GITHUB_STEP_SUMMARY"

build-and-upload:
runs-on: pub-hk-ubuntu-24.04-xlarge
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/build_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ jobs:
run: rustup update
- name: Rust Cache
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Cargo build
run: cargo build --locked
- name: Output CHANGELOG
run: cargo run --locked --bin ruby_changelog -- --version "${{inputs.ruby_version}}" | tee "$GITHUB_STEP_SUMMARY"
run: |
set -euo pipefail
{
# 4 backticks so the inner ```ruby fences in the changelog render literally
echo '````'
cargo run --locked --bin ruby_changelog -- --version "${{inputs.ruby_version}}"
echo '````'
} | tee -a "$GITHUB_STEP_SUMMARY"

build-and-upload:
runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-24.04-arm-xlarge' || 'pub-hk-ubuntu-24.04-xlarge' }}
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions jruby_executable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ tar = { workspace = true }
tempfile = { workspace = true }
thiserror = { workspace = true }
winnow = { workspace = true }

[dev-dependencies]
pretty_assertions = { workspace = true }
54 changes: 47 additions & 7 deletions jruby_executable/src/bin/jruby_changelog.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::error::Error;
use std::{error::Error, io::Write};

use bullet_stream::global::print;
use clap::Parser;
Expand All @@ -11,14 +11,25 @@ struct Args {
version: JRubyVersion,
}

fn jruby_changelog(args: &Args) -> Result<(), Box<dyn Error>> {
fn jruby_changelog<W>(args: &Args, io: W) -> Result<W, Box<dyn Error>>
where
W: Write,
{
let Args { version } = args;

let stdlib_version = jruby_build_properties(version)?.ruby_stdlib_version()?;

println!("Add a changelog item: https://devcenter.heroku.com/admin/changelog_items/new");
println!();
render_jruby_changelog(version, &stdlib_version, io)
}

fn render_jruby_changelog<W>(
version: &JRubyVersion,
stdlib_version: &str,
mut io: W,
) -> Result<W, Box<dyn Error>>
where
W: Write,
{
let changelog = formatdoc! {"
## JRuby version {version} is now available

Expand All @@ -32,14 +43,14 @@ fn jruby_changelog(args: &Args) -> Result<(), Box<dyn Error>> {
The JRuby release notes can be found on the [JRuby website](https://www.jruby.org/news).
"};

print::plain(changelog);
writeln!(io, "{changelog}")?;

Ok(())
Ok(io)
}

fn main() {
let args = Args::parse();
if let Err(error) = jruby_changelog(&args) {
if let Err(error) = jruby_changelog(&args, std::io::stdout()) {
print::error(formatdoc! {"
❌ Command failed ❌

Expand All @@ -49,3 +60,32 @@ fn main() {
std::process::exit(1);
}
}

#[cfg(test)]
mod test {
use super::*;
use pretty_assertions::assert_eq;

#[test]
fn regular_release() {
let mut io = Vec::new();

let output =
render_jruby_changelog(&JRubyVersion::parse("9.4.7.0").unwrap(), "3.1.4", &mut io)
.unwrap();
let actual = String::from_utf8_lossy(output);
let expected = formatdoc! {"
## JRuby version 9.4.7.0 is now available

[JRuby v9.4.7.0](/articles/ruby-support-reference#supported-jruby-versions) is now available on Heroku. To run
your app using this version of Ruby, add the following `ruby` directive to your Gemfile:

```ruby
ruby \"3.1.4\", engine: \"jruby\", engine_version: \"9.4.7.0\"
```

The JRuby release notes can be found on the [JRuby website](https://www.jruby.org/news).
"};
assert_eq!(expected.trim(), actual.trim());
}
}
11 changes: 0 additions & 11 deletions ruby_executable/src/bin/ruby_changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ where
{
let Args { version } = args;

writeln!(
io,
"Add a changelog item: https://devcenter.heroku.com/admin/changelog_items/new"
)?;

writeln!(io)?;

let gemfile_format = version.bundler_format();

let changelog = formatdoc! {"
Expand Down Expand Up @@ -81,8 +74,6 @@ mod test {
let output = ruby_changelog(&args, &mut io).unwrap();
let actual = String::from_utf8_lossy(output);
let expected = formatdoc! {"
Add a changelog item: https://devcenter.heroku.com/admin/changelog_items/new

## Ruby version 3.3.2 is now available

[Ruby v3.3.2](/articles/ruby-support#ruby-versions) is now available on Heroku. To run \
Expand All @@ -106,8 +97,6 @@ mod test {
let output = ruby_changelog(&args, &mut io).unwrap();
let actual = String::from_utf8_lossy(output);
let expected = formatdoc! {"
Add a changelog item: https://devcenter.heroku.com/admin/changelog_items/new

## Ruby version 3.1.0-rc1 is now available

[Ruby v3.1.0-rc1](/articles/ruby-support#ruby-versions) is now available on Heroku. To run \
Expand Down