diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index cfc4aead..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,150 +0,0 @@ -version: 2.1 - -orbs: - pack: buildpacks/pack@0.2.4 - heroku-buildpacks: - commands: - install-build-dependencies: - steps: - - run: - name: "Install rsync, jq, libssl-dev, musl-tools, pkg-config via apt" - command: sudo apt-get update && sudo apt-get install -y rsync jq libssl-dev musl-tools pkg-config - - run: - name: "Install yj 5.0.0" - command: | - bin_dir="$(mktemp -d)" - curl --retry 3 --fail --max-time 10 --location "https://github.com/sclevine/yj/releases/download/v5.0.0/yj-linux" --output "${bin_dir}/yj" - chmod +x "${bin_dir}/yj" - - echo "export PATH=\"${bin_dir}:\${PATH}\"" >> $BASH_ENV - - run: - name: "Install Rust Stable" - command: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -t x86_64-unknown-linux-musl - echo "export PATH=\"$HOME/.cargo/bin:$PATH\"" >> $BASH_ENV - - run: - name: "Install libcnb-cargo" - command: cargo install libcnb-cargo - -jobs: - package-buildpack: - parameters: - buildpack-dir: - type: string - docker: - - image: cimg/base:stable - steps: - - checkout - - setup_remote_docker - - pack/install-pack: - version: 0.27.0 - - heroku-buildpacks/install-build-dependencies - - run: - name: "Build and package buildpack" - command: | - package_toml="<< parameters.buildpack-dir >>/package.toml" - if [[ -f "<< parameters.buildpack-dir >>/build.sh" ]]; then - "./<< parameters.buildpack-dir >>/build.sh" - package_toml="<< parameters.buildpack-dir >>/target/package.toml" - fi - - pack buildpack package test --config "${package_toml}" - - shell-linting: - docker: - - image: koalaman/shellcheck-alpine:stable - steps: - - run: "apk add git" - - run: "apk add shfmt" - - checkout - - run: - name: "shellcheck" - command: "shfmt -f . | grep -v ^test-fixtures/ | xargs shellcheck" - - run: - name: "shfmt" - command: "shfmt -f . | grep -v ^test-fixtures/ | xargs shfmt -d" - - cutlass: - parameters: - spec_dir: - type: string - cnb_builder: - type: string - machine: - image: ubuntu-2004:current - resource_class: xlarge - environment: - PARALLEL_SPLIT_TEST_PROCESSES: 8 - INTEGRATION_TEST_CNB_BUILDER: "<< parameters.cnb_builder >>" - steps: - - checkout - - pack/install-pack: - version: 0.27.0 - - heroku-buildpacks/install-build-dependencies - - run: - name: Install Ruby dependencies - command: | - gem install bundler - bundle install - - run: - name: Execute rspec << parameters.spec_dir >> - command: bundle exec rspec << parameters.spec_dir >> - - cargo-test: - parameters: - cnb_builder: - type: string - machine: - image: ubuntu-2004:current - environment: - INTEGRATION_TEST_CNB_BUILDER: "<< parameters.cnb_builder >>" - steps: - - checkout - - heroku-buildpacks/install-build-dependencies - - pack/install-pack: - version: 0.27.0 - - run: - command: cargo test - - rustfmt: - docker: - - image: cimg/base:stable - steps: - - checkout - - setup_remote_docker - - heroku-buildpacks/install-build-dependencies - - run: - command: cargo fmt --all -- --check - -workflows: - version: 2 - ci: - jobs: - - shell-linting - - rustfmt - - package-buildpack: - matrix: - parameters: - buildpack-dir: - - "buildpacks/jvm" - - "buildpacks/maven" - - "buildpacks/jvm-function-invoker" - - "meta-buildpacks/java" - - "meta-buildpacks/java-function" - - "test/meta-buildpacks/java" - - "test/meta-buildpacks/java-function" - - cargo-test: - matrix: - parameters: - cnb_builder: - - "heroku/buildpacks:20" - - "heroku/builder:22" - - cutlass: - matrix: - parameters: - spec_dir: - - "test/specs/java" - - "test/specs/java-function" - cnb_builder: - - "heroku/buildpacks:20" - - "heroku/builder:22" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..39f61e89 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,97 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Update Rust toolchain + run: rustup update + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - name: Clippy + run: cargo clippy --all-targets --locked -- --deny warnings + - name: rustfmt + run: cargo fmt -- --check + + unit-test: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Update Rust toolchain + run: rustup update + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - name: Run unit tests + run: cargo test --locked + + libcnb-test: + name: Cargo integration tests (${{ matrix.integration-test-cnb-builder }}) + runs-on: ubuntu-22.04 + strategy: + matrix: + integration-test-cnb-builder: [ "heroku/buildpacks:20", "heroku/builder:22" ] + env: + INTEGRATION_TEST_CNB_BUILDER: ${{ matrix.integration-test-cnb-builder }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - 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 + - name: Install Pack CLI + uses: buildpacks/github-actions/setup-pack@v4.9.0 + - name: Run integration tests + # Runs only tests annotated with the `ignore` attribute (which in this repo, are the integration tests). + run: cargo test --locked -- --ignored + + cutlass-test: + name: Cutlass (${{ matrix.spec-dir }} on ${{ matrix.integration-test-cnb-builder }}) + runs-on: ubuntu-22.04 + strategy: + matrix: + integration-test-cnb-builder: ["heroku/buildpacks:20", "heroku/builder:22"] + spec-dir: ["test/specs/java", "test/specs/java-function"] + env: + INTEGRATION_TEST_CNB_BUILDER: ${{ matrix.integration-test-cnb-builder }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - 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 + - name: Install libcnb-cargo + run: cargo install libcnb-cargo + - name: Install Pack CLI + uses: buildpacks/github-actions/setup-pack@v4.9.0 + - name: Install Ruby and dependencies + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: "2.7" + - name: Run integration tests + run: bundle exec rspec ${{ matrix.spec-dir }} diff --git a/README.md b/README.md index 1b8a2408..91e69720 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Heroku Cloud Native JVM Buildpacks -[![CircleCI](https://circleci.com/gh/heroku/buildpacks-jvm/tree/main.svg?style=shield)](https://circleci.com/gh/heroku/buildpacks-jvm/tree/main) +[![CI](https://github.com/heroku/buildpacks-jvm/actions/workflows/ci.yml/badge.svg)](https://github.com/heroku/buildpacks-jvm/actions/workflows/ci.yml) Heroku's official [Cloud Native Buildpacks](https://buildpacks.io) for the JVM ecosystem. diff --git a/buildpacks/jvm-function-invoker/src/common.rs b/buildpacks/jvm-function-invoker/src/common.rs index 4eb9450e..5323cea8 100644 --- a/buildpacks/jvm-function-invoker/src/common.rs +++ b/buildpacks/jvm-function-invoker/src/common.rs @@ -4,7 +4,7 @@ use std::path::Path; use toml::Value; pub fn project_toml_salesforce_type_is_function(project_toml_path: &Path) -> bool { - read_toml_file(&project_toml_path) + read_toml_file(project_toml_path) .ok() .and_then(|table: Value| { toml_select_value(vec!["com", "salesforce", "type"], &table) diff --git a/buildpacks/jvm-function-invoker/src/layers/bundle.rs b/buildpacks/jvm-function-invoker/src/layers/bundle.rs index 4092c231..b3c13d39 100644 --- a/buildpacks/jvm-function-invoker/src/layers/bundle.rs +++ b/buildpacks/jvm-function-invoker/src/layers/bundle.rs @@ -55,7 +55,7 @@ impl Layer for BundleLayer { match exit_status.code() { Some(0) => { - log_function_metadata(&layer_path)?; + log_function_metadata(layer_path)?; LayerResultBuilder::new(GenericMetadata::default()) .env(LayerEnv::new().chainable_insert( Scope::All, diff --git a/buildpacks/jvm-function-invoker/src/main.rs b/buildpacks/jvm-function-invoker/src/main.rs index 2f08a5a0..943a03a8 100644 --- a/buildpacks/jvm-function-invoker/src/main.rs +++ b/buildpacks/jvm-function-invoker/src/main.rs @@ -97,7 +97,7 @@ impl Buildpack for JvmFunctionInvokerBuildpack { } fn on_error(&self, error: libcnb::Error) { - on_error(handle_buildpack_error, error) + on_error(handle_buildpack_error, error); } } diff --git a/buildpacks/jvm/src/bin/heroku_database_env_var_rewrite.rs b/buildpacks/jvm/src/bin/heroku_database_env_var_rewrite.rs index d4d24b5a..e4b83d13 100644 --- a/buildpacks/jvm/src/bin/heroku_database_env_var_rewrite.rs +++ b/buildpacks/jvm/src/bin/heroku_database_env_var_rewrite.rs @@ -9,6 +9,7 @@ use libcnb::exec_d::write_exec_d_program_output; use std::collections::HashMap; use url::Url; +#[allow(clippy::missing_panics_doc)] pub fn main() { write_exec_d_program_output( jvm_env_vars_for_env(&std::env::vars().collect()) @@ -352,7 +353,7 @@ mod test { String::from("postgres://pooluser:poolpass@pooled.example.com:5432/testdb"), )])); - assert_eq!(result, HashMap::new()) + assert_eq!(result, HashMap::new()); } #[test] @@ -466,7 +467,7 @@ mod test { String::from("postgres://test123@ec2-52-13-12"), )])); - assert_eq!(result, HashMap::new()) + assert_eq!(result, HashMap::new()); } #[test] diff --git a/buildpacks/jvm/src/layers/openjdk.rs b/buildpacks/jvm/src/layers/openjdk.rs index d447ecd1..44c04274 100644 --- a/buildpacks/jvm/src/layers/openjdk.rs +++ b/buildpacks/jvm/src/layers/openjdk.rs @@ -52,7 +52,7 @@ impl Layer for OpenJdkLayer { std::fs::File::open(&path) .map_err(OpenJdkBuildpackError::CannotOpenOpenJdkTarball) .and_then(|mut file| { - libherokubuildpack::tar::decompress_tarball(&mut file, &layer_path) + libherokubuildpack::tar::decompress_tarball(&mut file, layer_path) .map_err(OpenJdkBuildpackError::CannotDecompressOpenJdkTarball) })?; @@ -68,11 +68,11 @@ impl Layer for OpenJdkLayer { let symlink_ubuntu_java_cacerts_file = ubuntu_java_cacerts_file_path.is_file() && !app_jdk_overlay_dir_path - .join(&relative_jdk_cacerts_path) + .join(relative_jdk_cacerts_path) .exists(); if symlink_ubuntu_java_cacerts_file { - let absolute_jdk_cacerts_path = layer_path.join(&relative_jdk_cacerts_path); + let absolute_jdk_cacerts_path = layer_path.join(relative_jdk_cacerts_path); fs::rename( &absolute_jdk_cacerts_path, @@ -95,7 +95,7 @@ impl Layer for OpenJdkLayer { fs_extra::copy_items( &jdk_overlay_contents, - &layer_path, + layer_path, &CopyOptions { overwrite: true, skip_exist: false, @@ -116,7 +116,7 @@ impl Layer for OpenJdkLayer { Scope::All, ModificationBehavior::Override, "JAVA_HOME", - &layer_path, + layer_path, ) .chainable_insert( Scope::All, diff --git a/buildpacks/jvm/src/version.rs b/buildpacks/jvm/src/version.rs index 4e71f703..2ee24601 100644 --- a/buildpacks/jvm/src/version.rs +++ b/buildpacks/jvm/src/version.rs @@ -8,13 +8,13 @@ pub fn normalize_version_string>( ) -> Result<(OpenJDKDistribution, String), NormalizeVersionStringError> { let user_version_string = user_version_string.into(); - let (user_distribution_string, user_version_string) = user_version_string - .trim() - .split_once("-") - .map(|(split_distribution_string, split_version_string)| { - (Some(split_distribution_string), split_version_string) - }) - .unwrap_or((None, &user_version_string)); + let (user_distribution_string, user_version_string) = + user_version_string.trim().split_once('-').map_or( + (None, user_version_string.as_str()), + |(split_distribution_string, split_version_string)| { + (Some(split_distribution_string), split_version_string) + }, + ); let version_string = match user_version_string { "7" | "1.7" => "1.7.0_352", @@ -34,8 +34,8 @@ pub fn normalize_version_string>( }; match user_distribution_string { - None => Ok(default_distribution(&stack_id)), - Some("heroku") | Some("openjdk") => Ok(OpenJDKDistribution::Heroku), + None => Ok(default_distribution(stack_id)), + Some("heroku" | "openjdk") => Ok(OpenJDKDistribution::Heroku), Some("zulu") => Ok(OpenJDKDistribution::AzulZulu), Some(unknown) => Err(NormalizeVersionStringError::UnknownDistribution( String::from(unknown), diff --git a/buildpacks/jvm/tests/integration_tests.rs b/buildpacks/jvm/tests/integration_tests.rs index 86dbf1ad..49e869d0 100644 --- a/buildpacks/jvm/tests/integration_tests.rs +++ b/buildpacks/jvm/tests/integration_tests.rs @@ -1,6 +1,7 @@ use libcnb_test::{assert_contains, BuildConfig, TestRunner}; #[test] +#[ignore = "integration test"] fn test() { let builder_name = std::env::var("INTEGRATION_TEST_CNB_BUILDER").unwrap(); diff --git a/buildpacks/maven/README.md b/buildpacks/maven/README.md index 334dab4b..2a681039 100644 --- a/buildpacks/maven/README.md +++ b/buildpacks/maven/README.md @@ -1,5 +1,5 @@ # Heroku Cloud Native Maven Buildpack -[![CircleCI](https://circleci.com/gh/heroku/buildpacks-jvm/tree/main.svg?style=shield)](https://circleci.com/gh/heroku/buildpacks-jvm/tree/main) +[![CI](https://github.com/heroku/buildpacks-jvm/actions/workflows/ci.yml/badge.svg)](https://github.com/heroku/buildpacks-jvm/actions/workflows/ci.yml) [![Registry](https://img.shields.io/badge/dynamic/json?url=https://registry.buildpacks.io/api/v1/buildpacks/heroku/maven&label=version&query=$.latest.version&color=DF0A6B&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACSVJREFUaAXtWQ1sFMcVnp/9ub3zHT7AOEkNOMYYp4CQQFBLpY1TN05DidI2NSTF0CBFQAOBNrTlp0a14sipSBxIG6UYHKCO2ka4SXD4SUuaCqmoJJFMCapBtcGYGqMkDgQ4++52Z2e3b87es+/s+wNHVSUPsnZv9s2b97335v0MCI2NMQ2MaeD/WgP4FqQnX//2K4tVWfa0X+9+q/N4dfgWeESXPPjUUd+cu+5cYmMcPvzawQOtrdVG9GMaLxkD+OZDex6WVeUgwhiZnH1g62bNX4+sPpLGXvEkdPNzLd93e9y/cCnabIQJCnz+2Q9rNs9tjCdM9ltK9nGkb5jYxYjIyDJDSCLSV0yFHCr/XsObvQH92X+8u/b0SGvi5zZUn1joc/u2qapajglB4XAfUlQPoqpyRzxtqt8ZA+AIcQnZEb6WZSKCMSZUfSTLg8vv/86e3b03AztO/u3p7pE2fvInfy70TpiwRVKU5YqqygbTEWL9lISaiDFujbQu2VzGAIYzs5HFDUQo8WKibMzy0Yr7Ht5Td/Nyd0NLS3VQ0FesOjDurtwvPaWp6gZVc080TR2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efmP3etS5a2YSuVizjkfBAo9l0tzyCDbSqKC7YUIu/daOFB3pbUxrf721B0rc/w+9zrYfK2K5QlhcCvnfFCigUr6L0ucDA3KeR8iYO3U8y8M6+ZGBDAgIc0vWl5BEakiijQTYmhkWpEVEBwOELgUt+y3QtysuXT21ahGoujSePl3/qpiRVK2wO3KY1ClyuJ8YHATcDPIyhQFud6JbfKr1vZz+xehd0a8e08GICKC318xzpejrpUQ3UAkaZK4yoGU/HduWts72hsPpyFnSpL2wjWlFNFfSoSWipqIWVYP1J27rwcCL839eF9PMgYpATiLJ01eOs2jaU+D03508cK/9iHUkm6F4LBI+hTlc9m0BSsVSufcCBkvzu7afSHpgrGPYxoY00BEA/8FOPrYBqYsE44AAAAASUVORK5CYII=&labelColor=white)](https://registry.buildpacks.io/buildpacks/heroku/maven) Heroku's official Cloud Native Buildpack for [Apache Maven](https://maven.apache.org/). diff --git a/buildpacks/maven/src/framework.rs b/buildpacks/maven/src/framework.rs index bc0b9afc..33e7fa2c 100644 --- a/buildpacks/maven/src/framework.rs +++ b/buildpacks/maven/src/framework.rs @@ -27,7 +27,11 @@ pub fn detect_framework>( (wildfly_swarm_regex, Framework::WildflySwarm), ] .iter() - .find_map(|(regex, framework)| regex.is_match(&dependency_list_string).then(|| *framework)); + .find_map(|(regex, framework)| { + regex + .is_match(&dependency_list_string) + .then_some(*framework) + }); Ok(framework) } diff --git a/buildpacks/maven/src/layer/maven.rs b/buildpacks/maven/src/layer/maven.rs index d9d641bd..d81d3828 100644 --- a/buildpacks/maven/src/layer/maven.rs +++ b/buildpacks/maven/src/layer/maven.rs @@ -55,13 +55,13 @@ impl Layer for MavenLayer { libherokubuildpack::tar::decompress_tarball( &mut File::open(&temp_file_path).unwrap(), - &layer_path, + layer_path, ) .map_err(MavenBuildpackError::MavenTarballDecompressError)?; // The actual Maven installation is located in the .maven subdirectory of the tarball. We // need to move its contents to the layer itself before it can be used: - util::move_directory_contents(layer_path.join(".maven"), &layer_path) + util::move_directory_contents(layer_path.join(".maven"), layer_path) .map_err(MavenBuildpackError::MavenTarballNormalizationError)?; std::fs::remove_dir_all(layer_path.join(".maven")) @@ -81,7 +81,7 @@ impl Layer for MavenLayer { Scope::Build, ModificationBehavior::Override, "M2_HOME", - &layer_path, + layer_path, ); LayerResultBuilder::new(MavenLayerMetadata { diff --git a/buildpacks/maven/src/main.rs b/buildpacks/maven/src/main.rs index 58346f79..d6279f36 100644 --- a/buildpacks/maven/src/main.rs +++ b/buildpacks/maven/src/main.rs @@ -1,6 +1,4 @@ // Enable rustc and Clippy lints that are disabled by default. -// https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unused-crate-dependencies -#![warn(unused_crate_dependencies)] // https://rust-lang.github.io/rust-clippy/stable/index.html #![warn(clippy::pedantic)] // This lint is too noisy and enforces a style that reduces readability in many cases. @@ -101,6 +99,7 @@ impl Buildpack for MavenBuildpack { } } + #[allow(clippy::too_many_lines)] fn build(&self, context: BuildContext) -> libcnb::Result { let maven_repository_layer = context.handle_layer(layer_name!("repository"), MavenRepositoryLayer)?; diff --git a/buildpacks/maven/tests/customization_tests.rs b/buildpacks/maven/tests/customization_tests.rs index 593dd4af..80e2c203 100644 --- a/buildpacks/maven/tests/customization_tests.rs +++ b/buildpacks/maven/tests/customization_tests.rs @@ -2,6 +2,7 @@ use indoc::indoc; use libcnb_test::{assert_contains, BuildConfig, BuildpackReference, TestRunner}; #[test] +#[ignore = "integration test"] fn maven_custom_goals() { TestRunner::default().build(default_config().env("MAVEN_CUSTOM_GOALS", "site"), |context| { // Assert only the goals in MAVEN_CUSTOM_GOALS are executed @@ -38,6 +39,7 @@ fn maven_custom_goals() { } #[test] +#[ignore = "integration test"] fn maven_custom_opts() { TestRunner::default().build(default_config().env("MAVEN_CUSTOM_OPTS", "-X"), |context| { // Assert only the options in MAVEN_CUSTOM_GOALS are used diff --git a/buildpacks/maven/tests/misc_tests.rs b/buildpacks/maven/tests/misc_tests.rs index ab7c02ae..5828f268 100644 --- a/buildpacks/maven/tests/misc_tests.rs +++ b/buildpacks/maven/tests/misc_tests.rs @@ -6,6 +6,7 @@ use std::fs; use std::os::unix::fs::PermissionsExt; #[test] +#[ignore = "integration test"] fn mvnw_executable_bit() { TestRunner::default().build( default_config().app_dir_preprocessor(|dir| { @@ -20,6 +21,7 @@ fn mvnw_executable_bit() { } #[test] +#[ignore = "integration test"] fn mvn_dependency_list() { TestRunner::default().build(default_config(), |context| { assert_eq!( @@ -50,6 +52,7 @@ fn mvn_dependency_list() { } #[test] +#[ignore = "integration test"] fn no_unexpected_files_in_app_dir() { TestRunner::default().build(default_config(), |context| { assert_eq!( @@ -96,6 +99,7 @@ fn no_unexpected_files_in_app_dir() { } #[test] +#[ignore = "integration test"] fn no_internal_maven_options_logging() { TestRunner::default().build(default_config(), |context| { assert_not_contains!(context.pack_stdout, "-Dmaven.repo.local="); @@ -109,6 +113,7 @@ fn no_internal_maven_options_logging() { } #[test] +#[ignore = "integration test"] fn cache_dependencies_between_builds() { TestRunner::default().build(default_config(), |context| { assert_contains!(context.pack_stdout, "Downloading from central"); @@ -120,6 +125,7 @@ fn cache_dependencies_between_builds() { } #[test] +#[ignore = "integration test"] fn descriptive_error_message_on_failed_build() { TestRunner::default().build(default_config().app_dir("../../test-fixtures/app-with-compile-error").expected_pack_result(PackResult::Failure), |context| { assert_contains!(context.pack_stdout, "[INFO] BUILD FAILURE"); diff --git a/buildpacks/maven/tests/polyglot_tests.rs b/buildpacks/maven/tests/polyglot_tests.rs index 226b3f7d..dbc2d814 100644 --- a/buildpacks/maven/tests/polyglot_tests.rs +++ b/buildpacks/maven/tests/polyglot_tests.rs @@ -1,6 +1,7 @@ use libcnb_test::{assert_contains, BuildConfig, BuildpackReference, TestRunner}; #[test] +#[ignore = "integration test"] fn polyglot_maven_app() { TestRunner::default().build( BuildConfig::new( diff --git a/buildpacks/maven/tests/process_types_tests.rs b/buildpacks/maven/tests/process_types_tests.rs index 69010bdd..2ac6e5cb 100644 --- a/buildpacks/maven/tests/process_types_tests.rs +++ b/buildpacks/maven/tests/process_types_tests.rs @@ -3,6 +3,7 @@ use std::thread; use std::time::Duration; #[test] +#[ignore = "integration test"] fn spring_boot_process_type() { TestRunner::default().build( BuildConfig::new( @@ -18,7 +19,7 @@ fn spring_boot_process_type() { ContainerConfig::new().expose_port(8080), |container_context| { let addr = container_context.address_for_port(8080).unwrap(); - let url = format!("http://{}:{}/", addr.ip().to_string(), addr.port()); + let url = format!("http://{}:{}/", addr.ip(), addr.port()); // Give the application a little time to boot up: // https://github.com/heroku/libcnb.rs/issues/280 diff --git a/buildpacks/maven/tests/settings_xml_tests.rs b/buildpacks/maven/tests/settings_xml_tests.rs index fbf4f1e2..f12279b6 100644 --- a/buildpacks/maven/tests/settings_xml_tests.rs +++ b/buildpacks/maven/tests/settings_xml_tests.rs @@ -6,6 +6,7 @@ use std::fs; use std::path::PathBuf; #[test] +#[ignore = "integration test"] fn maven_settings_url_success() { TestRunner::default().build( default_config().env("MAVEN_SETTINGS_URL", SETTINGS_XML_URL), @@ -21,6 +22,7 @@ fn maven_settings_url_success() { } #[test] +#[ignore = "integration test"] fn maven_settings_url_failure() { TestRunner::default().build( default_config() @@ -39,17 +41,15 @@ fn maven_settings_url_failure() { } #[test] +#[ignore = "integration test"] fn maven_settings_path() { let settings_xml_filename = "forgreatjustice.xml"; let settings_xml_test_value = "Take off every 'ZIG'!!"; TestRunner::default().build( default_config() - .app_dir_preprocessor(|dir| { - write_settings_xml( - dir.join(settings_xml_filename.to_owned()), - settings_xml_test_value, - ) + .app_dir_preprocessor(move |dir| { + write_settings_xml(dir.join(settings_xml_filename), settings_xml_test_value) }) .env("MAVEN_SETTINGS_PATH", settings_xml_filename), |context| { @@ -64,17 +64,15 @@ fn maven_settings_path() { } #[test] +#[ignore = "integration test"] fn maven_settings_path_and_settings_url() { let settings_xml_filename = "zerowing.xml"; let settings_xml_test_value = "We get signal."; TestRunner::default().build( default_config() - .app_dir_preprocessor(|dir| { - write_settings_xml( - dir.join(settings_xml_filename.to_owned()), - settings_xml_test_value, - ) + .app_dir_preprocessor(move |dir| { + write_settings_xml(dir.join(settings_xml_filename), settings_xml_test_value) }) .env("MAVEN_SETTINGS_PATH", settings_xml_filename) .env("MAVEN_SETTINGS_URL", SETTINGS_XML_URL), @@ -91,17 +89,15 @@ fn maven_settings_path_and_settings_url() { } #[test] +#[ignore = "integration test"] fn maven_settings_xml_in_app_root() { let settings_xml_filename = "settings.xml"; let settings_xml_test_value = "Somebody set up us the bomb."; TestRunner::default().build( // Note that there is no MAVEN_SETTINGS_PATH here - default_config().app_dir_preprocessor(|dir| { - write_settings_xml( - dir.join(settings_xml_filename.to_owned()), - settings_xml_test_value, - ) + default_config().app_dir_preprocessor(move |dir| { + write_settings_xml(dir.join(settings_xml_filename), settings_xml_test_value) }), |context| { assert_contains!( @@ -115,6 +111,7 @@ fn maven_settings_xml_in_app_root() { } #[test] +#[ignore = "integration test"] fn maven_settings_xml_in_app_root_and_explicit_settings_path() { let settings_xml_filename = "settings.xml"; let settings_xml_test_value = "Somebody set up us the bomb."; @@ -124,16 +121,9 @@ fn maven_settings_xml_in_app_root_and_explicit_settings_path() { TestRunner::default().build( // Note that there is no MAVEN_SETTINGS_PATH here default_config() - .app_dir_preprocessor(|dir| { - write_settings_xml( - dir.join(settings_xml_filename.to_owned()), - settings_xml_test_value, - ); - - write_settings_xml( - dir.join(zero_wing_filename.to_owned()), - zero_wing_test_value, - ); + .app_dir_preprocessor(move |dir| { + write_settings_xml(dir.join(settings_xml_filename), settings_xml_test_value); + write_settings_xml(dir.join(zero_wing_filename), zero_wing_test_value); }) .env("MAVEN_SETTINGS_PATH", zero_wing_filename), |context| { @@ -148,6 +138,7 @@ fn maven_settings_xml_in_app_root_and_explicit_settings_path() { } #[test] +#[ignore = "integration test"] fn maven_settings_xml_in_app_root_and_explicit_settings_url() { let settings_xml_filename = "settings.xml"; let settings_xml_test_value = "Somebody set up us the bomb."; @@ -155,11 +146,8 @@ fn maven_settings_xml_in_app_root_and_explicit_settings_url() { TestRunner::default().build( // Note that there is no MAVEN_SETTINGS_PATH here default_config() - .app_dir_preprocessor(|dir| { - write_settings_xml( - dir.join(settings_xml_filename.to_owned()), - settings_xml_test_value, - ); + .app_dir_preprocessor(move |dir| { + write_settings_xml(dir.join(settings_xml_filename), settings_xml_test_value); }) .env("MAVEN_SETTINGS_URL", SETTINGS_XML_URL), |context| { diff --git a/buildpacks/maven/tests/version_handling_tests.rs b/buildpacks/maven/tests/version_handling_tests.rs index ca4b5709..e8a697c3 100644 --- a/buildpacks/maven/tests/version_handling_tests.rs +++ b/buildpacks/maven/tests/version_handling_tests.rs @@ -5,6 +5,7 @@ use std::fs::OpenOptions; use std::path::Path; #[test] +#[ignore = "integration test"] fn with_wrapper() { TestRunner::default().build(default_config(), |context| { assert_not_contains!(context.pack_stdout, "Selected Maven version:"); @@ -15,6 +16,7 @@ fn with_wrapper() { } #[test] +#[ignore = "integration test"] fn with_wrapper_and_system_properties() { TestRunner::default().build( default_config().app_dir_preprocessor(|path| { @@ -36,6 +38,7 @@ fn with_wrapper_and_system_properties() { } #[test] +#[ignore = "integration test"] fn with_wrapper_and_unknown_system_properties() { TestRunner::default().build( default_config().app_dir_preprocessor(|path| set_maven_version_app_dir_preprocessor( @@ -49,6 +52,7 @@ fn with_wrapper_and_unknown_system_properties() { } #[test] +#[ignore = "integration test"] fn without_wrapper_and_without_system_properties() { TestRunner::default().build( default_config().app_dir_preprocessor(|path| { @@ -69,6 +73,7 @@ fn without_wrapper_and_without_system_properties() { } #[test] +#[ignore = "integration test"] fn without_wrapper_and_unknown_system_properties() { TestRunner::default().build( default_config().app_dir_preprocessor(|path| { @@ -83,6 +88,7 @@ fn without_wrapper_and_unknown_system_properties() { } #[test] +#[ignore = "integration test"] fn without_wrapper_and_maven_3_6_2_system_properties() { TestRunner::default().build( default_config().app_dir_preprocessor(|path| { @@ -100,6 +106,7 @@ fn without_wrapper_and_maven_3_6_2_system_properties() { } #[test] +#[ignore = "integration test"] fn without_wrapper_and_maven_3_5_4_system_properties() { TestRunner::default().build( default_config().app_dir_preprocessor(|path| { @@ -117,6 +124,7 @@ fn without_wrapper_and_maven_3_5_4_system_properties() { } #[test] +#[ignore = "integration test"] fn without_wrapper_and_maven_3_3_9_system_properties() { TestRunner::default().build( default_config().app_dir_preprocessor(|path| { @@ -134,6 +142,7 @@ fn without_wrapper_and_maven_3_3_9_system_properties() { } #[test] +#[ignore = "integration test"] fn without_wrapper_and_maven_3_2_5_system_properties() { TestRunner::default().build( default_config().app_dir_preprocessor(|path| { @@ -177,7 +186,7 @@ fn set_maven_version_app_dir_preprocessor(version: &str, path: &Path) { .unwrap(); let mut properties = java_properties::read(&mut properties_file).unwrap(); - properties.insert(String::from("maven.version"), version.clone()); + properties.insert(String::from("maven.version"), version); java_properties::write(&mut properties_file, &properties).unwrap(); } diff --git a/meta-buildpacks/java/README.md b/meta-buildpacks/java/README.md index 176769f7..90b283a6 100644 --- a/meta-buildpacks/java/README.md +++ b/meta-buildpacks/java/README.md @@ -1,5 +1,5 @@ # Heroku Cloud Native Java Buildpack -[![CircleCI](https://circleci.com/gh/heroku/buildpacks-jvm/tree/main.svg?style=shield)](https://circleci.com/gh/heroku/buildpacks-jvm/tree/main) +[![CI](https://github.com/heroku/buildpacks-jvm/actions/workflows/ci.yml/badge.svg)](https://github.com/heroku/buildpacks-jvm/actions/workflows/ci.yml) [![Registry](https://img.shields.io/badge/dynamic/json?url=https://registry.buildpacks.io/api/v1/buildpacks/heroku/java&label=version&query=$.latest.version&color=DF0A6B&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACSVJREFUaAXtWQ1sFMcVnp/9ub3zHT7AOEkNOMYYp4CQQFBLpY1TN05DidI2NSTF0CBFQAOBNrTlp0a14sipSBxIG6UYHKCO2ka4SXD4SUuaCqmoJJFMCapBtcGYGqMkDgQ4++52Z2e3b87es+/s+wNHVSUPsnZv9s2b97335v0MCI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AOwJI8gE9M9g2GGTIJUnMsgkAEQ6Yah3IDQAsIzUAEbmEGJJlsqW2jZ+DEr4Y7m2TCicEMFOcAXF4xRkx9eAbNy+fORcIZzHDJb8KGz4Ot9lUhwiTbEQAJLEAFOeQOyQUNINdjIWrIsbNy6sYr2quH0HS+DFVlImYi01itSW0D/8vgLLHjR/2TQgkah8Ra8HFTjGOa06f3A797SCTCwWry8DSVXBvWhoJBgksLlM/3N6rw1xICOoCwXXOAlAU1tvBqzumdL18JcY7cwp+MH2cJG8CaVZgqPBE/HeG2FSWZCTi9NAhHFxkXYOzbpvznd2dZ3b19Bwf8Qb3AJqpLCgsrYRC6ecqJjMM4A+lxFB2SCbiLlWGucF5RXRzFgNK6yAzwzX551+MVswxABxOefmP3etS5a2YSuVizjkfBAo9l0tzyCDbSqKC7YUIu/daOFB3pbUxrf721B0rc/w+9zrYfK2K5QlhcCvnfFCigUr6L0ucDA3KeR8iYO3U8y8M6+ZGBDAgIc0vWl5BEakiijQTYmhkWpEVEBwOELgUt+y3QtysuXT21ahGoujSePl3/qpiRVK2wO3KY1ClyuJ8YHATcDPIyhQFud6JbfKr1vZz+xehd0a8e08GICKC318xzpejrpUQ3UAkaZK4yoGU/HduWts72hsPpyFnSpL2wjWlFNFfSoSWipqIWVYP1J27rwcCL839eF9PMgYpATiLJ01eOs2jaU+D03508cK/9iHUkm6F4LBI+hTlc9m0BSsVSufcCBkvzu7afSHpgrGPYxoY00BEA/8FOPrYBqYsE44AAAAASUVORK5CYII=&labelColor=white)](https://registry.buildpacks.io/buildpacks/heroku/java) Heroku's official Cloud Native Buildpack for Java applications.