Skip to content
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
103 changes: 103 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Test Suite

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

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12']
environment: [dev, stage]

steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests with pytest
env:
API_ENV: ${{ matrix.environment }}
JWT_SECRET: test_secret_for_ci
run: |
pytest -v \
--cov=app \
--cov-report=term-missing \
--cov-report=xml \
--junitxml=junit.xml \
-n auto

- name: Upload coverage reports
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.python-version }}-${{ matrix.environment }}

- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.python-version }}-${{ matrix.environment }}
path: junit.xml

rust-tests:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v3
with:
path: rust_tests/target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}

- name: Setup Python and start API
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Python dependencies and start API
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
export API_ENV=dev
export JWT_SECRET=test_secret_for_rust_tests
uvicorn app.main:app --host 0.0.0.0 --port 8000 &
sleep 5 # Wait for API to start

- name: Run Rust integration tests
working-directory: rust_tests
run: cargo test --verbose

- name: Upload Rust test results
if: always()
uses: actions/upload-artifact@v3
with:
name: rust-test-results
path: rust_tests/target/debug/deps/*.xml
20 changes: 12 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ venv/
env/
ENV/
.venv

# pytest
pip-log.txt
pip-delete-this-directory.txt
.pytest_cache/
.coverage
htmlcov/
*.cover
.hypothesis/

# Rust
rust_tests/target/
rust_tests/Cargo.lock
**/*.rs.bk

# IDE
.vscode/
Expand All @@ -26,9 +32,7 @@ htmlcov/
.DS_Store
Thumbs.db

# Environment
.env
*.log

# Internal documentation (not for candidates)
BUGS_REFERENCE.md
# Test outputs
junit.xml
coverage.xml
.coverage.*
Loading
Loading