Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
refactor test setup to use localstack in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
thought-tobi committed Apr 9, 2024
1 parent e1be4a7 commit 7a3b130
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ jobs:
run: poetry install --no-interaction --no-root --with dev

- name: Run tests
run: |
source .venv/bin/activate
export PYTHONPATH=./ && poetry run pytest test/ --ignore test/integration/manual/ --disable-warnings -s
run: bash -c scripts/test.sh

create_infrastructure:
needs: test
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: test run fmt

test:
@export PYTHONPATH=./ && poetry run pytest test/ --ignore test/integration/manual/ --disable-warnings -s
@bash -c 'scripts/test.sh'

fmt:
@bash -c 'pre-commit run -av'
Expand Down
24 changes: 9 additions & 15 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@ docker run -d --rm --name localstack -p 4566:4566 -p 4571:4571 localstack/locals
echo "waiting for localstack to be ready"
sleep 3

echo "creating user dynamodb table ..."
aws dynamodb create-table --table-name user \
--attribute-definitions AttributeName=user_id,AttributeType=N \
--key-schema AttributeName=user_id,KeyType=HASH \
--billing-mode PAY_PER_REQUEST \
--endpoint-url http://localhost:4566 > /dev/null
echo "running tests"
if [ -d .venv ]; then
echo "found existing virtual environment. activating ..."
source .venv/bin/activate
else
echo "no virtual environment found. assuming dependencies are available."
fi

echo "creating record dynamodb table ..."
aws dynamodb create-table --table-name record \
--attribute-definitions AttributeName=timestamp,AttributeType=S \
--attribute-definitions AttributeName=user_id,AttributeType=N \
--key-schema AttributeName=timestamp,KeyType=RANGE \
--key-schema AttributeName=user_id,KeyType=HASH \
--billing-mode PAY_PER_REQUEST \
--endpoint-url http://localhost:4566 > /dev/null
export PYTHONPATH=./ && poetry run pytest test/ --ignore test/integration/manual/ --disable-warnings -s

echo "cleaning up"
# docker stop localstack
docker stop localstack

0 comments on commit 7a3b130

Please sign in to comment.