Skip to content

austin/match-ts-parity #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Aug 22, 2025
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
15 changes: 0 additions & 15 deletions .claude/project.json

This file was deleted.

7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Nutrient DWS Processor API Configuration for Testing
NUTRIENT_API_KEY=your_api_key_here
NUTRIENT_BASE_URL=https://api.nutrient.io

# Development Settings
DEBUG=true
PYTHON_ENV=development
187 changes: 31 additions & 156 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,190 +1,71 @@
name: CI

# Integration Test Strategy:
# - Fork PRs: Cannot access secrets, so integration tests are skipped with informative feedback
# - Same-repo PRs: Have access to secrets, integration tests run normally
# - Push to main/develop: Integration tests always run to catch any issues after merge
# - Manual trigger: Allows maintainers to run integration tests on demand
#
# This ensures security while still validating integration tests before release

on:
push:
branches: [ main, develop ]
branches: [ main ]
pull_request:
branches: [ main, develop ]
# Run integration tests after PR is merged
workflow_dispatch: # Allow manual trigger for integration tests
branches: [ main ]

jobs:
test:
lint-and-type-check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

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

- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
python-version: '3.12'
cache: 'pip'

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

- name: Run linting with ruff
if: matrix.python-version == '3.10'
- name: Run linting
run: |
python -m ruff check .
python -m ruff format --check .

- name: Run type checking with mypy
run: python -m mypy --python-version=${{ matrix.python-version }} src tests
python -m ruff check src/

- name: Run unit tests with pytest
run: python -m pytest tests/unit/ -v --cov=nutrient_dws --cov-report=xml --cov-report=term
- name: Run type checking
run: python -m mypy src/

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
unit-tests:
runs-on: ${{ matrix.os }}
needs: lint-and-type-check

integration-test:
runs-on: ubuntu-latest
# Run on: pushes to main/develop, PRs from same repo, and manual triggers
if: |
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v4

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

- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
cache: 'pip'

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

- name: Check for API key availability
run: |
if [ -z "${{ secrets.NUTRIENT_DWS_API_KEY }}" ]; then
echo "::warning::NUTRIENT_DWS_API_KEY secret not found, skipping integration tests"
echo "skip_tests=true" >> $GITHUB_ENV

# Provide context about why this might be happening
if [ "${{ github.event_name }}" == "pull_request" ]; then
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "::notice::This appears to be a PR from a fork. Secrets are not available for security reasons."
else
echo "::error::This is a PR from the same repository but the API key is missing. Please check repository secrets configuration."
fi
else
echo "::error::Running on ${{ github.event_name }} event but API key is missing. Please configure NUTRIENT_DWS_API_KEY secret."
fi
else
echo "::notice::API key found, integration tests will run"
echo "skip_tests=false" >> $GITHUB_ENV
fi

- name: Create integration config with API key
if: env.skip_tests != 'true'
run: |
python -c "
import os
with open('tests/integration/integration_config.py', 'w') as f:
f.write(f'API_KEY = \"{os.environ[\"NUTRIENT_DWS_API_KEY\"]}\"\n')
"
env:
NUTRIENT_DWS_API_KEY: ${{ secrets.NUTRIENT_DWS_API_KEY }}

- name: Run integration tests
if: env.skip_tests != 'true'
run: python -m pytest tests/integration/ -v

- name: Cleanup integration config
if: always()
run: rm -f tests/integration/integration_config.py

# Provide feedback for fork PRs where integration tests can't run
integration-test-fork-feedback:
runs-on: ubuntu-latest
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Comment on PR about integration tests
uses: actions/github-script@v7
- name: Run unit tests with coverage
run: python -m pytest tests/unit/ -v --cov=nutrient_dws --cov-report=xml --cov-report=term

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue_number = context.issue.number;
const owner = context.repo.owner;
const repo = context.repo.repo;

// Check if we've already commented
const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number,
});

const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Integration tests are skipped for pull requests from forks')
);

if (!botComment) {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: `## Integration Tests Status\n\n` +
`Integration tests are skipped for pull requests from forks due to security restrictions. ` +
`These tests will run automatically after the PR is merged.\n\n` +
`**What this means:**\n` +
`- Unit tests, linting, and type checking have passed ✅\n` +
`- Integration tests require API credentials that aren't available to fork PRs\n` +
`- A maintainer will review your changes and merge if appropriate\n` +
`- Integration tests will run on the main branch after merge\n\n` +
`Thank you for your contribution! 🙏`
});
}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella

build:
runs-on: ubuntu-latest
needs: test
needs: [lint-and-type-check, unit-tests]

steps:
- uses: actions/checkout@v4
Expand All @@ -193,20 +74,14 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'

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

- name: Build package
run: python -m build

- name: Check package with twine
- name: Verify build outputs
run: twine check dist/*

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
54 changes: 54 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Integration Tests

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

jobs:
integration-tests:
runs-on: ubuntu-latest
needs: [] # Run in parallel with other workflows

strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: |
pip install ".[dev]"

- name: Check for API key
id: check-api-key
env:
NUTRIENT_API_KEY: ${{ secrets.NUTRIENT_API_KEY }}
run: |
if [ -n "$NUTRIENT_API_KEY" ] && [ "$NUTRIENT_API_KEY" != "fake_key" ] && [ ${#NUTRIENT_API_KEY} -gt 10 ]; then
echo "has_api_key=true" >> $GITHUB_OUTPUT
echo "✅ Valid API key detected"
else
echo "has_api_key=false" >> $GITHUB_OUTPUT
echo "⏭️ No valid API key - Integration tests will be skipped"
fi

- name: Run integration tests
if: steps.check-api-key.outputs.has_api_key == 'true'
env:
NUTRIENT_API_KEY: ${{ secrets.NUTRIENT_API_KEY }}
run: python -m pytest tests/test_integration.py -v

- name: Skip integration tests (no API key)
if: steps.check-api-key.outputs.has_api_key == 'false'
run: |
echo "✅ Integration tests skipped - no valid API key available"
echo "This is expected for forks and external PRs"
41 changes: 0 additions & 41 deletions .github/workflows/publish-existing-tag.yml

This file was deleted.

Loading
Loading