# Public repository, self-hosted runner: trusted pushes only, so a fork cannot # execute on the runner. Stages are sequential; nothing publishes unless every # earlier stage is green. name: ci on: push: branches: [main] workflow_dispatch: permissions: contents: read defaults: run: shell: bash env: PYTHONUNBUFFERED: "1" UV_LINK_MODE: copy UV_PYTHON_DOWNLOADS: manual IMAGE: git.eeee.moe/omar/fetch-mcp jobs: static: name: static runs-on: fetch-mcp-ci steps: - uses: actions/checkout@v4 - name: Install tooling from the lock file run: uv sync --locked --all-groups - name: ASCII only run: uv run --locked python scripts/check_ascii.py - name: Lint and format run: | uv run --locked ruff check . uv run --locked ruff format --check . - name: Byte-compile everything run: uv run --locked python -m compileall -q $(git ls-files '*.py') test: name: test-${{ matrix.python }} needs: static runs-on: fetch-mcp-ci strategy: fail-fast: false matrix: python: ["3.12", "3.13"] steps: - uses: actions/checkout@v4 - name: Fetch the matrix interpreter run: uv python install ${{ matrix.python }} - name: Install from the lock file run: uv sync --locked --all-groups --python ${{ matrix.python }} - name: Tests with coverage gate run: uv run --locked pytest -q --junitxml=junit.xml - name: Keep the report if: always() uses: actions/upload-artifact@v3.2.2 with: name: coverage-${{ matrix.python }} path: | coverage.xml junit.xml .coverage if-no-files-found: warn image: name: image needs: test runs-on: fetch-mcp-ci outputs: tag: ${{ steps.meta.outputs.tag }} steps: - uses: actions/checkout@v4 - name: Derive the content tag id: meta run: echo "tag=sha-$(git rev-parse --short=12 HEAD)" >> "$GITHUB_OUTPUT" - name: Build id: build run: | set -euo pipefail docker build --pull --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ -t "$IMAGE:${{ steps.meta.outputs.tag }}" . docker image inspect "$IMAGE:${{ steps.meta.outputs.tag }}" --format '{{.Id}}' smoke: name: smoke needs: image runs-on: fetch-mcp-ci steps: - uses: actions/checkout@v4 - name: Run the built image offline over stdio run: | set -euo pipefail image="$IMAGE:${{ needs.image.outputs.tag }}" name="smoke-$(date +%s%N)-$$" docker create --name "$name" --network none -e MCP_LIVE_ROUTE=direct -i "$image" > /dev/null trap 'docker rm -f "$name" > /dev/null 2>&1 || true' EXIT python3 scripts/mcp_smoke.py | docker start -a -i "$name" > smoke.out code=$(docker inspect --format '{{.State.ExitCode}}' "$name") cat smoke.out test "$code" = "0" python3 - "$name" <<'PY' import json, sys lines = [line for line in open("smoke.out", encoding="utf-8") if line.strip()] assert lines, "no stdout" ids = [] for line in lines: frame = json.loads(line) assert frame.get("jsonrpc") == "2.0", frame assert "error" not in frame, frame if "id" in frame: ids.append(frame["id"]) assert ids == [1, 2, 3], ids init = next(json.loads(line) for line in lines if '"id": 1' in line or '"id":1' in line) tools = init["result"]["capabilities"]["tools"] assert tools is not None print("smoke ok:", ids) PY - name: Solver binary answers offline run: | set -euo pipefail out=$(docker run --rm --network none --entrypoint /opt/cfsolve/challenge \ "$IMAGE:${{ needs.image.outputs.tag }}" --help) printf '%s\n' "$out" | head -3 printf '%s' "$out" | grep -q -- '--fingerprint' - name: Keep the transcript if: always() uses: actions/upload-artifact@v3.2.2 with: name: smoke path: smoke.out publish: name: publish needs: [image, smoke] if: github.ref == 'refs/heads/main' && github.event_name == 'push' runs-on: fetch-mcp-ci steps: - name: Require a green smoke run: test "${{ needs.smoke.result }}" = "success" - uses: actions/checkout@v4 - name: Log in with the package token run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.eeee.moe -u omar --password-stdin - name: Push the immutable tag built above run: | set -euo pipefail image="$IMAGE:${{ needs.image.outputs.tag }}" docker image inspect "$image" > /dev/null docker push "$image" docker image inspect "$image" --format '{{.RepoDigests}}' - name: Move latest only if HEAD has not moved run: | set -euo pipefail built=$(docker image inspect "$IMAGE:${{ needs.image.outputs.tag }}" --format '{{index .Config.Labels "org.opencontainers.image.revision"}}') head=$(git rev-parse HEAD) docker tag "$IMAGE:${{ needs.image.outputs.tag }}" "$IMAGE:latest" if [ "$built" = "$head" ]; then docker push "$IMAGE:latest" else echo "HEAD moved to $head, leaving latest alone" fi