-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from gabrielbazan/develop
0.1 - Prepare fist version
- Loading branch information
Showing
24 changed files
with
979 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- "LICENSE" | ||
- "*.md" | ||
|
||
pull_request: | ||
paths-ignore: | ||
- "LICENSE" | ||
- "*.md" | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8"] # "3.x", "3.7", "3.8", "3.9", "3.10" | ||
os: [ubuntu-latest] # , macOS-latest, windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
make create_virtualenv | ||
make install_requirements | ||
make install_test_requirements | ||
- name: Run unit tests | ||
run: | | ||
make run_unit_tests | ||
- name: Install LocalStack | ||
run: | | ||
pip install localstack | ||
- name: Install Serverless | ||
run: | | ||
npm install -g serverless | ||
- name: Install Serverless plugins | ||
run: | | ||
npm i | ||
- name: Deploy Serverless to LocalStack | ||
run: | | ||
make deploy_local | ||
- name: Run integration tests | ||
run: | | ||
make run_integration_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.serverless/ | ||
.mypy_cache/ | ||
.vscode/ | ||
node_modules/ | ||
venv/ | ||
package-lock.json | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black"] | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.0.0 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.1.1 | ||
hooks: | ||
- id: mypy | ||
args: [--strict, --ignore-missing-imports] | ||
additional_dependencies: ['types-requests'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
|
||
|
||
VIRTUALENV_PATH=./venv | ||
REQUIREMENTS_FILE_PATH=./requirements.txt | ||
DEV_REQUIREMENTS_FILE_PATH=./requirements.dev.txt | ||
TEST_REQUIREMENTS_FILE_PATH=./requirements.test.txt | ||
|
||
|
||
SERVICE_NAME=thumbnails-service | ||
|
||
GENERATE_THUMBNAILS_FUNCTION_NAME=generate_thumbnails | ||
GENERATE_THUMBNAILS_FUNCTION_FULL_NAME=${SERVICE_NAME}-local-${GENERATE_THUMBNAILS_FUNCTION_NAME} | ||
|
||
RETRY_FROM_DLQ_FUNCTION_NAME=retry_from_dlq | ||
RETRY_FROM_DLQ_FUNCTION_FULL_NAME=${SERVICE_NAME}-local-${RETRY_FROM_DLQ_FUNCTION_NAME} | ||
|
||
IMAGES_BUCKET_NAME=images-bucket | ||
IMAGES_DLQ_NAME=images-dlq | ||
|
||
|
||
LOCALSTACK_ENDPOINT=http://localhost:4566 | ||
|
||
|
||
IMAGES_DLQ_URL=${LOCALSTACK_ENDPOINT}/000000000000/${IMAGES_DLQ_NAME} | ||
|
||
|
||
AWS_CLI_LOCALSTACK_PROFILE=localstack | ||
AWS_CLI_LOCALSTACK_PARAMETERS=--endpoint-url=${LOCALSTACK_ENDPOINT} --profile ${AWS_CLI_LOCALSTACK_PROFILE} | ||
|
||
|
||
AWS_CLI=aws ${AWS_CLI_LOCALSTACK_PARAMETERS} | ||
|
||
|
||
TEST_IMAGES_FOLDER=./test | ||
|
||
|
||
install_git_hooks: | ||
pre-commit install | ||
|
||
|
||
run_git_hooks: | ||
pre-commit run --all-files | ||
|
||
|
||
create_virtualenv: | ||
@echo "Creating virtualenv..." | ||
python3 -m venv "${VIRTUALENV_PATH}" | ||
@echo "Done!" | ||
|
||
|
||
install_requirements: | ||
@echo "Installing requirements..." | ||
${VIRTUALENV_PATH}/bin/pip install -r "${REQUIREMENTS_FILE_PATH}" | ||
@echo "Done!" | ||
|
||
|
||
install_dev_requirements: | ||
@echo "Installing dev requirements..." | ||
${VIRTUALENV_PATH}/bin/pip install -r "${DEV_REQUIREMENTS_FILE_PATH}" | ||
@echo "Done!" | ||
|
||
|
||
install_test_requirements: | ||
@echo "Installing test requirements..." | ||
${VIRTUALENV_PATH}/bin/pip install -r "${TEST_REQUIREMENTS_FILE_PATH}" | ||
@echo "Done!" | ||
|
||
|
||
install_all_requirements: install_requirements install_dev_requirements install_test_requirements | ||
|
||
|
||
run_unit_tests: | ||
@echo "Running unit tests..." | ||
@. ${VIRTUALENV_PATH}/bin/activate && python -m unittest discover -s functions -p '*_test.py' | ||
@echo "Done!" | ||
|
||
|
||
run_integration_tests: | ||
@echo "Running integration tests..." | ||
@. ${VIRTUALENV_PATH}/bin/activate && python -m unittest discover -s integration_tests -p '*_test.py' | ||
@echo "Done!" | ||
|
||
|
||
localstack_logs: | ||
localstack logs --follow | ||
|
||
|
||
deploy_local: | ||
localstack stop || true | ||
DISABLE_EVENTS=1 localstack start -d | ||
sls deploy --stage local | ||
|
||
|
||
deploy_functions_local: deploy_generate_thumbnails_function_local deploy_retry_from_dlq_function_local | ||
|
||
|
||
deploy_generate_thumbnails_function_local: | ||
sls deploy function --stage local --function ${GENERATE_THUMBNAILS_FUNCTION_NAME} | ||
|
||
|
||
deploy_retry_from_dlq_function_local: | ||
sls deploy function --stage local --function ${RETRY_FROM_DLQ_FUNCTION_NAME} | ||
|
||
|
||
tail_generate_thumbnails_function_logs: | ||
${AWS_CLI} logs tail /aws/lambda/${GENERATE_THUMBNAILS_FUNCTION_FULL_NAME} --follow | ||
|
||
|
||
tail_retry_from_sqs_function_logs: | ||
${AWS_CLI} logs tail /aws/lambda/${RETRY_FROM_DLQ_FUNCTION_FULL_NAME} --follow | ||
|
||
|
||
upload_test_images_to_s3: | ||
${AWS_CLI} s3 cp ${TEST_IMAGES_FOLDER} s3://${IMAGES_BUCKET_NAME}/images/ --recursive | ||
|
||
|
||
show_messages_in_dlq: | ||
${AWS_CLI} sqs receive-message --queue-url ${IMAGES_DLQ_URL} --max-number-of-messages 10 --output json | ||
|
||
|
||
retry_from_dql: | ||
${AWS_CLI} lambda invoke --function-name ${RETRY_FROM_DLQ_FUNCTION_FULL_NAME} --invocation-type Event response.json | ||
rm response.json |
Oops, something went wrong.