Closed MatteoGioioso closed 4 years ago
Ok I have solved partially the issue by using the sam
container: sam build --use-container ...
However now I have another problem:
Running PythonPipBuilder:ResolveDependencies
Error: PythonPipBuilder:ResolveDependencies - Requirements file not found: /tmp/samcli/source/requirements.txt
I tried to run the same script in local:
sam build --use-container --build-dir mypath/build/ --template mypath/template.yaml
but the build is successful. The mounting output is similar for both local and in github actions.
Mounting /github/workspace/mypath/myfunction as /tmp/samcli/source:ro,delegated inside runtime container
Mounting /home/user/myprojectspath/mypath/myfunction as /tmp/samcli/source:ro,delegated inside runtime container
@MatteoGioioso Tractor Zoom isn't a python shop, we primarily work in Node.js, we need python to run the sam cli so this hasn't been extensively tested for development with python. The docker image we're using with this project is specifying python 3.8, so maybe you're having a clash of versions? https://github.com/TractorZoom/sam-cli-action/blob/8ed2396c177af435a69a9359499218c1f6b0f32a/Dockerfile#L1
I had the same bug as @MatteoGioioso. Ended up having to match all Python versions to Python3.8. Lambda function in the template.yml and the unit testing Python version from a GitHub action as well in the same template. I also specified the version of SAM to be 0.53
as 1.0 (latest)
still has a lot of quirks and bugs.
Here's my template for future reference:
name: Deploy SAM template
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
# Python unit test
- name: Install Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r myFolder/requirements.txt
pip install moto boto3
- name: Unittest XYZ
run: python my_unit_test.py
# AWS
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: SAM Build
uses: TractorZoom/sam-cli-action@master
with:
sam_command: "build -t my-template.yaml --debug"
sam_version: "0.53"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
- name: SAM Deploy
uses: TractorZoom/sam-cli-action@master
with:
sam_command: "deploy -t my-template.yaml \
--role-arn arn:aws:iam::00000000000:role/disMyRole \
--parameter-overrides ParameterKey=MyParameter,ParameterValue=MyValue \
--debug \
--no-fail-on-empty-changeset"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
The --use-container
flag returns a requirements.txt not found
error, not sure why that is an issue, but it works without that flag as well.
Describe the bug Hello there,
Not really sure this is a bug on your side or the
actions/setup-python@v1
package. Anyway I cannot run the build as the sam-cli cannot locate the python runtime. This is the error I got:To Reproduce This is my workflow.yaml file
Expected behavior Should local the python runtime
Thanks