Skip to content

Commit

Permalink
Merge from aws/aws-sam-cli/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-sam-cli-bot authored Aug 9, 2023
2 parents 6b94038 + 17b25eb commit da9f1b5
Show file tree
Hide file tree
Showing 138 changed files with 7,112 additions and 1,251 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/automated-updates-to-sam-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ jobs:
with:
repository: aws/aws-sam-cli
path: aws-sam-cli

- uses: actions/setup-python@v4 # used for make update-reproducible-reqs below
with:
python-version: |
3.8
3.11

- name: Update aws-sam-translator & commit
run: |
Expand All @@ -90,7 +84,7 @@ jobs:
SAM_T_PRE_VERSION=$(grep "aws-sam-translator=" requirements/base.txt)
echo "SAM-T pre version is $SAM_T_PRE_VERSION"
git reset --hard develop
sed -i "s/$SAM_T_PRE_VERSION/aws-sam-translator==$SAM_T_CUR_VERSION/g" requirements/base.txt; make update-reproducible-reqs
sed -i "s/$SAM_T_PRE_VERSION/aws-sam-translator==$SAM_T_CUR_VERSION/g" requirements/base.txt
cp -r ../serverless-application-model/tests/translator/input ./tests/functional/commands/validate/lib/models
git status
git diff --quiet && exit 0 # exit if there is no change
Expand Down Expand Up @@ -129,12 +123,6 @@ jobs:
repository: aws/aws-sam-cli
path: aws-sam-cli

- uses: actions/setup-python@v4 # used for make update-reproducible-reqs below
with:
python-version: |
3.8
3.11
- name: Upgrade aws_lambda_builders & commit
run: |
git config --global user.email "[email protected]"
Expand All @@ -147,7 +135,7 @@ jobs:
BUILDERS_PRE_VERSION=$(grep "aws_lambda_builders=" requirements/base.txt)
echo "Lambda Builders pre version is $BUILDERS_PRE_VERSION"
git reset --hard develop
sed -i "s/$BUILDERS_PRE_VERSION/aws_lambda_builders==$BUILDERS_CUR_VERSION/g" requirements/base.txt; make update-reproducible-reqs
sed -i "s/$BUILDERS_PRE_VERSION/aws_lambda_builders==$BUILDERS_CUR_VERSION/g" requirements/base.txt
git status
git diff --quiet && exit 0 # exit if there is no change
echo "is_new_lambda_builders=1" >> $GITHUB_ENV # set env variable for next step run decision
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ jobs:
runs-on: ubuntu-latest
needs:
- make-pr
- validate-schema
- integration-tests
- smoke-and-functional-tests
- docker-disabled
steps:
- name: report-failure
if : |
needs.make-pr.result != 'success' ||
needs.validate-schema.result != 'success' ||
needs.integration-tests.result != 'success' ||
needs.smoke-and-functional-tests.result != 'success' ||
needs.docker-disabled.result != 'success'
Expand Down Expand Up @@ -64,6 +66,27 @@ jobs:
- run: make init
- run: make pr

validate-schema:
name: Validate JSON schema
if: github.repository_owner == 'aws'
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python 3.11
with:
python-version: 3.11
- run: make init
- run: |
diff <( cat schema/samcli.json ) <( python schema/make_schema.py; cat schema/samcli.json ) && exit 0 # exit if schema is unchanged
echo "The generated schema differs from that in the PR. Please run 'make schema'."
exit 1
name: Generate and compare the schema
shell: bash
integration-tests:
name: Integration Tests / ${{ matrix.os }} / ${{ matrix.python }} / ${{ matrix.tests_folder }}
if: github.repository_owner == 'aws'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
apply-internal-external-label:
needs: apply-file-based-labels
if: ${{ always() }}
permissions:
pull-requests: write
runs-on: ubuntu-latest
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/update-reproducibles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update reproducible requirements
on:
pull_request:
branches: [develop]
paths:
- requirements/base.txt # run this GHA only if requirements file is changed

jobs:
update-reqs:
permissions:
pull-requests: write
contents: write
if: github.repository_owner == 'aws'
strategy:
matrix:
include:
- os: ubuntu-latest
python: 3.11
target: update-reproducible-linux-reqs
- os: macos-latest
python: 3.8
target: update-reproducible-mac-reqs
- os: windows-latest
python: 3.8
target: update-reproducible-win-reqs
max-parallel: 1
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- run: make ${{ matrix.target }}
- name: Push changes
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -am "Update reproducibles: ${{ matrix.target }}" || echo "nothing to commit"
git push
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
# environment variable.
SAM_CLI_TELEMETRY ?= 0

.PHONY: schema

init:
SAM_CLI_DEV=1 pip install -e '.[dev]'

test:
# Run unit tests
# Fail if coverage falls below 95%
pytest --cov samcli --cov-report term-missing --cov-fail-under 94 tests/unit
pytest --cov samcli --cov schema --cov-report term-missing --cov-fail-under 94 tests/unit

test-cov-report:
# Run unit tests with html coverage report
pytest --cov samcli --cov-report html --cov-fail-under 94 tests/unit
pytest --cov samcli --cov schema --cov-report html --cov-fail-under 94 tests/unit

integ-test:
# Integration tests don't need code coverage
Expand All @@ -34,24 +36,27 @@ smoke-test:

lint:
# Linter performs static analysis to catch latent bugs
ruff samcli
ruff samcli schema
# mypy performs type check
mypy --exclude /testdata/ --exclude /init/templates/ --no-incremental setup.py samcli tests
mypy --exclude /testdata/ --exclude /init/templates/ --no-incremental setup.py samcli tests schema

# Command to run everytime you make changes to verify everything works
dev: lint test

black:
black setup.py samcli tests
black setup.py samcli tests schema

black-check:
black --check setup.py samcli tests
black --check setup.py samcli tests schema

format: black
ruff samcli --fix

schema:
python schema/make_schema.py

# Verifications to run before sending a pull request
pr: init dev black-check
pr: init dev schema black-check

# (jfuss) We updated to have two requirement files, one for mac and one for linux. This
# is meant to be a short term fix when upgrading the Linux installer to be python3.11 from
Expand All @@ -70,4 +75,13 @@ update-reproducible-mac-reqs:
venv-update-reproducible-mac/bin/pip install -r requirements/base.txt
venv-update-reproducible-mac/bin/pip-compile --generate-hashes --allow-unsafe -o requirements/reproducible-mac.txt

# note that this should be run on a windows environment with python3.8 as default interpreter
update-reproducible-win-reqs:
python -m venv venv-update-reproducible-win
.\venv-update-reproducible-win\Scripts\activate
pip install --upgrade pip-tools pip
pip install -r requirements\base.txt
pip-compile --generate-hashes --allow-unsafe -o requirements\reproducible-win.txt


update-reproducible-reqs: update-reproducible-linux-reqs update-reproducible-mac-reqs
Loading

0 comments on commit da9f1b5

Please sign in to comment.