feat(ui): Teams page — list, create, delete + member management #150
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: ["**"] | |
| pull_request: | |
| branches: ["**"] | |
| jobs: | |
| test: | |
| name: Test Suite | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip | |
| # Install only what the tests need — avoids building heavy native | |
| # extensions (asyncpg, cryptography/bcrypt, etc.) that are mocked. | |
| # PyJWT uses stdlib hmac for HS256 — no cffi/C-extension needed. | |
| # bcrypt is handled by passlib's pbkdf2 fallback in test environments. | |
| pip install \ | |
| pytest>=8 pytest-asyncio>=0.23 httpx>=0.27 ruff>=0.4 \ | |
| fastapi>=0.111 pydantic>=2.7 "pydantic-settings>=2.3" \ | |
| "sqlalchemy[asyncio]>=2.0" pyyaml>=6.0 \ | |
| jinja2>=3.1 \ | |
| "passlib>=1.7" "PyJWT>=2.9" | |
| - name: Lint (ruff) | |
| run: ruff check . | |
| - name: Run tests | |
| id: run_tests | |
| run: | | |
| python -m pytest \ | |
| tests/test_ip_utils.py \ | |
| tests/test_agent_collectors.py \ | |
| tests/test_ldap_module.py \ | |
| tests/test_inventory.py \ | |
| tests/test_notifications.py \ | |
| tests/test_cli.py \ | |
| tests/test_data_ingestion.py \ | |
| tests/test_version.py \ | |
| tests/test_rbac.py \ | |
| tests/test_task_engine.py \ | |
| tests/test_alerts_api.py \ | |
| tests/test_modules_topology_api.py \ | |
| tests/test_module_registry.py \ | |
| tests/test_inventory_module.py \ | |
| tests/test_topology_module.py \ | |
| tests/test_rate_limit.py \ | |
| tests/test_vault.py \ | |
| tests/test_docgen.py \ | |
| tests/test_deploy.py \ | |
| tests/test_teams_api.py \ | |
| tests/test_auth_requests_api.py \ | |
| tests/test_agent_auto_update.py \ | |
| tests/test_team_scoped_inventory.py \ | |
| --deselect tests/test_task_engine.py::TestTasksAPI \ | |
| -v --tb=short --junit-xml=test-results.xml | |
| continue-on-error: true | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: test-results.xml | |
| # ------------------------------------------------------------------ | |
| # Auto-create a GitHub issue when tests fail, unless one already | |
| # exists with the same title (prevents spam on repeated failures). | |
| # ------------------------------------------------------------------ | |
| - name: Create issue on failure | |
| if: steps.run_tests.outcome == 'failure' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const title = `CI failure on ${context.ref} (${context.sha.substring(0, 7)})`; | |
| const label = 'ci-failure'; | |
| // Check for an existing open issue with the same label to avoid duplicates | |
| const { data: existing } = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| labels: label, | |
| }); | |
| if (existing.length > 0) { | |
| console.log(`Open CI-failure issue already exists (#${existing[0].number}) — skipping creation`); | |
| return; | |
| } | |
| const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| const body = [ | |
| `## CI failure`, | |
| ``, | |
| `**Branch:** \`${context.ref}\``, | |
| `**Commit:** \`${context.sha}\``, | |
| `**Run:** [${context.runId}](${runUrl})`, | |
| ``, | |
| `Tests failed in the CI pipeline. Check the [run log](${runUrl}) for details.`, | |
| ``, | |
| `This issue was created automatically and will be closed once CI passes again.`, | |
| ].join('\n'); | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title, | |
| body, | |
| labels: [label], | |
| }); | |
| # Close any open CI-failure issue when tests pass again | |
| - name: Close CI failure issue on success | |
| if: steps.run_tests.outcome == 'success' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const label = 'ci-failure'; | |
| const { data: existing } = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| labels: label, | |
| }); | |
| for (const issue of existing) { | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issue.number, | |
| state: 'closed', | |
| }); | |
| console.log(`Closed CI failure issue #${issue.number}`); | |
| } | |
| # Fail the job after issue creation so the PR is marked red | |
| - name: Fail job if tests failed | |
| if: steps.run_tests.outcome == 'failure' | |
| run: exit 1 | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: dkastle | |
| POSTGRES_HOST_AUTH_METHOD: trust # gitguardian:ignore | |
| POSTGRES_DB: discoverykastle_test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| env: | |
| INTEGRATION_TEST_DB_URL: postgresql+asyncpg://dkastle@localhost:5432/discoverykastle_test | |
| DKASTLE_DATABASE_URL: postgresql+asyncpg://dkastle@localhost:5432/discoverykastle_test | |
| DKASTLE_SECRET_KEY: ci-integration-test-secret-key-32ch! # gitguardian:ignore | |
| PYTHONPATH: ${{ github.workspace }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install \ | |
| pytest>=8 pytest-asyncio>=0.23 httpx>=0.27 \ | |
| fastapi>=0.111 pydantic>=2.7 "pydantic-settings>=2.3" \ | |
| "sqlalchemy[asyncio]>=2.0" "asyncpg>=0.29" "alembic>=1.13" \ | |
| pyyaml>=6.0 jinja2>=3.1 \ | |
| "passlib>=1.7" "PyJWT>=2.9" \ | |
| "cryptography>=50" | |
| - name: Run Alembic migrations | |
| run: alembic upgrade head | |
| - name: Run integration tests | |
| run: | | |
| python -m pytest tests/integration/ -v --tb=short \ | |
| --junit-xml=integration-test-results.xml | |
| - name: Upload integration test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-test-results | |
| path: integration-test-results.xml |