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

feat(ci): integrate ci analytics #1

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3be907b
feat(ci): integrate ci analytics
pandomic Nov 22, 2024
8d4c67a
update test workflow
pandomic Nov 27, 2024
be21a10
update test workflow
pandomic Nov 27, 2024
cbad002
update test workflow
pandomic Nov 27, 2024
a04c158
update test workflow
pandomic Nov 27, 2024
4c58d59
update test workflow
pandomic Nov 27, 2024
6e0064d
update test workflow
pandomic Nov 27, 2024
97bb8a0
update test workflow
pandomic Nov 27, 2024
2e3b436
update test workflow
pandomic Nov 27, 2024
5e2801e
update test workflow
pandomic Nov 27, 2024
14ed91d
update test workflow
pandomic Nov 27, 2024
2caf103
update test workflow
pandomic Nov 27, 2024
3ebb0f0
update test workflow
pandomic Nov 27, 2024
b4327cd
update test workflow
pandomic Nov 27, 2024
4e4469f
update test workflow
pandomic Nov 27, 2024
cf33946
update test workflow
pandomic Nov 27, 2024
ff41d3a
update test workflow
pandomic Nov 27, 2024
00e5a28
update test workflow
pandomic Nov 27, 2024
f45134c
update test workflow
pandomic Nov 27, 2024
bb066cf
update test workflow
pandomic Nov 27, 2024
aa5d68c
update test workflow
pandomic Nov 27, 2024
1d0986e
update test workflow
pandomic Nov 27, 2024
6d1055d
update test workflow
pandomic Nov 27, 2024
d968e33
update test workflow
pandomic Nov 27, 2024
e0dbf41
update test workflow
pandomic Nov 27, 2024
c8f7426
update test workflow
pandomic Nov 28, 2024
deae3ee
update test workflow
pandomic Nov 28, 2024
5c51eec
update test workflow
pandomic Nov 28, 2024
3a097be
update test workflow
pandomic Nov 28, 2024
452cad6
update test workflow
pandomic Nov 28, 2024
0328b51
update test workflow
pandomic Nov 28, 2024
d5fac06
update test workflow
pandomic Nov 28, 2024
b228d2f
update test workflow
pandomic Nov 28, 2024
921b295
update test workflow
pandomic Nov 28, 2024
222f2b9
update test workflow
pandomic Nov 28, 2024
4f66506
update test workflow
pandomic Nov 28, 2024
89f620e
update test workflow
pandomic Nov 28, 2024
7e10cd9
update test workflow
pandomic Nov 28, 2024
ccbcf26
update test workflow
pandomic Nov 28, 2024
564ce5d
update test workflow
pandomic Nov 28, 2024
75c54cb
update test workflow
pandomic Nov 28, 2024
d9d01c4
update test workflow
pandomic Nov 28, 2024
24d2dd7
update test workflow
pandomic Nov 28, 2024
0b34f47
update test workflow
pandomic Nov 28, 2024
9408e66
update test workflow
pandomic Nov 28, 2024
c5886ab
update test workflow
pandomic Nov 29, 2024
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
89 changes: 0 additions & 89 deletions .github/workflows/ephemeral.yml

This file was deleted.

116 changes: 82 additions & 34 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ on:
type: choice
options:
- ubuntu-latest

env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
LOCALSTACK_PROJECT_ID: project_1bipvrdld3
LOCALSTACK_PIPELINE_ID: pipeline_dw7flhan3i

jobs:
integration-test-job:
Expand All @@ -27,6 +30,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Checkout CI Extension
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PULL_TOKEN }}
repository: localstack/localstack-ci-extension
path: localstack-ci-extension

- name: Checkout CI Extension Plugin
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PULL_TOKEN }}
repository: localstack/localstack-ci-extension-plugins
path: localstack-ci-extension-plugins

- name: Set up Python 3.11
id: setup-python
uses: actions/setup-python@v2
Expand All @@ -40,59 +57,90 @@ jobs:

