Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/deployaws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
submodules: 'true'
- uses: actions/setup-python@v3
with:
python-version: '3.9'
python-version: '3.12'
- uses: aws-actions/setup-sam@v2
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-1
- run: find ./ -name requirements.txt -type f -exec pip install -t dependencies/python -r "{}" \;
- run: pip install -t dependencies/python -e .
- run: sam build
- run: sam deploy --parameter-overrides 'Password=${{ secrets.WEB_PASSWORD }}'
49 changes: 49 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Run Unit Tests

on:
pull_request:
branches: [ dev, master ]
push:
branches: [ dev, master ]
paths-ignore:
- 'docs/**'
- '**.md'

jobs:
test:
name: Run Python Tests
runs-on: ubuntu-latest
container:
image: ghcr.io/astral-sh/uv:python3.12-bookworm
options: --user root
env:
UV_INDEX_URL: https://pypi.org/simple

steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Install dependencies with uv sync
run: |
uv sync --python-preference only
uv pip install pytest moto

- name: Initialize submodules
run: git submodule update --init --recursive

- name: Run tests
run: pytest tests/ -v
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
test-results/
.pytest_cache/
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "taskbox"
version = "0.1.0"
description = "A personal scheduled task framework running on Serverless platform"
authors = [
{name = "jneeee", email = "your-email@example.com"},
{name = "jneeee", email = "jneeee@outlook.com"},
]
readme = "README.md"
requires-python = ">=3.9"
Expand All @@ -18,10 +18,11 @@ dependencies = [
"Jinja2>=3.1.2",
"boto3>=1.26.8",
"botocore>=1.29.8",
"pyaes>=1.6.1",
]

[tool.uv]
dev-dependencies = [
dependency-groups.dev = [
"pytest>=7.0.0",
"black>=23.0.0",
"isort>=5.0.0",
Expand Down Expand Up @@ -64,4 +65,4 @@ skip_gitignore = true

[tool.pytest.ini_options]
pythonpath = ["src"]
testpaths = ["src/taskbox/tests"]
testpaths = ["tests"]
7 changes: 5 additions & 2 deletions src/taskbox/tests/test_manage.py → tests/test_manage.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import os
import sys
import unittest
from unittest import mock

from taskbox.tests import fixture
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))

from taskbox.tests.fixture import create_table
from taskbox.taskbase.manage import TaskManager

class Test_manage(unittest.TestCase):

def setUp(self) -> None:
self.table = fixture.create_table()
self.table = create_table()
d = {
'DDB_TABLE': 'table_name',
'AWS_ACCESS_KEY_ID': "keyid",
Expand Down
4 changes: 4 additions & 0 deletions src/taskbox/tests/test_object.py → tests/test_object.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
import sys
import unittest
from unittest import mock

sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))

from taskbox.webx.object import Request


Expand Down
8 changes: 6 additions & 2 deletions src/taskbox/tests/test_web.py → tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

from moto import mock_dynamodb

import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))

from taskbox.index import lambda_handler
from taskbox.utils.tools import LOG
from taskbox.tests import fixture
from taskbox.tests.fixture import create_table


Fake_event = {
Expand All @@ -30,7 +34,7 @@ class Test_web_tasks(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.table = fixture.create_table()
cls.table = create_table()

@classmethod
def tearDownClass(cls):
Expand Down
Loading