Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Sep 9, 2024
1 parent d86fda2 commit b2a203f
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 263 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,3 @@ jobs:
run: pack build my-image --force-color --builder heroku/builder:24 --trust-extra-buildpacks --buildpack heroku/nodejs-engine --buildpack packaged/${{ matrix.target }}/debug/heroku_ruby --path tmp/ruby-getting-started --pull-policy never
- name: "PRINT: Cached getting started guide output"
run: pack build my-image --force-color --builder heroku/builder:24 --trust-extra-buildpacks --buildpack heroku/nodejs-engine --buildpack packaged/${{ matrix.target }}/debug/heroku_ruby --path tmp/ruby-getting-started --pull-policy never

print-style-guide:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install musl-tools
run: sudo apt-get install musl-tools --no-install-recommends
- name: Update Rust toolchain
run: rustup update
- name: Install Rust linux-musl target
run: rustup target add x86_64-unknown-linux-musl
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
- name: "PRINT: Style guide"
run: cargo run --quiet --bin print_style_guide
3 changes: 1 addition & 2 deletions buildpacks/ruby/src/layers/ruby_install_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use flate2::read::GzDecoder;
use libcnb::build::BuildContext;
use libcnb::data::layer_name;
use libcnb::layer::{
CachedLayerDefinition, EmptyLayerCause, IntoAction, InvalidMetadataAction, LayerState,
RestoredLayerAction,
CachedLayerDefinition, EmptyLayerCause, IntoAction, LayerState, RestoredLayerAction,
};
use libcnb::layer_env::LayerEnv;
use magic_migrate::{try_migrate_deserializer_chain, TryMigrate};
Expand Down
3 changes: 0 additions & 3 deletions buildpacks/ruby/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ buildpack_main!(RubyBuildpack);
struct BundleWithout(String);

impl BundleWithout {
fn new(without: impl AsRef<str>) -> Self {
Self(String::from(without.as_ref()))
}
fn as_str(&self) -> &str {
&self.0
}
Expand Down
46 changes: 27 additions & 19 deletions buildpacks/ruby/src/steps/default_env.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{RubyBuildpack, RubyBuildpackError};
use commons::layer::DefaultEnvLayer;
use libcnb::layer::UncachedLayerDefinition;
use libcnb::layer_env::{LayerEnv, ModificationBehavior};
use libcnb::{
build::BuildContext,
data::{layer_name, store::Store},
Expand All @@ -23,25 +24,32 @@ pub(crate) fn default_env(
}

let (default_secret_key_base, store) = fetch_secret_key_base_from_store(&context.store);
let env_defaults_layer = context.uncached_layer(
layer_name!("env_default"),
UncachedLayerDefinition {
build: true,
launch: true,
},
)?;

let env_defaults_layer = context //
.handle_layer(
layer_name!("env_defaults"),
DefaultEnvLayer::new(
[
("SECRET_KEY_BASE", default_secret_key_base.as_str()),
("JRUBY_OPTS", "-Xcompile.invokedynamic=false"),
("RACK_ENV", "production"),
("RAILS_ENV", "production"),
("RAILS_SERVE_STATIC_FILES", "enabled"),
("RAILS_LOG_TO_STDOUT", "enabled"),
("MALLOC_ARENA_MAX", "2"),
("DISABLE_SPRING", "1"),
]
.into_iter(),
),
)?;
env = env_defaults_layer.env.apply(Scope::Build, &env);
let mut layer_env = LayerEnv::new();
for (key, value) in [
("SECRET_KEY_BASE", default_secret_key_base.as_str()),
("JRUBY_OPTS", "-Xcompile.invokedynamic=false"),
("RACK_ENV", "production"),
("RAILS_ENV", "production"),
("RAILS_SERVE_STATIC_FILES", "enabled"),
("RAILS_LOG_TO_STDOUT", "enabled"),
("MALLOC_ARENA_MAX", "2"),
("DISABLE_SPRING", "1"),
] {
layer_env =
layer_env.chainable_insert(Scope::All, ModificationBehavior::Default, key, value);
}

env_defaults_layer.write_env(&layer_env)?;

let env = env_defaults_layer.read_env()?.apply(Scope::Build, &env);

Ok((env, store))
}
Expand Down
2 changes: 1 addition & 1 deletion buildpacks/ruby/src/user_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ fn debug_cmd(mut bullet: Print<SubBullet<Stdout>>, command: &mut Command) -> Pri

match result {
Ok(_) => bullet.done(),
Err(e) => bullet.sub_bullet(&e.to_string()).done(),
Err(e) => bullet.sub_bullet(e.to_string()).done(),
}
}

Expand Down
4 changes: 0 additions & 4 deletions commons/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ edition.workspace = true
rust-version.workspace = true
version = "1.1.0"

[[bin]]
name = "print_style_guide"
path = "bin/print_style_guide.rs"

[lints]
workspace = true

Expand Down
216 changes: 0 additions & 216 deletions commons/bin/print_style_guide.rs

This file was deleted.

2 changes: 2 additions & 0 deletions commons/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ mod error;

pub use self::app_cache::{build, PathState};
pub use self::app_cache::{AppCache, CacheState};

#[allow(deprecated)]
pub use self::app_cache_collection::AppCacheCollection;
pub use self::clean::FilesWithSize;
pub use self::config::CacheConfig;
Expand Down
4 changes: 2 additions & 2 deletions commons/src/cache/app_cache_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct AppCacheCollection<'a> {
collection: Vec<AppCache>,
}

#[allow(deprecated)]
impl<'a> AppCacheCollection<'a> {
/// Store multiple application paths in the cache
///
Expand All @@ -36,15 +37,14 @@ impl<'a> AppCacheCollection<'a> {
let caches = config
.into_iter()
.map(|config| {
AppCache::new_and_load(context, config).map(|store| {
AppCache::new_and_load(context, config).inspect(|store| {
let path = store.path().display();

log::log_step(match store.cache_state() {
CacheState::NewEmpty => format!("Creating cache for {path}"),
CacheState::ExistsEmpty => format!("Loading (empty) cache for {path}"),
CacheState::ExistsWithContents => format!("Loading cache for {path}"),
});
store
})
})
.collect::<Result<Vec<AppCache>, CacheError>>()?;
Expand Down
2 changes: 2 additions & 0 deletions commons/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ mod default_env_layer;

use libcnb::layer::{IntoAction, InvalidMetadataAction};

#[allow(deprecated)]
pub use self::configure_env_layer::ConfigureEnvLayer;
#[allow(deprecated)]
pub use self::default_env_layer::DefaultEnvLayer;

pub enum MetadataMigrationFYI<T> {
Expand Down
Loading

0 comments on commit b2a203f

Please sign in to comment.