Skip to content
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

Update project.toml includes and excludes to respect repository root #1043

Merged
merged 4 commits into from
Feb 1, 2021

Conversation

dwillist
Copy link
Contributor

Signed-off-by: dwillist dthornton@vmware.com

Summary

Fixes issue where files were filtered against the include and exclude sections in project.toml as absolute paths.
Given the following application:

.
├── node_modules
├── package.json
├── package-lock.json
├── project.toml
├── README.md
└── server.js

and the following contents of project.toml (which uses .gitignore syntax)

[build]
include = [
  "src/", 
  "/package.json",
  "/package-lock.json",
  "/node_modules",
]

/package.json would be interpreted as a file at the root of your filesystem.

Before

After

Documentation

  • Should this change be documented?
    • Yes, see #___
    • No

Related

Resolves #987

Signed-off-by: dwillist <dthornton@vmware.com>
@dwillist dwillist requested a review from a team as a code owner January 27, 2021 21:18
@github-actions github-actions bot added this to the 0.17.0 milestone Jan 27, 2021
@github-actions github-actions bot added the type/enhancement Issue that requests a new feature or improvement. label Jan 27, 2021
@codecov
Copy link

codecov bot commented Jan 27, 2021

Codecov Report

Merging #1043 (ba035e6) into release/0.17.0-rc1 (78a5f8a) will decrease coverage by 0.02%.
The diff coverage is 60.00%.

Impacted file tree graph

@@                  Coverage Diff                   @@
##           release/0.17.0-rc1    #1043      +/-   ##
======================================================
- Coverage               80.23%   80.21%   -0.01%     
======================================================
  Files                     130      130              
  Lines                    7990     7998       +8     
======================================================
+ Hits                     6410     6415       +5     
- Misses                   1160     1163       +3     
  Partials                  420      420              
Flag Coverage Δ
os_linux 79.60% <66.67%> (+0.01%) ⬆️
os_macos 76.92% <66.67%> (+0.01%) ⬆️
os_windows 80.13% <60.00%> (-0.01%) ⬇️
unit 79.60% <66.67%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@dfreilich dfreilich changed the base branch from main to release/0.17.0-rc1 January 28, 2021 12:09
Signed-off-by: dwillist <dthornton@vmware.com>
@github-actions github-actions bot added the type/chore Issue that requests non-user facing changes. label Jan 28, 2021
Signed-off-by: dwillist <dthornton@vmware.com>
Copy link
Member

@dfreilich dfreilich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool Cat

UA:

Using this repo: https://github.com/bervol/buildpack-nodejs-poc, with this project.toml:

[build]
include = [
    "/src",
    "/package.json",
    "/package-lock.json",
    "/nest-cli.json",
    "/tsconfig.*json",
]

