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

chore: Release SAM CLI v0.22 #1413

Merged
merged 12 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
pip-wheel-metadata/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/python/black
rev: 19.3b0
hooks:
- id: black
language_version: python3.7
exclude_types: ['markdown', 'ini', 'toml']
19 changes: 16 additions & 3 deletions DEVELOPMENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,20 @@ easily setup multiple Python versions.
5. Make Python versions available in the project:
`pyenv local 3.6.8 2.7.14 3.7.2`

### 2. Activate Virtualenv
### 2. Install Additional Tooling
#### Black
We format our code using [Black](https://github.com/python/black) and verify the source code is black compliant
in Appveyor during PRs. You can find installation instructions on [Black's docs](https://black.readthedocs.io/en/stable/installation_and_usage.html).

After installing, you can run our formatting through our Makefile by `make black-format` or integrating Black directly in your favorite IDE (instructions
can be found [here](https://black.readthedocs.io/en/stable/editor_integration.html))

#### Pre-commit
If you don't wish to manually run black on each pr or install black manually, we have integrated black into git hooks through [pre-commit](https://pre-commit.com/).
After installing pre-commit, run `pre-commit install` in the root of the project. This will install black for you and run the black formatting on
commit.

### 3. Activate Virtualenv

Virtualenv allows you to install required libraries outside of the
Python installation. A good practice is to setup a different virtualenv
Expand All @@ -49,7 +62,7 @@ be the appropriate python version.
1. `pyenv virtualenv 3.7.2 samcli37`
2. `pyenv activate samcli37` for Python3.7

### 3. Install dev version of SAM CLI
### 4. Install dev version of SAM CLI

We will install a development version of SAM CLI from source into the
virtualenv for you to try out the CLI as you make changes. We will
Expand All @@ -60,7 +73,7 @@ SAM CLI installation, if any.
2. Install dev CLI: `make init`
3. Make sure installation succeeded: `which samdev`

### 4. (Optional) Install development version of SAM Transformer
### 5. (Optional) Install development version of SAM Transformer

If you want to run the latest version of [SAM
Transformer](https://github.com/awslabs/serverless-application-model/),
Expand Down
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,25 @@ func-test:

smoke-test:
# Smoke tests run in parallel
pytest -n 4 tests/functional

flake:
# Make sure code conforms to PEP8 standards
flake8 samcli
flake8 tests/unit tests/integration
SAM_CLI_DEV=1 pytest -n 4 tests/smoke

lint:
# Linter performs static analysis to catch latent bugs
pylint --rcfile .pylintrc samcli

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

black:
black samcli/* tests/* scripts/*

black-check:
black --check samcli/* tests/* scripts/*

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

update-isolated-req:
pipenv --three
pipenv run pip install -r requirements/base.txt
pipenv run pip freeze > requirements/isolated.txt
100 changes: 100 additions & 0 deletions appveyor-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
version: 1.0.{build}
image: Windows Server 2019
build: off

# Change the clone folder to somewhere in "D:\" because this is shared by default with Docker. We need this to mount folders.
clone_folder: D:\source

environment:
AWS_DEFAULT_REGION: us-east-1
SAM_CLI_DEV: 1

# In Windows, tempdir is usually in C:\. But in AppVeyor only D:\ is shared in Docker.
# Therefore change TEMPDIR it to D: for invoke tests to work. Python uses $TMPDIR envvar
# to find root of tempdir
TMPDIR: D:\tmp
TEMP: D:\tmp
TMP: D:\tmp

# MSI Installers only use Py3.6.6. It is sufficient to test with this version here.
PYTHON_HOME: "C:\\Python36-x64"
PYTHON_SCRIPTS: "C:\\Python36-x64\\Scripts"
PYTHON_EXE: "C:\\Python36-x64\\python.exe"
PYTHON_VERSION: '3.6.8'
PYTHON_ARCH: '64'
HOME: 'C:\Users\appveyor'
HOMEDRIVE: 'C:'
HOMEPATH: 'C:\Users\appveyor'

init:
# Uncomment this for RDP
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
- ps: gcim Win32_Processor | % { "$($_.NumberOfLogicalProcessors) logical CPUs" }
- ps: gcim Win32_OperatingSystem | % { "$([int]($_.TotalVisibleMemorySize/1mb)) Gb" }

cache:
- C:\ProgramData\chocolatey\bin -> appveyor.yml
- C:\ProgramData\chocolatey\lib -> appveyor.yml

install:

# Make sure the temp directory exists for Python to use.
- ps: "mkdir -Force D:\\tmp"
- "echo %PATH%"
- "python --version"

# Upgrade setuptools, wheel and virtualenv
- "python -m pip install --upgrade setuptools wheel virtualenv"

# Create new virtual environment with chosen python version and activate it
- "rm -rf venv"
- "dir C:\\Python36-x64"
- "virtualenv -p %PYTHON_EXE% venv"
- "venv\\Scripts\\activate"
- "python -c \"import sys; print(sys.executable)\""
- "python --version"

# Actually install SAM CLI's dependencies
- "pip install -e \".[dev]\""


# To run Nodejs workflow integ tests
- "choco install nodejs-lts -y --force"
- "refreshenv"
# setup Ruby
- "choco install ruby --version 2.5.3.1 --force -y"
- "refreshenv"
- "ruby --version"
- "gem --version"
- "gem install bundler -v 2.0.2"
- "refreshenv"
- "bundler --version"
- "echo %PATH%"

# setup Java, Maven and Gradle
- "refreshenv"
- "choco install jdk8 -y --force"
- "refreshenv"
- "choco install maven -y --force"
- "refreshenv"
- "choco install gradle -y --force"
- "refreshenv"
- "java -version"
- "gradle -v"
- "mvn --version"

# Switch to Docker Linux containers
- ps: Switch-DockerLinux

# Echo final Path
- "echo %PATH%"

test_script:
# Reactivate virtualenv before running tests
- "venv\\Scripts\\activate"
- "docker system prune -a -f"
- "pytest -vv tests/integration"

# Uncomment for RDP
# on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
12 changes: 7 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ image:
- Ubuntu
- Visual Studio 2017

configuration:
- smoke

environment:
AWS_DEFAULT_REGION: us-east-1
SAM_CLI_DEV: 1
Expand Down Expand Up @@ -56,6 +53,11 @@ for:
- sh: "sudo unzip -d /opt/gradle /tmp/gradle-*.zip"
- sh: "PATH=/opt/gradle/gradle-5.5/bin:$PATH"

# Install black
- sh: "wget -O /tmp/black https://github.com/python/black/releases/download/19.3b0/black"
- sh: "chmod +x /tmp/black"
- sh: "/tmp/black --version"

-
matrix:
only:
Expand All @@ -72,12 +74,12 @@ build_script:

test_script:
- "pytest --cov samcli --cov-report term-missing --cov-fail-under 95 tests/unit"
- "flake8 samcli"
- "flake8 tests/unit tests/integration"
- "pylint --rcfile .pylintrc samcli"

# Runs only in Linux
- sh: "pytest -vv tests/integration"
- sh: "/tmp/black --check setup.py tests samcli scripts"
- sh: "python scripts/check-isolated-needs-update.py"

# Smoke tests run in parallel - it runs on both Linux & Windows
# Presence of the RUN_SMOKE envvar will run the smoke tests
Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
requires = ["setuptools", "wheel"] # PEP 508 specifications.


[tool.black]
line-length = 120
target_version = ['py37', 'py27', 'py36']
exclude = '''

(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.tox
| \.venv
| build
| dist
| pip-wheel-metadata
| samcli/local/init/templates
)/
)
'''
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
env =
AWS_DEFAULT_REGION = ap-southeast-1

filterwarnings =
error
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Flask~=1.0.2
boto3~=1.9, >=1.9.56
PyYAML~=5.1
cookiecutter~=1.6.0
aws-sam-translator==1.11.0
aws-sam-translator==1.14.0
docker~=4.0
dateparser~=0.7
python-dateutil~=2.6
Expand Down
1 change: 0 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
coverage==4.3.4
flake8==3.3.0
tox==2.2.1
pytest-cov==2.4.0
# astroid > 2.0.4 is not compatible with pylint1.7
Expand Down
39 changes: 39 additions & 0 deletions requirements/isolated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
arrow==0.15.2
attrs==19.1.0
aws-lambda-builders==0.4.0
aws-sam-translator==1.14.0
binaryornot==0.4.4
boto3==1.9.228
botocore==1.12.228
certifi==2019.9.11
chardet==3.0.4
chevron==0.13.1
Click==7.0
cookiecutter==1.6.0
dateparser==0.7.1
docker==4.0.2
docutils==0.15.2
Flask==1.0.4
future==0.17.1
idna==2.8
itsdangerous==1.1.0
Jinja2==2.10.1
jinja2-time==0.2.0
jmespath==0.9.4
jsonschema==3.0.2
MarkupSafe==1.1.1
poyo==0.5.0
pyrsistent==0.15.4
python-dateutil==2.8.0
pytz==2019.2
PyYAML==5.1.2
regex==2019.8.19
requests==2.22.0
s3transfer==0.2.1
serverlessrepo==0.1.9
six==1.11.0
tzlocal==2.0.0
urllib3==1.25.3
websocket-client==0.56.0
Werkzeug==0.15.6
whichcraft==0.6.1
2 changes: 1 addition & 1 deletion samcli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
SAM CLI version
"""

__version__ = '0.21.0'
__version__ = "0.22.0"
4 changes: 2 additions & 2 deletions samcli/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"samcli.commands.package",
"samcli.commands.deploy",
"samcli.commands.logs",
"samcli.commands.publish"
"samcli.commands.publish",
]

DEPRECATION_NOTICE = (
Expand Down Expand Up @@ -85,7 +85,7 @@ def _set_commands(package_names):
commands = OrderedDict()

for pkg_name in package_names:
cmd_name = pkg_name.split('.')[-1]
cmd_name = pkg_name.split(".")[-1]
commands[cmd_name] = pkg_name

return commands
Expand Down
7 changes: 3 additions & 4 deletions samcli/cli/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def debug(self, value):

if self._debug:
# Turn on debug logging
logging.getLogger('samcli').setLevel(logging.DEBUG)
logging.getLogger('aws_lambda_builders').setLevel(logging.DEBUG)
logging.getLogger("samcli").setLevel(logging.DEBUG)
logging.getLogger("aws_lambda_builders").setLevel(logging.DEBUG)

@property
def region(self):
Expand Down Expand Up @@ -135,5 +135,4 @@ def _refresh_session(self):
the Boto3's session object are read-only. Therefore when Click parses new AWS session related properties (like
region & profile), it will call this method to create a new session with latest values for these properties.
"""
boto3.setup_default_session(region_name=self._aws_region,
profile_name=self._aws_profile)
boto3.setup_default_session(region_name=self._aws_region, profile_name=self._aws_profile)
6 changes: 3 additions & 3 deletions samcli/cli/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def config_dir(self):
if not self._config_dir:
# Internal Environment variable to customize SAM CLI App Dir. Currently used only by integ tests.
app_dir = os.getenv("__SAM_CLI_APP_DIR")
self._config_dir = Path(app_dir) if app_dir else Path(click.get_app_dir('AWS SAM', force_posix=True))
self._config_dir = Path(app_dir) if app_dir else Path(click.get_app_dir("AWS SAM", force_posix=True))
return Path(self._config_dir)

@property
Expand Down Expand Up @@ -106,7 +106,7 @@ def telemetry_enabled(self):
# If environment variable is set, its value takes precedence over the value from config file.
env_name = "SAM_CLI_TELEMETRY"
if env_name in os.environ:
return os.getenv(env_name) in ('1', 1)
return os.getenv(env_name) in ("1", 1)

try:
self._telemetry_enabled = self._get_value(TELEMETRY_ENABLED_KEY)
Expand Down Expand Up @@ -200,7 +200,7 @@ def _set_json_cfg(self, filepath, key, value, json_body=None):
json_body[key] = value
file_body = json.dumps(json_body, indent=4) + "\n"
try:
with open(str(filepath), 'w') as f:
with open(str(filepath), "w") as f:
f.write(file_body)
except IOError as ex:
LOG.debug("Error writing to {filepath}", exc_info=ex)
Expand Down
Loading