|
1 | | -name: CI |
| 1 | +name: CI - Tests and Architecture Validation |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
8 | 8 |
|
9 | 9 | jobs: |
10 | 10 | test: |
| 11 | + name: Run Tests |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 |
|
13 | 14 | steps: |
14 | | - - uses: actions/checkout@v3 |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
15 | 17 |
|
16 | | - - name: Set up Python |
17 | | - uses: actions/setup-python@v4 |
| 18 | + - name: Set up Python 3.12 |
| 19 | + uses: actions/setup-python@v5 |
18 | 20 | with: |
19 | | - python-version: '3.11' |
| 21 | + python-version: '3.12' |
20 | 22 |
|
21 | 23 | - name: Install dependencies |
22 | 24 | run: | |
23 | 25 | python -m pip install --upgrade pip |
24 | 26 | pip install -r requirements.txt |
| 27 | + pip install pytest pytest-cov |
25 | 28 | |
26 | | - - name: Run tests |
| 29 | + - name: Run tests with coverage |
27 | 30 | run: | |
28 | | - pytest tests/ -v --tb=short |
| 31 | + pytest tests/ -v --cov=app --cov-report=term-missing |
| 32 | +
|
| 33 | + validate-architecture: |
| 34 | + name: Validate C4 Annotations |
| 35 | + runs-on: ubuntu-latest |
| 36 | + needs: test |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout notes-api |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Set up Python 3.12 |
| 43 | + uses: actions/setup-python@v5 |
| 44 | + with: |
| 45 | + python-version: '3.12' |
| 46 | + |
| 47 | + - name: Install c4-literate-python |
| 48 | + run: | |
| 49 | + # For now, install from local path or git repo |
| 50 | + # Replace with: pip install c4-literate-python |
| 51 | + # once published to PyPI |
| 52 | + pip install git+https://github.com/ChristosDev75/c4-literate-python.git@main |
| 53 | + |
| 54 | + - name: Validate C4 annotations |
| 55 | + run: | |
| 56 | + c4-literate validate . |
29 | 57 | |
30 | | - - name: Test API startup |
| 58 | + - name: Generate architecture diagrams |
31 | 59 | run: | |
32 | | - timeout 10 uvicorn app.main:app --host 0.0.0.0 --port 8000 & |
33 | | - sleep 5 |
34 | | - curl -f http://localhost:8000/ || exit 1 |
| 60 | + mkdir -p docs/architecture |
| 61 | + c4-literate tangle . -o docs/architecture/workspace.dsl |
| 62 | + |
| 63 | + - name: Upload generated DSL |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: architecture-diagrams |
| 67 | + path: docs/architecture/workspace.dsl |
| 68 | + retention-days: 90 |
| 69 | + |
| 70 | + - name: Comment PR with artifact link |
| 71 | + if: github.event_name == 'pull_request' |
| 72 | + uses: actions/github-script@v7 |
| 73 | + with: |
| 74 | + script: | |
| 75 | + github.rest.issues.createComment({ |
| 76 | + issue_number: context.issue.number, |
| 77 | + owner: context.repo.owner, |
| 78 | + repo: context.repo.repo, |
| 79 | + body: '✅ Architecture diagrams generated successfully! Download the artifact to view with Structurizr Lite.' |
| 80 | + }) |
0 commit comments