- name: Set up Dependencies
run: |
pip install requests boto3 pytest localstack-sdk-python
make install
pip install localstack-ci-extension-plugins/pytest_plugin
cd localstack-ci-extension && pip install -e . && cd -

- name: Prepare LocalStack
run: |
LOCALSTACK_API_KEY=$LOCALSTACK_API_KEY \
localstack extensions dev enable ./localstack-ci-extension

- name: Start LocalStack
uses: LocalStack/[email protected]
with:
image-tag: 'latest'
use-pro: 'true'
configuration: LS_LOG=trace
install-awslocal: 'true'
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
run: |
DEBUG=1 \
LOCALSTACK_API_KEY=$LOCALSTACK_API_KEY \
LOCALSTACK_PROJECT_ID=$LOCALSTACK_PROJECT_ID \
LOCALSTACK_PIPELINE_ID=$LOCALSTACK_PIPELINE_ID \
DNS_NAME_PATTERNS_TO_RESOLVE_UPSTREAM="*cianalyticsbucket*" \
EXTENSION_DEV_MODE=1 \
localstack start -d

- name: Wait for LocalStack to be ready
run: |
echo "Waiting for LocalStack CI extension to activate..."
for i in {1..10}; do
if localstack logs | grep -q "activated CI Extension"; then
echo "CI extension activated. Proceeding..."
exit 0
fi
sleep 5
done
echo "CI extension not activated in time. Failing..."
exit 1

- name: Deploy infrastructure
run: |
START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
bash bin/deploy.sh
END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
curl -X POST http://localhost:4566/_localstack/extensions/ci/steps \
-H "Content-Type: application/json" \
-d '{
pandomic marked this conversation as resolved.
Show resolved Hide resolved
"steps": [
{
"step_id": "deploy",
"name": "Deploy Infrastructure",
"step_type" : "step",
"state": "passed",
"time_start": "'"$START_TIME"'",
"time_end": "'"$END_TIME"'"
}
]
}'

START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
bash bin/seed.sh
END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
curl -X POST http://localhost:4566/_localstack/extensions/ci/steps \
-H "Content-Type: application/json" \
-d '{
"steps": [
{
"step_id": "seed",
"name": "Seed Data",
"step_type" : "step",
"state": "passed",
"time_start": "'"$START_TIME"'",
"time_end": "'"$END_TIME"'"
}
]
}'

- name: Run Integration Tests
- name: Run Tests
env:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
run: |
pytest tests/test_infra.py

- name: Run Outages Tests
env:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
run: |
pytest tests/test_outage.py
pytest tests

- name: Show localstack logs
if: always()
run: |
localstack logs

- name: Send a Slack notification
if: failure() || github.event_name != 'pull_request'
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

- name: Generate a Diagnostic Report
if: failure()
run: |
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/preview.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

# Python

.idea
.Python
build/
develop-eggs/
dist/
.env
.venv
*.egg-info/
env/
venv/
__pycache__
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
install:
pip install -e .;

usage: ## Show usage for this Makefile
@cat Makefile | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
Expand Down
10 changes: 10 additions & 0 deletions lambdas/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import json

def prepare_response(status_code, body):
return {
"statusCode": status_code,
"body": json.dumps(body),
"headers": {
"Content-Type": "application/json",
}
}
24 changes: 24 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[metadata]
name = serverless-quiz-app
version = 0.0.1
url = localstack.cloud
author = LocalStack Team
author_email = [email protected]
description = LocalStack Quiz App
license = Proprietary
classifiers =
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
License :: Other/Proprietary License
Topic :: Software Development :: Testing

[options]
zip_safe = False
packages = find_namespace:
install_requires =
localstack
requests
boto3
pytest
localstack-sdk-python
awscli-local
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python
from setuptools import setup

setup()
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import logging
import sys

logging.getLogger("urllib3").setLevel(logging.WARNING)

logging.basicConfig(
level=logging.DEBUG,
stream=sys.stdout,
)
Loading
Loading