Skip to content

Commit

Permalink
Replace heroku/nodejs-engine with libcnb.rs implementation (#184)
Browse files Browse the repository at this point in the history
* Add a rudimentary nodejs buildpack

* Add rudimentary shared lib for libcnb buildpacks

* s/ruby/node

* Move package_json into it's own mod

* Bring in resolve-version.rs

* Use node-semver over semver

* Add resolve-version.rs bins

* Rename version bins

* Move version parsing to lib

* Refactor and deserialize package.json versions as node semver requirements

* Move version to versions

* Move libnodejs to libcncb-nodejs

* Parse requested node version from package.json

* Get version detection and resolution working

* Cache and reuse if node version hasn't changed

* Use compile target to determine default release

* Drop debug lines

* s/Software/Inventory

* s/RuntimeLayer/DistLayer/

* Detect server.js or index.js as default process

* Add integration tests for nodejs-runtime

* Drop inventory dir

* Set provides and requires for nodejs-runtime

* Use layer metadata to evaluate dist layer reuse

* Use cargo workspaces

* Create set_web_concurrency.rs

* Set WEB_CONCURRENCY via exec.d

* Attempt to read memory from cgroups v2 and cgroups v1 as a fallback

* Replace nodejs-engine with nodejs-runtime

* Drop extra Cargo.lock

* Update libcnb-test dependency to use git over local

* Update buildpack.toml with homepage

* Drop reqwest,tokio,openssl

* Use released libcnb versions

* WebLayer -> WebEnvLayer

* Drop util in favor of libherokubuildpack

* Improve error typing

* Improve error messaging

* Run rust fmt

* Add error messaging

* Use libherokubuildpack logging

* Update integration tests to match new logging

* Adjust detection conditions

* Add cargo test and rust fmt to circle build

* Install pack-cli in circle builds

* Don't run shpec on nodejs-engine

* Add a nodejs-engine build script

* Use the machine executor for cargo test

* Bump nodejs-engine in test/meta-buildpacks

* Add missing build.sh script

* Don't setup remote docker for cargo test

* Install rust when packaging buildpacks

* Install rust when running cutlass tests

* Use release target for build.sh

* Update nodejs-engine version for meta-buildpacks test

* yarn buildpack should install it's own yj

* Add missing logging functionality to yarn buildpack

* Include [types] table for the toolbox

* npm buildpack should install it's own yj

* Fix shellcheck issue

* Restore lost messaging

* Adjust messaging expectations

* Fix more shell linting issues

* Update all buildpacks to 0.6

* Add [types] table to a few layers to support newer buildpack api

* Adjust nodejs-engine logging

* Apply cargo fmt

* Update changelogs

* Move nodejs to dist layer bin so that PATH changes aren't required

* Run clippy in CI

* Apply clippy

* Fix linting issues

* Drop superfluous postfix on error variants

* Additional lint fixes

* Update the nodejs-engine README

* Update root README.md

* Adjust casing for keywords

* s/libcnb-nodejs/libhkcnb-nodejs/

* Prune dependencies

* Get a little more critical with lints

* Add #[must_use] where appropriate

* Allow module_name_repetitions

* Drop unused tempfile crate form libhkcnb-nodejs

* Update lockfile

* Add missing Cargo.toml fields

* Address clippy::missing_errors_doc

* Add a small README.md for libhkcnb-nodejs

* Address clippy::cargo_common_metadata

* Specify rust version

* Resolve clippy::single_char_pattern

* Apply additional clippy fixes

* More cargo fmt

* Split inventory functionality out into inv package

* Move inventory read functionality into lib

* Cargo fmt

* Rename Ver and Req to Version and Requirement

* Rename versions::Ver,Req to vrs::Version,Requirement

* Update libhkcnb-nodejs/src/package_json.rs

Co-authored-by: Manuel Fuchs <manuel.fuchs@salesforce.com>

* Improve launchjs detection

* Drop a few lets in version_range fetching

* Simplify detection

* Simplify layer initialization

* Use StackId from libcnb::data

* Use derived Eq to detect layer strategy

* Create helper function for initializing metadata

* Update .circleci/config.yml

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Update .circleci/config.yml

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Fix clippy command in CI

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Drop superfluous .buildpacks call in test

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Drop superfluous .buildpacks call in test

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Update base image for CI tests

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Output files checked with cargo fmt

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Refactor web_env

* Add clippy pedantic in more places

* Remove unused dependency in integration test

* Break apart integration and unit tests, fix CI

* Import test dependencies to silence unused dep clippy

* Use 1.58 as minimum rust version

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Update README.md dependencies

* Don't install libcnb-cargo for integration tests

* Set publish = false and drop cargo metadata

Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>

* Update cargo manifests

* Drop 'Buildpack' suffix from buildpack name

* Upgrade to libcnb-test 0.3.0

* Use assert_contains from libcnb-test

* Use assert_contains from libcnb_test

* Move shared rust lib to common/nodejs-utils

* Group and organize use statements

* Bump minor versions for yarn and npm buildpacks

* Update test meta-buildpacks to point at new npm/yarn buildpack versions

Co-authored-by: Manuel Fuchs <manuel.fuchs@salesforce.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 9, 2022
1 parent 23f609e commit 235de40
Show file tree
Hide file tree
Showing 61 changed files with 11,634 additions and 1,740 deletions.
60 changes: 55 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,21 @@ orbs:
install-build-dependencies:
steps:
- run:
name: "Install rsync, jq via apt"
command: sudo apt-get update && sudo apt-get install -y rsync jq
name: "Install rsync, jq, and musl-tools via apt"
command: sudo apt-get update && sudo apt-get install -y --no-install-recommends rsync jq musl-tools
- install-yq
install-rust:
steps:
- run:
name: "Install rustc 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
install-libcnb-cargo:
steps:
- run:
name: "Install libcnb-cargo"
command: cargo install libcnb-cargo

jobs:
package-buildpack:
Expand All @@ -33,8 +45,10 @@ jobs:
- checkout
- setup_remote_docker
- pack/install-pack:
version: 0.23.0
version: 0.24.0
- heroku-buildpacks/install-build-dependencies
- heroku-buildpacks/install-rust
- heroku-buildpacks/install-libcnb-cargo
- run:
name: "Build and package buildpack with retries"
command: |
Expand All @@ -61,9 +75,11 @@ jobs:
steps:
- checkout
- pack/install-pack:
version: 0.23.0
version: 0.24.0
- ruby/install-deps
- heroku-buildpacks/install-build-dependencies
- heroku-buildpacks/install-rust
- heroku-buildpacks/install-libcnb-cargo
- run:
name: "Run rspec tests against a given directory"
command: |
Expand Down Expand Up @@ -110,16 +126,50 @@ jobs:
name: Shpec unit tests on heroku-<<parameters.stack-version>>
command: shpec << parameters.buildpack-dir >>/shpec/*_shpec.sh

rust-integration-test:
machine:
image: ubuntu-2004:202201-02
steps:
- checkout
- pack/install-pack:
version: 0.24.0
- heroku-buildpacks/install-build-dependencies
- heroku-buildpacks/install-rust
- run:
command: cargo test --locked -- --ignored

rust-unit-test:
docker:
- image: cimg/rust:1.59
steps:
- checkout
- run:
command: cargo test --locked

rust-linting:
docker:
- image: cimg/rust:1.59
steps:
- checkout
- run:
name: rustfmt
command: cargo fmt -- --check --verbose
- run:
name: clippy
command: cargo clippy --all-targets --all-features --locked -- --deny warnings

workflows:
version: 2
ci:
jobs:
- shell-linting
- rust-linting
- rust-unit-test
- rust-integration-test
- shpec:
matrix:
parameters:
buildpack-dir:
- "buildpacks/nodejs-engine"
- "buildpacks/nodejs-function-invoker"
- "buildpacks/npm"
stack-version:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
dist/
node_modules/
package-lock.json
.tool-versions

**/target/

Expand Down
Loading

0 comments on commit 235de40

Please sign in to comment.