buildpacks icon indicating copy to clipboard operation
buildpacks copied to clipboard

Add support for file ignoring in builds

Open ace-n opened this issue 4 years ago • 3 comments

cc @grant @di

We should have some (well-documented) mechanism for ignoring files.

(Ignored files can result in unnecessary build failures - e.g. the Python GCF builder fails if your .nox folder is out of date.)

=== Python - Functions Framework ([email protected]) ===
--------------------------------------------------------------------------------
Running "python3 -m compileall -f -q ."
*** Error compiling './.nox/py-3-7/lib/python3.7/site-packages/uuid.py'...
  File "./.nox/py-3-7/lib/python3.7/site-packages/uuid.py", line 138
    if not 0 <= time_low < 1<<32L:
                                ^
SyntaxError: invalid syntax

Done "python3 -m compileall -f -q ." (3.2263624s)
Failure: (ID: 49c34848) *** Error compiling './.nox/py-3-7/lib/python3.7/site-packages/uuid.py'...
  File "./.nox/py-3-7/lib/python3.7/site-packages/uuid.py", line 138
    if not 0 <= time_low < 1<<32L:
                                ^
SyntaxError: invalid syntax

ace-n avatar Sep 23 '20 23:09 ace-n

Seems like .gcloudignore would be the appropriate tool to use here.

I also feel like this is overkill for just checking syntax of the user's function, but I don't have anything better:

https://github.com/GoogleCloudPlatform/buildpacks/blob/410b552aba55404bdb45acb638112feb271de01f/cmd/python/functions_framework/main.go#L57-L58

di avatar Sep 24 '20 00:09 di

IIRC we added this check because functions would often fail at run time and it was difficult for customers to access the logs to determine the failure reason.

.gcloudignore is documented as a way to ignore files in GCF and project.toml build>exclude field when using the builders directly with pack.

lukasberger avatar Sep 24 '20 00:09 lukasberger

Adding to this, CNB has a mechism to mark files as included/excluded per build. We recently had to answer a question around this in the discussion https://github.com/GoogleCloudPlatform/buildpacks/discussions/301

the nuance here is that pack expects the 0.1 spec by default, and most of the CNB docs show the 0.2 spec. So docs on https://cloud.google.com/docs/buildpacks/overview would probably make it a bit easier to apply onto GCP projects

jama22 avatar May 30 '23 22:05 jama22