Skip to content

Commit

Permalink
Wiring Up Circle CI (newrelic#17)
Browse files Browse the repository at this point in the history
* Wiring Up Circle CI

* Fix DEVELOPER.md typo
  • Loading branch information
kolanos authored Jun 24, 2020
1 parent b46f720 commit 5e8923a
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 17 deletions.
109 changes: 109 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
version: 2
jobs:
build:
docker:
- image: circleci/python:3.7
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.7/site-packages
- restore_cache:
key: deps-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
command: |
sudo pip install pipenv
pipenv install --dev --deploy
- save_cache:
key: deps-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
paths:
- ".venv"
- "/usr/local/bin"
- "/usr/local/lib/python3.7/site-packages"

lint:
docker:
- image: circleci/python:3.7
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.7/site-packages
- restore_cache:
key: deps-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
command: |
pipenv run flake8 src test
pipenv run black --check src test
test:
docker:
- image: circleci/python:3.7
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.7/site-packages
- restore_cache:
key: deps-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
command: pipenv run pytest

release:
docker:
- image: circleci/python:3.7
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages
- run:
name: Install release dependencies
command: |
sudo pip install -q -U aws-sam-cli
pipenv lock --requirements --keep-outdated > ./src/requirements.txt
sam validate
sam build
sam package --s3-bucket nr-serverless-applications --output-template-file packaged.yaml
sam publish --region us-east-1 --template packaged.yaml
workflows:
version: 2
build-all:
jobs:
- build:
filters:
branches:
only: /.*/
tags:
only: /.*/
- lint:
requires:
- build
filters:
branches:
only: /.*/
tags:
only: /.*/
- test:
requires:
- build
filters:
branches:
only: /.*/
tags:
only: /.*/
- release:
requires:
- build
- lint
- test
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
18 changes: 5 additions & 13 deletions Developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@
# Running tests and linter locally

- Run tests with `pipenv run pytest`
- Ensure the code is PEP-8 compliant by using the flake8 linter: `black .; pipenv run flake8`
- Ensure the code is PEP-8 compliant by using the flake8 linter: `pipenv run flake8`

# Publishing a new version

Currently a manual process. Follow carefully.

> Each NEW PR must be approved by the Lambda team and the Logs team
- Make sure that you've updated the semantic version in the template.yaml file.
- Use the build.sh script, which does the following:
- Generate the requirements.txt with `pipenv lock --requirements --keep-outdated > ./src/requirements.txt`,
- Use `sam build --use-container`
- To package and upload the Lambda to an S3 bucket,
`sam package --s3-bucket nr-serverless-applications --output-template-file packaged.yaml`. You'll need access to the `nr-dashboards` AWS account.
- `sam publish --region us-east-1 --template packaged.yaml` to publish the serverless repo application
- Double check that everything is working as expected by creating a new function based on that app and check that it's using latest version of code. The publish step is kinda flakey; you may need to do that from the AWS Console UI.
To publish a new version [create a release](https://github.com/newrelic/aws-log-ingestion/releases/new)
and specify a tag that matches the `SemanticVersion` that appears in the `template.yml`
but prefixed with a `v`. For example, if the `SemanticVersion` is `1.2.3` then your
release tag should be `v1.2.3`.

# Code style

Expand Down
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
pipenv lock --requirements --keep-outdated > ./src/requirements.txt

sam build --use-container

3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ exclude = '''
| dist
)/
'''

[tool.flake8]
max-line-length = 88

0 comments on commit 5e8923a

Please sign in to comment.