From f27200b29cb39a9114ee4f21660e67e0e83554b7 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 26 Sep 2020 11:40:18 -0400 Subject: [PATCH] ci: base (#2) * ci: base * ci: missing bit * ci: pyenv via action * ci: typos * ci: deps * ci: typo * ci: temp rm black * ci: py ver * ci: use builtin py * ci: typo * ci: setuptools * ci: without subshell * chore: normalize titles * chore: lint * ci: validate and lint flows * ci: job name * ci: pipx as module * ci: missing dep * ci: missing dep * ci: pipx module * docs: add badge --- .github/workflows/base.yml | 22 ++++++++++++++++++++ README.md | 2 ++ dev_requirements.txt => requirements_dev.txt | 3 --- script/bootstrap | 2 +- tasks.py | 6 ++++-- 5 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/base.yml rename dev_requirements.txt => requirements_dev.txt (89%) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml new file mode 100644 index 0000000..ae6a751 --- /dev/null +++ b/.github/workflows/base.yml @@ -0,0 +1,22 @@ +name: Lambda Boilerplate + +on: [push] +jobs: + lint-and-validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt install python3-venv + python3 -m pip install --upgrade pip setuptools wheel pipx + - name: Validate templates + run: | + cd infrastructure + python3 -m pipx run sceptre validate app/app.yaml + python3 -m pipx run sceptre validate bootstrap/bootstrap.yaml + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }} + - name: Lint + run: python3 -m pipx run black . --check diff --git a/README.md b/README.md index ddda1e5..8793a80 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # lambda-boilerplate 🛠 Skip the boilerplate and start building fun λ things 🛠 +![Lambda Boilerplate](https://github.com/mcataford/lambda-boilerplate/workflows/Lambda%20Boilerplate/badge.svg) + ## Overview AWS Lambdas are fun, but often the amount of boilerplate involved in getting a project off the ground hinders the fun. From setting up a local environment to writing out a Cloudformation template, the overhead of Lambda-based greenfield projects can be daunting. No more. Just use this repository as a template or clone it and jump straight into the action! This repository offers a quick template your can use, full with a Docker setup for local development and invocation commands that you can use to package and deploy small Lambdas. diff --git a/dev_requirements.txt b/requirements_dev.txt similarity index 89% rename from dev_requirements.txt rename to requirements_dev.txt index ee86a1a..8cb537a 100644 --- a/dev_requirements.txt +++ b/requirements_dev.txt @@ -1,7 +1,5 @@ appdirs==1.4.4 attrs==20.1.0 -awscli==1.18.124 -black==19.10b0 boto3==1.14.55 botocore==1.17.55 click==7.1.2 @@ -22,7 +20,6 @@ PyYAML==5.3.1 regex==2020.7.14 rsa==4.5 s3transfer==0.3.3 -sceptre==2.3.0 six==1.15.0 toml==0.10.1 typed-ast==1.4.1 diff --git a/script/bootstrap b/script/bootstrap index 01db817..b7dc74f 100644 --- a/script/bootstrap +++ b/script/bootstrap @@ -10,6 +10,6 @@ VENV=lambda-boilerplate.venv pyenv virtualenv $VENV && pyenv activate $VENV && python -m pip install -U pip && - pip install -r dev_requirements.txt && + pip install -r requirements_dev.txt && echo "✨ Good to go! ✨" } diff --git a/tasks.py b/tasks.py index 8941ef3..dfb6ab8 100644 --- a/tasks.py +++ b/tasks.py @@ -14,13 +14,13 @@ def teardown_app(ctx): with ctx.cd("infrastructure"): ctx.run("sceptre delete app/app.yaml -y") + @task(name="teardown-bootstrap") def teardown_bootstrap(ctx): with ctx.cd("infrastructure"): ctx.run("sceptre delete bootstrap/bootstrap.yaml -y") - @task(name="deploy") def stack_deploy(ctx): path = Path(__file__).parent @@ -33,7 +33,9 @@ def stack_deploy(ctx): new_archive_name = f"lambda_function_{srchash}.zip" ctx.run(f"mv lambda_function.zip {new_archive_name}") - ctx.run(f"aws s3 cp {new_archive_name} s3://mcat-dev-test-bucket-artifacts-2 && rm {new_archive_name}") + ctx.run( + f"aws s3 cp {new_archive_name} s3://mcat-dev-test-bucket-artifacts-2 && rm {new_archive_name}" + ) with ctx.cd("infrastructure"): ctx.run(f"sceptre --var source_key={new_archive_name} launch app/app.yaml -y")