Skip to content

Commit c7895dc

Browse files
committed
Unit tests working
1 parent bdec28e commit c7895dc

File tree

11 files changed

+106
-76
lines changed

11 files changed

+106
-76
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Run Unit Tests for Python services
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
service_directory:
7+
type: string
8+
required: true
9+
10+
jobs:
11+
unit_tests:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- uses: actions/setup-python@v4
18+
with: { python-version: 3.10.11 }
19+
20+
- uses: snok/install-poetry@v1
21+
with:
22+
version: 1.4.2
23+
virtualenvs-create: true
24+
virtualenvs-in-project: true
25+
26+
- name: Initialize and install dependencies
27+
run: make ci_init
28+
working-directory: ./${{ inputs.service_directory }}
29+
30+
- name: Run Unit tests
31+
run: make unit-test
32+
working-directory: ./${{ inputs.service_directory }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
on:
2+
push:
3+
branches: [develop, main]
4+
paths:
5+
- 'unicorn_contracts/**'
6+
- 'unicorn_properties/**'
7+
- 'unicorn_web/**'
8+
pull_request:
9+
branches: [develop, main]
10+
paths:
11+
- 'unicorn_contracts/**'
12+
- 'unicorn_properties/**'
13+
- 'unicorn_web/**'
14+
15+
jobs:
16+
unicorn_contracts:
17+
uses: ./.github/workflows/reusable_unit_tests.yml
18+
with:
19+
service_directory: unicorn_contracts
20+
21+
unicorn_properties:
22+
uses: ./.github/workflows/reusable_unit_tests.yml
23+
with:
24+
service_directory: unicorn_properties
25+
26+
unicorn_web:
27+
uses: ./.github/workflows/reusable_unit_tests.yml
28+
with:
29+
service_directory: unicorn_web

unicorn_contracts/.coveragerc

Lines changed: 0 additions & 2 deletions
This file was deleted.

unicorn_contracts/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sync:
1616

1717
test: unit-test
1818

19-
unit-test: deps
19+
unit-test:
2020
poetry run pytest tests/unit/
2121

2222
integration-test: deps
@@ -33,3 +33,8 @@ clean:
3333
delete:
3434
sam delete --stack-name $(stackName) --no-prompts
3535

36+
# NOTE: [2023-05-09] This is a fix for installing Poetry dependencies in GitHub Actions
37+
ci_init:
38+
poetry export --without-hashes --format=requirements.txt --output=src/requirements.txt --with dev
39+
poetry run pip install -r src/requirements.txt
40+
poetry install -n

unicorn_contracts/poetry.lock

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unicorn_contracts/pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ exclude = ["src/events/"]
77
packages = [{ include = "contracts_service", from = "src" }]
88

99
[tool.poetry.dependencies]
10-
python = "^3.9"
10+
python = "3.10.11"
1111
boto3 = "^1.26.121"
1212
aws-lambda-powertools = {extras = ["tracer"], version = "^2.14.1"}
1313

14-
[tool.poetry.dev-dependencies]
14+
[tool.poetry.group.dev.dependencies]
1515
pytest = "^7.1.2"
1616
pytest-mock = "^3.7.0"
1717
pytest-cov = "^3.0.0"
1818
coverage = "^6.4.2"
1919
requests = "^2.28.1"
2020
moto = "^3.1.17"
2121
importlib-metadata = "^4.12.0"
22-
23-
[tool.poetry.group.dev.dependencies]
2422
aws-lambda-powertools = {extras = ["aws-sdk"], version = "^2.14.1"}
2523

2624
[build-system]

unicorn_properties/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ clean:
2929

3030
delete:
3131
sam delete --stack-name $(stackName) --no-prompts
32+
33+
# NOTE: [2023-05-09] This is a fix for installing Poetry dependencies in GitHub Actions
34+
ci_init:
35+
poetry export --without-hashes --format=requirements.txt --output=src/requirements.txt --with dev
36+
poetry run pip install -r src/requirements.txt
37+
poetry install -n

unicorn_properties/pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ python = "^3.9"
1313
boto3 = "^1.26.121"
1414
aws-lambda-powertools = {extras = ["tracer"], version = "^2.14.1"}
1515

16-
[tool.poetry.dev-dependencies]
16+
[tool.poetry.group.dev.dependencies]
1717
pytest = "^7.1.2"
1818
pytest-mock = "^3.7.0"
1919
pytest-cov = "^3.0.0"
2020
coverage = "^6.4.2"
2121
requests = "^2.28.1"
2222
moto = "^3.1.17"
23-
24-
[tool.poetry.group.dev.dependencies]
2523
aws-lambda-powertools = {extras = ["aws-sdk"], version = "^2.14.1"}
2624

2725
[build-system]

unicorn_web/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ clean:
2222

2323
delete:
2424
sam delete --no-prompts --region "$$(aws configure get region)"
25+
26+
# NOTE: [2023-05-09] This is a fix for installing Poetry dependencies in GitHub Actions
27+
ci_init:
28+
poetry export --without-hashes --format=requirements.txt --output=src/requirements.txt --with dev
29+
poetry run pip install -r src/requirements.txt
30+
poetry install -n

0 commit comments

Comments
 (0)