Skip to content

Commit

Permalink
[IT-937] Setup pre-commit, pipenv, and CI (Sage-Bionetworks#2)
Browse files Browse the repository at this point in the history
* Setup pre-commit[1] for linting python, yaml and cloudformation
  templates
* Setup pipenv[2] to manage python package dependencies
* Setup travis CI to automate build and deploy lambda to an S3 bucket
  for consumption
* add documentation

[1] https://pre-commit.com/
[2] https://pipenv-fork.readthedocs.io/en/latest/
  • Loading branch information
zaro0508 authored Aug 18, 2020
1 parent 85d67f6 commit 83a78c5
Show file tree
Hide file tree
Showing 7 changed files with 929 additions and 30 deletions.
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-ast
- repo: https://github.com/adrienverge/yamllint
rev: v1.24.2
hooks:
- id: yamllint
- repo: https://github.com/awslabs/cfn-python-lint
rev: v0.34.0
hooks:
- id: cfn-python-lint
files: template\.(json|yml|yaml)$
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.8
hooks:
- id: remove-tabs
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: python
python: 3.6
cache: pip
env:
- REPO_NAME="${PWD##*/}"
install:
- pip install pipenv
- pipenv install --dev
- wget https://github.com/Sage-Bionetworks/infra-utils/archive/master.zip -O /tmp/infra-utils.zip
- unzip -j -n /tmp/infra-utils.zip -x "infra-utils-master/.gitignore" "infra-utils-master/LICENSE" "infra-utils-master/*.md" "infra-utils-master/aws/*"
- ./setup_aws_cli.sh || travis_terminate 1
- export SAM_CLI_TELEMETRY=0
stages:
- name: validate
- name: deploy
if: (tag =~ ^v) OR (branch = master AND type = push)
jobs:
fast_finish: true
include:
- stage: validate
script:
- pre-commit run --all-files
- sam build
# - python -m pytest tests/ -v
- stage: deploy
script:
- sam build
- |
sam package --template-file .aws-sam/build/template.yaml \
--s3-bucket essentials-awss3lambdaartifactsbucket-x29ftznj6pqw \
--output-template-file .aws-sam/build/$REPO_NAME.yaml
- aws s3 cp .aws-sam/build/$REPO_NAME.yaml s3://bootstrap-awss3cloudformationbucket-19qromfd235z9/$REPO_NAME/$TRAVIS_BRANCH/
29 changes: 29 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

extends: default

rules:
braces:
level: warning
max-spaces-inside: 1
brackets:
level: warning
max-spaces-inside: 1
colons:
level: warning
commas:
level: warning
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
level: warning
hyphens:
level: warning
indentation:
level: warning
indent-sequences: consistent
line-length: disable
truthy: disable
new-line-at-end-of-file:
level: warning
18 changes: 18 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "~=2.5.3"
pytest = "~=6.0.1"
pytest-mock = "~=3.2.0"
pre-commit = "~=2.6.0"
responses = "~=0.10.15"
aws-sam-cli = "<2,>=1.1"

[packages]
synapseclient = "<3,>=2.1"

[requires]
python_version = "3.6"
Loading

0 comments on commit 83a78c5

Please sign in to comment.