ci: single Gitea Actions pipeline, uv-based image, scoped docker cleanup
Replace lint/test/docker workflows with ci.yml (gitleaks, lint, test-unit, test-integration, test-mcp, build-and-push, docs-check, security). Rebuild the Dockerfile as a digest-pinned multi-stage uv build running as uid 1000, add .dockerignore, a hardened compose file and a gitleaks config. The integration harness now falls back to /etc/hostname and /proc/self to find its own container.
This commit is contained in:
1 parent
9e50859133
commit
1a039e32ab
16 files changed
+729
-404
No files matched your search
@@ -0,0 +1,341 @@
|
||||
name: ci
|
||||
|
||||
# One pipeline, eight jobs:
|
||||
#
|
||||
# gitleaks secret scan over the full history
|
||||
# lint ruff check, ruff format --check, mypy
|
||||
# test-unit pytest (coverage gate from pyproject.toml)
|
||||
# test-integration pytest against a throwaway Gitea in Docker
|
||||
# test-mcp MCP smoke tests, including against the freshly built image
|
||||
# build-and-push build the image; push it on push events (needs lint + test-unit)
|
||||
# docs-check docs drift check
|
||||
# security security test suite, pip-audit, ruff bandit rules
|
||||
#
|
||||
# Docker hygiene on the shared runner: every resource this workflow creates has
|
||||
# a per-run name (aegis-ci-<run id>-...) and is removed by an `if: always()`
|
||||
# step that deletes exactly those names. Nothing here ever prunes.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
|
||||
env:
|
||||
UV_PYTHON_DOWNLOADS: never
|
||||
UV_NO_PROGRESS: "1"
|
||||
|
||||
jobs:
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. Secret scan: pinned gitleaks binary (sha256 verified), full history.
|
||||
# ---------------------------------------------------------------------------
|
||||
gitleaks:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install gitleaks
|
||||
shell: bash
|
||||
run: |
|
||||
bin_dir="${RUNNER_TEMP:-/tmp}/gitleaks-bin"
|
||||
bash scripts/ci/install_gitleaks.sh "${bin_dir}"
|
||||
echo "${bin_dir}" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Scan history
|
||||
shell: bash
|
||||
run: gitleaks git --config .gitleaks.toml --redact --no-banner --verbose --exit-code 1 .
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Lint
|
||||
# ---------------------------------------------------------------------------
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
- name: Install dependencies
|
||||
run: uv sync --locked
|
||||
- name: Ruff check
|
||||
run: uv run ruff check .
|
||||
- name: Ruff format
|
||||
run: uv run ruff format --check .
|
||||
- name: Mypy
|
||||
run: uv run mypy src
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. Unit tests (integration tests are skipped without AEGIS_INTEGRATION=1).
|
||||
# ---------------------------------------------------------------------------
|
||||
test-unit:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
- name: Install dependencies
|
||||
run: uv sync --locked
|
||||
- name: Run unit tests
|
||||
run: uv run pytest --cov-report=term-missing --cov-report=xml:coverage.xml
|
||||
- name: Upload coverage report
|
||||
# Best effort: some act_runner versions do not support the v4 artifact
|
||||
# backend, and the coverage gate itself already ran above.
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-${{ github.run_id }}
|
||||
path: coverage.xml
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 4. Integration tests against a throwaway Gitea 28.1.0 in Docker. The job
|
||||
# container is joined to a per-run network (container mode), see
|
||||
# tests/integration/README.md. The harness removes what it creates; the
|
||||
# cleanup step is the safety net for cancelled runs.
|
||||
# ---------------------------------------------------------------------------
|
||||
test-integration:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
- name: Install dependencies
|
||||
run: uv sync --locked
|
||||
- name: Run integration tests
|
||||
env:
|
||||
AEGIS_INTEGRATION: "1"
|
||||
AEGIS_IT_NETWORK_MODE: container
|
||||
run: uv run pytest tests/integration -m integration --no-cov
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
shell: bash
|
||||
run: bash scripts/ci/cleanup_job_resources.sh
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 5. MCP smoke tests. Builds its own copy of the image (same Dockerfile, same
|
||||
# commit) so the tests can also exercise the container, and passes the
|
||||
# reference through AEGIS_MCP_IMAGE. The image cannot be shared with
|
||||
# build-and-push: pull requests never push, and jobs may land on different
|
||||
# runners.
|
||||
# ---------------------------------------------------------------------------
|
||||
test-mcp:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 40
|
||||
env:
|
||||
MCP_IMAGE: aegis-ci-${{ github.run_id }}-mcp:test
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
- name: Install dependencies
|
||||
run: uv sync --locked
|
||||
- name: Build image
|
||||
run: docker build -f docker/Dockerfile -t "${MCP_IMAGE}" .
|
||||
- name: Run MCP smoke tests
|
||||
env:
|
||||
AEGIS_MCP_IMAGE: ${{ env.MCP_IMAGE }}
|
||||
# Smoke tests that start a throwaway Gitea use the same harness as the
|
||||
# integration tests.
|
||||
AEGIS_INTEGRATION: "1"
|
||||
AEGIS_IT_NETWORK_MODE: container
|
||||
run: uv run pytest tests/mcp -m mcp_smoke --no-cov
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
shell: bash
|
||||
run: bash scripts/ci/cleanup_job_resources.sh "${MCP_IMAGE}"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 6. Build the image from the checked-out commit. On push events it is also
|
||||
# pushed:
|
||||
# :sha-<12> every branch (immutable, traceable to the commit; lets any
|
||||
# feature branch image be pulled and tested)
|
||||
# :dev additionally on dev
|
||||
# :latest and :main additionally on main
|
||||
# Pull requests only build. The pushed digest is recorded in the job
|
||||
# outputs and the job summary.
|
||||
# ---------------------------------------------------------------------------
|
||||
build-and-push:
|
||||
needs: [lint, test-unit]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
outputs:
|
||||
image: ${{ steps.meta.outputs.sha_tag }}
|
||||
digest: ${{ steps.digest.outputs.digest }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Compute image name and tags
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
IMAGE="git.hiddenden.cafe/${GITHUB_REPOSITORY,,}"
|
||||
SHA_TAG="${IMAGE}:sha-${GITHUB_SHA::12}"
|
||||
EXTRA_TAGS=""
|
||||
if [ "${GITHUB_EVENT_NAME}" = "push" ]; then
|
||||
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
||||
EXTRA_TAGS="${IMAGE}:latest ${IMAGE}:main"
|
||||
elif [ "${GITHUB_REF_NAME}" = "dev" ]; then
|
||||
EXTRA_TAGS="${IMAGE}:dev"
|
||||
fi
|
||||
fi
|
||||
{
|
||||
echo "image=${IMAGE}"
|
||||
echo "sha_tag=${SHA_TAG}"
|
||||
echo "extra_tags=${EXTRA_TAGS}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build image
|
||||
shell: bash
|
||||
run: |
|
||||
docker build -f docker/Dockerfile \
|
||||
--label "org.opencontainers.image.revision=${GITHUB_SHA}" \
|
||||
--label "org.opencontainers.image.source=https://git.hiddenden.cafe/${GITHUB_REPOSITORY}" \
|
||||
-t "${{ steps.meta.outputs.sha_tag }}" .
|
||||
|
||||
- name: Smoke-test image
|
||||
shell: bash
|
||||
run: docker run --rm "${{ steps.meta.outputs.sha_tag }}" version
|
||||
|
||||
- name: Log in to the registry
|
||||
if: github.event_name == 'push'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.hiddenden.cafe
|
||||
username: ${{ github.actor }}
|
||||
# PAT with write:package scope. The built-in token lacks package-write
|
||||
# on this instance.
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Tag and push
|
||||
if: github.event_name == 'push'
|
||||
shell: bash
|
||||
run: |
|
||||
for tag in ${{ steps.meta.outputs.extra_tags }}; do
|
||||
docker tag "${{ steps.meta.outputs.sha_tag }}" "${tag}"
|
||||
done
|
||||
for tag in ${{ steps.meta.outputs.sha_tag }} ${{ steps.meta.outputs.extra_tags }}; do
|
||||
docker push "${tag}"
|
||||
done
|
||||
|
||||
- name: Record digest
|
||||
id: digest
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "${GITHUB_EVENT_NAME}" = "push" ]; then
|
||||
DIGEST="$(docker inspect --format '{{index .RepoDigests 0}}' "${{ steps.meta.outputs.sha_tag }}")"
|
||||
else
|
||||
DIGEST="not pushed (pull request build)"
|
||||
fi
|
||||
echo "digest=${DIGEST}" >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
echo "### Image"
|
||||
echo
|
||||
echo "- tag: \`${{ steps.meta.outputs.sha_tag }}\`"
|
||||
echo "- digest: \`${DIGEST}\`"
|
||||
if [ -n "${{ steps.meta.outputs.extra_tags }}" ]; then
|
||||
echo "- also tagged: \`${{ steps.meta.outputs.extra_tags }}\`"
|
||||
fi
|
||||
} >> "${GITHUB_STEP_SUMMARY:-/dev/null}"
|
||||
echo "image digest: ${DIGEST}"
|
||||
|
||||
# Removes exactly what this run created, even on failure. No prune.
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
shell: bash
|
||||
run: |
|
||||
docker logout git.hiddenden.cafe || true
|
||||
bash scripts/ci/cleanup_job_resources.sh \
|
||||
"${{ steps.meta.outputs.sha_tag }}" ${{ steps.meta.outputs.extra_tags }}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 7. Docs drift check
|
||||
# ---------------------------------------------------------------------------
|
||||
docs-check:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
- name: Install dependencies
|
||||
run: uv sync --locked
|
||||
- name: Check docs against code and spec
|
||||
run: uv run python scripts/check_docs.py
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 8. Security: test suite, dependency audit, bandit rules via ruff.
|
||||
# Waivers live in docs/security.md; advisory ignores in
|
||||
# security/pip-audit-ignore.txt.
|
||||
# ---------------------------------------------------------------------------
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
- name: Install dependencies
|
||||
run: uv sync --locked
|
||||
- name: Security tests
|
||||
run: uv run pytest tests/security --no-cov
|
||||
- name: Dependency audit
|
||||
run: bash scripts/ci/pip_audit.sh
|
||||
- name: Ruff security rules
|
||||
run: uv run ruff check --select S .
|
||||
@@ -1,125 +0,0 @@
|
||||
name: docker
|
||||
|
||||
on:
|
||||
# Test on every branch push; registry push is gated per-step to main/dev.
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. Lint: ruff + black + mypy.
|
||||
# ---------------------------------------------------------------------------
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements-dev.txt
|
||||
- name: Run lint
|
||||
run: |
|
||||
ruff check src tests
|
||||
ruff format --check src tests
|
||||
black --check src tests
|
||||
mypy src
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Test: pytest with coverage gate.
|
||||
# ---------------------------------------------------------------------------
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements-dev.txt
|
||||
- name: Run tests
|
||||
run: pytest --cov=aegis_gitea_mcp --cov-report=term-missing --cov-fail-under=80
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. Build the Docker image, smoke-test it, push to Gitea (push events to
|
||||
# main/dev only), then clean up so nothing lingers on the self-hosted
|
||||
# runner.
|
||||
# ---------------------------------------------------------------------------
|
||||
docker:
|
||||
needs: [lint, test]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Compute image name & tags
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
IMAGE="git.hiddenden.cafe/${GITHUB_REPOSITORY,,}"
|
||||
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
|
||||
echo "sha_tag=${IMAGE}:sha-${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
|
||||
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
||||
# Production: stable :latest + :main
|
||||
echo "branch_tags=${IMAGE}:latest ${IMAGE}:main" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
# dev (and any other branch): tag with the branch name
|
||||
echo "branch_tags=${IMAGE}:${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Build image
|
||||
shell: bash
|
||||
run: docker build -f docker/Dockerfile -t "${{ steps.meta.outputs.sha_tag }}" .
|
||||
|
||||
- name: Smoke-test image
|
||||
shell: bash
|
||||
run: |
|
||||
docker run --rm --entrypoint python "${{ steps.meta.outputs.sha_tag }}" \
|
||||
-c "import aegis_gitea_mcp"
|
||||
echo "Image imports cleanly."
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev')
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.hiddenden.cafe
|
||||
username: ${{ github.actor }}
|
||||
# PAT with write:package scope, stored as the REGISTRY_TOKEN secret.
|
||||
# The auto-provided GITEA_TOKEN lacks package-write permission on
|
||||
# this instance, so we use a dedicated token here.
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Tag & push
|
||||
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev')
|
||||
shell: bash
|
||||
run: |
|
||||
for tag in ${{ steps.meta.outputs.branch_tags }} ${{ steps.meta.outputs.sha_tag }}; do
|
||||
docker tag "${{ steps.meta.outputs.sha_tag }}" "$tag"
|
||||
docker push "$tag"
|
||||
echo "Pushed $tag"
|
||||
done
|
||||
|
||||
# Always runs — removes exactly what this run created, even on failure.
|
||||
# Scoped on purpose: if the runner shares the host Docker daemon, a global
|
||||
# prune would also wipe other homelab services. We never create volumes
|
||||
# here, so only dangling images + build cache are swept.
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
shell: bash
|
||||
run: |
|
||||
docker rmi -f ${{ steps.meta.outputs.sha_tag }} ${{ steps.meta.outputs.branch_tags }} || true
|
||||
docker image prune -f || true
|
||||
docker builder prune -f || true
|
||||
@@ -1,34 +0,0 @@
|
||||
name: lint
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements-dev.txt
|
||||
|
||||
- name: Run Ruff (fail on any diagnostics)
|
||||
run: ruff check src tests
|
||||
|
||||
- name: Enforce formatting
|
||||
run: |
|
||||
ruff format --check src tests
|
||||
black --check src tests
|
||||
|
||||
- name: Run mypy
|
||||
run: mypy src
|
||||
@@ -3,7 +3,7 @@ name: publish
|
||||
# Build the Python package with uv and publish it to the self-hosted Gitea PyPI
|
||||
# registry on merge. dev -> a dev package (aegis-gitea-mcp-dev, .devN versions);
|
||||
# main -> the stable package (aegis-gitea-mcp). Gated on lint + tests so a release
|
||||
# can never ship red. Reuses the REGISTRY_TOKEN package secret (same one docker.yml
|
||||
# can never ship red. Reuses the REGISTRY_TOKEN package secret (same one ci.yml
|
||||
# uses); if it is absent the job fails loudly instead of publishing anonymously.
|
||||
on:
|
||||
push:
|
||||
@@ -13,7 +13,7 @@ on:
|
||||
|
||||
jobs:
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. Lint: ruff + black + mypy (same gate as the other workflows).
|
||||
# 1. Lint (same gate as ci.yml, via uv and the lockfile).
|
||||
# ---------------------------------------------------------------------------
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -24,19 +24,21 @@ jobs:
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements-dev.txt
|
||||
run: uv sync --locked
|
||||
- name: Run lint
|
||||
run: |
|
||||
ruff check src tests
|
||||
ruff format --check src tests
|
||||
black --check src tests
|
||||
mypy src
|
||||
uv run ruff check .
|
||||
uv run ruff format --check .
|
||||
uv run mypy src
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Test: pytest with coverage gate.
|
||||
# 2. Test: unit tests with the coverage gate from pyproject.toml.
|
||||
# ---------------------------------------------------------------------------
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -47,12 +49,15 @@ jobs:
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements-dev.txt
|
||||
run: uv sync --locked
|
||||
- name: Run tests
|
||||
run: pytest --cov=aegis_gitea_mcp --cov-report=term-missing --cov-fail-under=80
|
||||
run: uv run pytest
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. Build with uv and publish to the Gitea PyPI registry.
|
||||
@@ -78,6 +83,9 @@ jobs:
|
||||
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
version: "0.12.5"
|
||||
enable-cache: false
|
||||
|
||||
- name: Require publish credentials
|
||||
shell: bash
|
||||
@@ -100,7 +108,9 @@ jobs:
|
||||
CHANNEL="stable"
|
||||
else
|
||||
PKG_NAME="aegis-gitea-mcp-dev"
|
||||
PKG_VERSION="${BASE}.dev${GITHUB_RUN_NUMBER}"
|
||||
# Drop an existing .devN suffix (the committed version may be a
|
||||
# development version) so the result has exactly one dev segment.
|
||||
PKG_VERSION="${BASE%%.dev*}.dev${GITHUB_RUN_NUMBER}"
|
||||
CHANNEL="dev"
|
||||
fi
|
||||
echo "pkg_name=${PKG_NAME}" >> "$GITHUB_OUTPUT"
|
||||
@@ -133,7 +143,7 @@ jobs:
|
||||
- name: Publish to Gitea PyPI registry
|
||||
shell: bash
|
||||
env:
|
||||
# Reuse the existing package secret (same one docker.yml uses). The
|
||||
# Reuse the existing package secret (same one ci.yml uses). The
|
||||
# token authenticates as its owning Gitea user, so GITHUB_ACTOR is the
|
||||
# username and the token is the password.
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements-dev.txt
|
||||
|
||||
- name: Run lint
|
||||
run: |
|
||||
ruff check src tests
|
||||
ruff format --check src tests
|
||||
black --check src tests
|
||||
|
||||
- name: Run tests with coverage gate
|
||||
run: |
|
||||
pytest --cov=aegis_gitea_mcp --cov-report=term-missing --cov-fail-under=80
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Package: build with uv and smoke-test both install profiles so packaging
|
||||
# regressions (broken console scripts, dependency split) are caught in CI.
|
||||
# ---------------------------------------------------------------------------
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Set up uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
|
||||
- name: Build sdist + wheel
|
||||
run: uv build
|
||||
|
||||
- name: Smoke-test the core (stdio) install
|
||||
shell: bash
|
||||
run: |
|
||||
WHEEL="$(echo dist/*.whl)"
|
||||
python -m venv /tmp/core
|
||||
/tmp/core/bin/pip install --quiet "$WHEEL"
|
||||
# The core install must NOT pull in the web stack.
|
||||
if /tmp/core/bin/python -c "import importlib.util,sys; sys.exit(0 if importlib.util.find_spec('fastapi') else 1)"; then
|
||||
echo "::error::core install unexpectedly includes fastapi" >&2
|
||||
exit 1
|
||||
fi
|
||||
# The stdio console script exists and exits 2 with a clear error when
|
||||
# required env vars are missing (no traceback).
|
||||
set +e
|
||||
GITEA_URL= GITEA_TOKEN= /tmp/core/bin/aegis-gitea-mcp >/dev/null 2>/tmp/core_err.txt
|
||||
rc=$?
|
||||
set -e
|
||||
test "$rc" = "2" || { echo "::error::stdio entry exit $rc (expected 2)"; cat /tmp/core_err.txt; exit 1; }
|
||||
grep -q "GITEA_URL" /tmp/core_err.txt
|
||||
echo "core stdio entry OK (exit 2, no fastapi)"
|
||||
|
||||
- name: Smoke-test the [server] install
|
||||
shell: bash
|
||||
run: |
|
||||
WHEEL="$(echo dist/*.whl)"
|
||||
python -m venv /tmp/server
|
||||
/tmp/server/bin/pip install --quiet "${WHEEL}[server]"
|
||||
/tmp/server/bin/python -c "import fastapi, uvicorn, aegis_gitea_mcp.server_entry; print('server extra import OK')"
|
||||
Reference in new issue
Block a user