Before with old project.toml (and after having run npm install

$  pack build test-old-project-toml
base: Pulling from paketobuildpacks/builder
Digest: sha256:16adfeaabc798a524003c0af313471c094c430c7236006b89d1d53c08dcf5c26
Status: Image is up to date for paketobuildpacks/builder:base
base-cnb: Pulling from paketobuildpacks/run
Digest: sha256:1f7e8b4faa102c3c58474632b5366965c3a5765bb156e1ac77b16eb49bcc1086
Status: Image is up to date for paketobuildpacks/run:base-cnb
===> DETECTING
3 of 4 buildpacks participating
paketo-buildpacks/node-engine 0.1.5
paketo-buildpacks/npm-install 0.2.4
paketo-buildpacks/npm-start   0.0.3
===> ANALYZING
Previous image with name "test-old-project-toml" not found
===> RESTORING
===> BUILDING
Paketo Node Engine Buildpack 0.1.5
  Resolving Node Engine version
    Candidate version sources (in priority order):
                -> ""
      <unknown> -> "*"

    Selected Node Engine version (using ): 14.15.4

  Executing build process
    Installing Node Engine 14.15.4
      Completed in 7.271s

  Configuring environment
    NODE_ENV     -> "production"
    NODE_HOME    -> "/layers/paketo-buildpacks_node-engine/node"
    NODE_VERBOSE -> "false"

    Writing profile.d/0_memory_available.sh
      Calculates available memory based on container limits at launch time.
      Made available in the MEMORY_AVAILABLE environment variable.

Paketo NPM Install Buildpack 0.2.4
  Resolving installation process
    Process inputs:
      node_modules      -> "Found"
      npm-cache         -> "Not found"
      package-lock.json -> "Found"

    Selected NPM build process: 'npm rebuild'

  Executing build process
unlinkat /workspace/node_modules/acorn-globals/package.json: permission denied
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 145

Before w/ updated project.toml

$  pack build test -p /tmp/bp-nodejs-poc/
...
Status: Downloaded newer image for paketobuildpacks/run:base-cnb
===> DETECTING
ERROR: No buildpack groups passed detection.
ERROR: Please check that you are running against the correct path.
ERROR: failed to detect: no buildpacks participating
ERROR: failed to build: executing lifecycle: failed with status code: 100

After:

$  out/pack build test -p /tmp/bp-nodejs-poc/
base: Pulling from paketobuildpacks/builder
Digest: sha256:16adfeaabc798a524003c0af313471c094c430c7236006b89d1d53c08dcf5c26
Status: Image is up to date for paketobuildpacks/builder:base
base-cnb: Pulling from paketobuildpacks/run
Digest: sha256:1f7e8b4faa102c3c58474632b5366965c3a5765bb156e1ac77b16eb49bcc1086
Status: Image is up to date for paketobuildpacks/run:base-cnb
===> DETECTING
3 of 4 buildpacks participating
paketo-buildpacks/node-engine 0.1.5
paketo-buildpacks/npm-install 0.2.4
paketo-buildpacks/npm-start   0.0.3
===> ANALYZING
Restoring metadata for "paketo-buildpacks/node-engine:node" from app image
Restoring metadata for "paketo-buildpacks/npm-install:modules" from app image
Restoring metadata for "paketo-buildpacks/npm-install:npm-cache" from app image
===> RESTORING
Removing "paketo-buildpacks/node-engine:node", not in cache
Removing "paketo-buildpacks/npm-install:modules", not in cache
Removing "paketo-buildpacks/npm-install:npm-cache", not in cache
===> BUILDING
Paketo Node Engine Buildpack 0.1.5
  Resolving Node Engine version
    Candidate version sources (in priority order):
                -> ""
      <unknown> -> "*"

    Selected Node Engine version (using ): 14.15.4

  Executing build process
    Installing Node Engine 14.15.4
      Completed in 8.006s

  Configuring environment
    NODE_ENV     -> "production"
    NODE_HOME    -> "/layers/paketo-buildpacks_node-engine/node"
    NODE_VERBOSE -> "false"

    Writing profile.d/0_memory_available.sh
      Calculates available memory based on container limits at launch time.
      Made available in the MEMORY_AVAILABLE environment variable.

Paketo NPM Install Buildpack 0.2.4
  Resolving installation process
    Process inputs:
      node_modules      -> "Not found"
      npm-cache         -> "Not found"
      package-lock.json -> "Found"

    Selected NPM build process: 'npm ci'

  Executing build process
    Running 'npm ci --unsafe-perm --cache /layers/paketo-buildpacks_npm-install/npm-cache'
      Completed in 9.169s

  Configuring environment
    NPM_CONFIG_LOGLEVEL   -> "error"
    NPM_CONFIG_PRODUCTION -> "true"
    PATH                  -> "$PATH:/layers/paketo-buildpacks_npm-install/modules/node_modules/.bin"

Paketo NPM Start Buildpack 0.0.3
  Assigning launch processes
    web: nest start
===> EXPORTING
Reusing layer 'paketo-buildpacks/node-engine:node'
Reusing layer 'paketo-buildpacks/npm-install:modules'
Adding layer 'paketo-buildpacks/npm-install:npm-cache'
Reusing 1/1 app layer(s)
Reusing layer 'launcher'
Reusing layer 'config'
Reusing layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'web'
*** Images (aa3f9bfd7c7c):
      test
Adding cache layer 'paketo-buildpacks/node-engine:node'
Adding cache layer 'paketo-buildpacks/npm-install:modules'
Adding cache layer 'paketo-buildpacks/npm-install:npm-cache'
Successfully built image test

Signed-off-by: dwillist <dthornton@vmware.com>
@dwillist dwillist merged commit 5a0e31f into release/0.17.0-rc1 Feb 1, 2021
@dwillist dwillist deleted the 987_unlink_at_bug branch February 1, 2021 20:22
@dfreilich dfreilich removed the type/chore Issue that requests non-user facing changes. label Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
2 participants