Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release to PyPI

on:
release:
types: [published]
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package
run: python -m build

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Lint with ruff
run: ruff check .

- name: Check formatting with black
run: black --check .

- name: Run tests
run: pytest tests/ -v
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __pycache__
localstack_utils.egg-info
.ruff_cache
dist
*.env
4 changes: 3 additions & 1 deletion localstack_utils/container.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import re
import docker
Expand Down Expand Up @@ -69,4 +71,4 @@ def wait_for_ready(container, pattern):
attempts += 1

if attempts >= MAX_LOG_COLLECTION_ATTEMPTS:
raise "Could not find token: " + pattern.toString() + "in logs"
raise RuntimeError(f"Could not find token: {pattern.pattern} in logs")
20 changes: 9 additions & 11 deletions localstack_utils/localstack.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import sys
import docker
import logging
from localstack_utils.container import Container
Expand Down Expand Up @@ -41,14 +40,13 @@ def startup(self, docker_configuration):

try:
self.localstack_container = Container.create_localstack_container(
docker_configuration.pull_new_image,
docker_configuration.image_name,
docker_configuration.image_tag,
docker_configuration.gateway_listen,
docker_configuration.environment_variables,
docker_configuration.port_mappings,
docker_configuration.pro,
docker_configuration.auto_remove_container,
pull_new_image=docker_configuration.pull_new_image,
image_name=docker_configuration.image_name,
image_tag=docker_configuration.image_tag,
gateway_listen=docker_configuration.gateway_listen,
auto_remove=docker_configuration.auto_remove_container,
environment_variables=docker_configuration.environment_variables,
bind_ports=docker_configuration.port_mappings,
)

self.setup_logger()
Expand All @@ -57,10 +55,10 @@ def startup(self, docker_configuration):

except docker.errors.APIError:
if not docker_configuration.ignore_docker_runerrors:
raise "Unable to start docker"
raise RuntimeError("Unable to start docker")

except Exception:
raise sys.exc_info()
raise

def stop(self):
self.localstack_container.stop()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_kinesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TestKinesis(unittest.TestCase):
def setUp(self):
startup_localstack()
startup_localstack(image_name="localstack/localstack")

def tearDown(self):
stop_localstack()
Expand All @@ -16,6 +16,7 @@ def test_create_stream(self):
kinesis = boto3.client(
service_name="kinesis",
aws_access_key_id="test",
region_name="us-east-1",
aws_secret_access_key="test",
endpoint_url="http://localhost:4566",
)
Expand Down