aws / aws/aws-sam-cli

Bug: build-and-package step failing in github actions

Open
#6,221 6 comments 0 reactions 0 assignees View on GitHub
area/build area/esbuild
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:
Followed the standard steps in the AWS SAM Workshop to create a TypeScript lambda function for a Hello World API. At the step to implement CI/CD with Github Actions (https://catalog.workshops.aws/complete-aws-sam/en-US/module-4-cicd/module-4-cicd-gh/50-sampipeinit) received the following error in the build-and-package job, "Build resources" step:

Run sam build --template ${SAM_TEMPLATE} --use-container

SAM CLI now collects telemetry to better understand customer needs.

You can OPT OUT and disable telemetry collection by setting the
environment variable SAM_CLI_TELEMETRY=0 in your shell.
Thanks for your help!

Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html

Starting Build use cache
Starting Build inside a container
Cache is invalid, running build and copying resources for following functions (HelloWorldFunction)
Building codeuri: /home/runner/work/sam-app/sam-app/hello-world runtime: nodejs[18](https://github.com/domaa11/sam-app/actions/runs/6792663600/job/18466312061#step:4:19).x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es[20](https://github.com/domaa11/sam-app/actions/runs/6792663600/job/18466312061#step:4:21)20', 'Sourcemap': True, 'EntryPoints': ['app.ts']}} architecture: x86_64 functions: HelloWorldFunction

Fetching public.ecr.aws/sam/build-nodejs18.x:latest-x86_64 Docker container image........................................................................................................................................................................................................................................................................................................................................................................................................................................
Mounting /home/runner/work/sam-app/sam-app/hello-world as /tmp/samcli/source:ro,delegated, inside runtime container

Build Failed
Running NodejsNpmEsbuildBuilder:CopySource
Running NodejsNpmEsbuildBuilder:NpmInstall
Running NodejsNpmEsbuildBuilder:EsbuildBundle
Error: NodejsNpmEsbuildBuilder:EsbuildBundle - Esbuild Failed: Cannot find esbuild. esbuild must be installed on the host machine to use this feature. It is recommended to be installed on the PATH, but can also be included as a project dependency.
Error: Process completed with exit code 1.

### Steps to reproduce:
Follow the AWS SAM Workshop until this step (using a HelloWorld TypeScript API, with Github Actions): https://catalog.workshops.aws/complete-aws-sam/en-US/module-4-cicd/module-4-cicd-gh/50-sampipeinit

After the following steps:
```cd ~/environment/sam-app
git add .
git commit -m "Adding SAM CI/CD Pipeline definition"
git push
```

### Observed result:
Received the following error in the build-and-package job, "Build resources" step:

Run sam build --template ${SAM_TEMPLATE} --use-container

SAM CLI now collects telemetry to better understand customer needs.

You can OPT OUT and disable telemetry collection by setting the
environment variable SAM_CLI_TELEMETRY=0 in your shell.
Thanks for your help!

Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html

Starting Build use cache
Starting Build inside a container
Cache is invalid, running build and copying resources for following functions (HelloWorldFunction)
Building codeuri: /home/runner/work/sam-app/sam-app/hello-world runtime: nodejs[18](https://github.com/domaa11/sam-app/actions/runs/6792663600/job/18466312061#step:4:19).x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es[20](https://github.com/domaa11/sam-app/actions/runs/6792663600/job/18466312061#step:4:21)20', 'Sourcemap': True, 'EntryPoints': ['app.ts']}} architecture: x86_64 functions: HelloWorldFunction

Fetching public.ecr.aws/sam/build-nodejs18.x:latest-x86_64 Docker container image........................................................................................................................................................................................................................................................................................................................................................................................................................................
Mounting /home/runner/work/sam-app/sam-app/hello-world as /tmp/samcli/source:ro,delegated, inside runtime container

Build Failed
Running NodejsNpmEsbuildBuilder:CopySource
Running NodejsNpmEsbuildBuilder:NpmInstall
Running NodejsNpmEsbuildBuilder:EsbuildBundle
Error: NodejsNpmEsbuildBuilder:EsbuildBundle - Esbuild Failed: Cannot find esbuild. esbuild must be installed on the host machine to use this feature. It is recommended to be installed on the PATH, but can also be included as a project dependency.
Error: Process completed with exit code 1.

### Expected result:
Build Succeeded

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

This is my local machine (sand running `sam build` builds successfully locally. The issue above is in the Github Actions environemnt.
```
sam --info
{
"version": "1.100.0",
"system": {
"python": "3.8.13",
"os": "macOS-12.7-x86_64-i386-64bit"
},
"additional_dependencies": {
"docker_engine": "20.10.22",
"aws_cdk": "Not available",
"terraform": "Not available"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.