diff --git a/.github/workflows/email-tests.yml b/.github/workflows/email-tests.yml new file mode 100644 index 0000000..c4f1a97 --- /dev/null +++ b/.github/workflows/email-tests.yml @@ -0,0 +1,49 @@ +name: Email Tests (Requires Postmark Credentials) + +on: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: Set up Python + run: uv python install 3.12 + + - name: Install dependencies + run: uv sync --group dev + + - name: Check Postmark credentials + env: + POSTMARK_API_TOKEN: ${{ secrets.POSTMARK_API_TOKEN }} + SENDER_EMAIL: ${{ secrets.SENDER_EMAIL }} + run: | + if [ -z "$POSTMARK_API_TOKEN" ]; then + echo "Error: POSTMARK_API_TOKEN is not set in repository secrets" + echo "This workflow requires Postmark credentials to run email tests" + echo "Please add POSTMARK_API_TOKEN and SENDER_EMAIL to repository secrets" + exit 1 + fi + if [ -z "$SENDER_EMAIL" ]; then + echo "Error: SENDER_EMAIL is not set in repository secrets" + exit 1 + fi + echo "Postmark credentials are properly configured" + + - name: Run email sending tests + env: + POSTMARK_API_TOKEN: ${{ secrets.POSTMARK_API_TOKEN }} + SENDER_EMAIL: ${{ secrets.SENDER_EMAIL }} + run: uv run pytest tests/ -v -m "flow" + + - name: Run async email sending tests + env: + POSTMARK_API_TOKEN: ${{ secrets.POSTMARK_API_TOKEN }} + SENDER_EMAIL: ${{ secrets.SENDER_EMAIL }} + run: uv run pytest tests/test_tacomail_async.py -v -m "flow" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c98c5eb --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,26 @@ +name: Lint and Type Check + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: Set up Python + run: uv python install 3.12 + + - name: Install dependencies + run: uv sync --group dev + + - name: Run linter + run: uv run ruff check . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c2b316d..1471fc3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Tests +name: Basic Tests on: push: @@ -9,39 +9,21 @@ on: jobs: test: runs-on: ubuntu-latest - + steps: - uses: actions/checkout@v4 - + - name: Install uv uses: astral-sh/setup-uv@v4 - + - name: Set up Python run: uv python install 3.12 - + - name: Install dependencies run: uv sync --group dev - - - name: Run linter - run: uv run ruff check . - - - name: Check Postmark credentials - env: - POSTMARK_API_TOKEN: ${{ secrets.POSTMARK_API_TOKEN }} - SENDER_EMAIL: ${{ secrets.SENDER_EMAIL }} - run: | - if [ -z "$POSTMARK_API_TOKEN" ]; then - echo "Error: POSTMARK_API_TOKEN is not set in repository secrets" - exit 1 - fi - if [ -z "$SENDER_EMAIL" ]; then - echo "Error: SENDER_EMAIL is not set in repository secrets" - exit 1 - fi - echo "Postmark credentials are properly configured" - - - name: Run tests - env: - POSTMARK_API_TOKEN: ${{ secrets.POSTMARK_API_TOKEN }} - SENDER_EMAIL: ${{ secrets.SENDER_EMAIL }} - run: uv run pytest tests/ -v + + - name: Run basic tests (no email sending required) + run: uv run pytest tests/ -v -m "not flow" + + - name: Run async basic tests + run: uv run pytest tests/test_tacomail_async.py -v -m "not flow" diff --git a/README.md b/README.md index 88e5a48..0f0bc4b 100644 --- a/README.md +++ b/README.md @@ -170,17 +170,6 @@ To receive emails, you can use either approach: 2. ✅ `tacomail create-session ` - Create session (REQUIRED) 3. ✅ `tacomail wait ` - Monitor inbox for incoming emails -### Benefits of create-with-session - -The `create-with-session` command (and its short alias `new`) provides several advantages: - -- **⚡ Faster workflow**: One command instead of two -- **🎯 Reduced errors**: No need to copy-paste email between commands -- **📋 Complete information**: Shows both email and session details at once -- **🔄 Works in both modes**: Supports both sync and async clients -- **🎨 Better UX**: Clear next steps displayed after creation -- **⚙️ Flexible options**: Still supports domain and username customization - ### Common Workflows **Workflow 1: Quick setup for testing** diff --git a/tests/test_tacomail.py b/tests/test_tacomail.py index 3531019..f8fb8bd 100644 --- a/tests/test_tacomail.py +++ b/tests/test_tacomail.py @@ -66,6 +66,7 @@ def test_fetch_empty_inbox(client: TacomailClient): assert len(emails) == 0 +@pytest.mark.flow def test_email_sender_initialization(): sender = PostmarkEmailSender() assert sender.api_token is not None diff --git a/tests/test_tacomail_async.py b/tests/test_tacomail_async.py index 8ed49a2..1df404c 100644 --- a/tests/test_tacomail_async.py +++ b/tests/test_tacomail_async.py @@ -49,6 +49,7 @@ async def test_delete_session_async( await client.delete_session(username, domain) +@pytest.mark.flow @pytest.mark.asyncio async def test_wait_for_email_async( client_generator: AsyncGenerator[AsyncTacomailClient, None], @@ -81,6 +82,7 @@ async def test_wait_for_email_async( assert received_email.body.text.strip() == test_body +@pytest.mark.flow @pytest.mark.asyncio async def test_wait_for_email_filtered_async( client_generator: AsyncGenerator[AsyncTacomailClient, None],