Skip to content

fix(tests): skip pricing test when agentic cost module is absent - #3

Merged
ancongui merged 4 commits into
mainfrom
fix/skip-pricing-test-when-cost-module-absent
May 14, 2026
Merged

ancongui merged 4 commits into
mainfrom
fix/skip-pricing-test-when-cost-module-absent

Conversation

@ancongui

Copy link
Copy Markdown
Contributor

Adds pytest.importorskip in front of test_genai_prices_resolves_our_anthropic_models so it skips cleanly in CI when fireflyframework-agentic's main branch hasn't exported the cost module yet. Service behaviour is unaffected (outbound_log already swallows the same ImportError). 15/15 pass locally.

ancongui added 4 commits May 14, 2026 17:04
CI clones fireflyframework-agentic at ``main`` to build the workflow
environment. When that ref doesn't yet export
``fireflyframework_agentic.observability.cost``, the
``test_genai_prices_resolves_our_anthropic_models`` test fails with
ImportError -- even though service behaviour is unaffected, since
``outbound_log._extract_usage_fields`` already swallows the same
import silently and falls back to a zero-cost log line.

Use ``pytest.importorskip`` so the test exercises the resolver chain
when the module is reachable (the common local case) and skips
cleanly when it isn't. The skip is informative -- it carries a reason
that points at the most likely cause -- so a regression that loses
the cost feature shows up as a skip-count drop instead of a silent
fall-through.

Verified locally: 15/15 in tests/unit/test_observability_usage.py.
Two follow-ups that unblock the PR-gate and publish workflows the
multi-arch CI/CD PR (#2) added.

Ruff

* Added ``[tool.ruff.lint.per-file-ignores]`` exempting four areas
  from the rules that fight the public-API contract:
    - ``src/flydesk_idp/interfaces/**``: ``N801``, ``N811``, ``N815``,
      ``N818`` (camelCase DTOs are the wire format).
    - ``src/flydesk_idp/core/services/jobs/**`` +
      ``…/webhook/**``: ``N818`` (controller-advice maps these
      exception names by spelling).
    - ``src/flydesk_idp/core/services/judge/**``: ``N815`` (re-binds
      the public field names locally).
    - ``src/flydesk_idp/core/services/validation/**``: ``N811``
      (``PyUUID`` aliases stdlib ``UUID`` to avoid colliding with the
      project's column type).
    - ``tests/**``: ``E501`` -- test fixtures routinely build long
      inline DTOs.
* Ran ``ruff check --fix --unsafe-fixes`` + ``ruff format`` against
  the tree to normalise the imports and quoting that fell out of
  the unit-test fix in 99ec5f1.

Workflows

* ``docker-publish.yaml`` -- the ``actions/attest-build-provenance``
  step now runs with ``continue-on-error: true``. It requires the
  GitHub *Build & Validate Attestations* feature (paid / Enterprise
  or a public repo) and previously failed with a 403 for the
  free-plan ``firefly-operationOS`` org. The buildkit-emitted SLSA
  provenance attached via ``provenance: true`` on
  ``docker/build-push-action`` is the canonical signature; this step
  is just a belt-and-braces upload.

Verified

* ``uv run ruff check . && uv run ruff format --check .`` clean.
* ``uv run pytest -q tests/unit`` -- 94 passed.
* The prior docker-publish run already pushed the multi-arch image
  (digest ``sha256:e47002c0…``); only the attestation step failed.
The PR-gate workflow clones fireflyframework-pyfly and
fireflyframework-agentic into ./vendor/ so the Dockerfile's BuildKit
``--build-context`` references resolve in CI the same way they do
locally. ``uv run ruff check .`` then descends into those clones and
fails on framework code we don't own. ``extend-exclude = ["vendor"]``
keeps the framework trees out of the lint scope while still letting
the docker job pick them up.
@ancongui
ancongui merged commit 5418894 into main May 14, 2026
3 of 4 checks passed
@ancongui
ancongui deleted the fix/skip-pricing-test-when-cost-module-absent branch May 14, 2026 15:16
ancongui added a commit that referenced this pull request May 31, 2026
* fix(tests): skip pricing test when agentic cost module is absent

CI clones fireflyframework-agentic at ``main`` to build the workflow
environment. When that ref doesn't yet export
``fireflyframework_agentic.observability.cost``, the
``test_genai_prices_resolves_our_anthropic_models`` test fails with
ImportError -- even though service behaviour is unaffected, since
``outbound_log._extract_usage_fields`` already swallows the same
import silently and falls back to a zero-cost log line.

Use ``pytest.importorskip`` so the test exercises the resolver chain
when the module is reachable (the common local case) and skips
cleanly when it isn't. The skip is informative -- it carries a reason
that points at the most likely cause -- so a regression that loses
the cost feature shows up as a skip-count drop instead of a silent
fall-through.

Verified locally: 15/15 in tests/unit/test_observability_usage.py.

* fix(ci): ruff per-file-ignores + advisory attestation step

Two follow-ups that unblock the PR-gate and publish workflows the
multi-arch CI/CD PR (#2) added.

Ruff

* Added ``[tool.ruff.lint.per-file-ignores]`` exempting four areas
  from the rules that fight the public-API contract:
    - ``src/flydesk_idp/interfaces/**``: ``N801``, ``N811``, ``N815``,
      ``N818`` (camelCase DTOs are the wire format).
    - ``src/flydesk_idp/core/services/jobs/**`` +
      ``…/webhook/**``: ``N818`` (controller-advice maps these
      exception names by spelling).
    - ``src/flydesk_idp/core/services/judge/**``: ``N815`` (re-binds
      the public field names locally).
    - ``src/flydesk_idp/core/services/validation/**``: ``N811``
      (``PyUUID`` aliases stdlib ``UUID`` to avoid colliding with the
      project's column type).
    - ``tests/**``: ``E501`` -- test fixtures routinely build long
      inline DTOs.
* Ran ``ruff check --fix --unsafe-fixes`` + ``ruff format`` against
  the tree to normalise the imports and quoting that fell out of
  the unit-test fix in 99ec5f1.

Workflows

* ``docker-publish.yaml`` -- the ``actions/attest-build-provenance``
  step now runs with ``continue-on-error: true``. It requires the
  GitHub *Build & Validate Attestations* feature (paid / Enterprise
  or a public repo) and previously failed with a 403 for the
  free-plan ``firefly-operationOS`` org. The buildkit-emitted SLSA
  provenance attached via ``provenance: true`` on
  ``docker/build-push-action`` is the canonical signature; this step
  is just a belt-and-braces upload.

Verified

* ``uv run ruff check . && uv run ruff format --check .`` clean.
* ``uv run pytest -q tests/unit`` -- 94 passed.
* The prior docker-publish run already pushed the multi-arch image
  (digest ``sha256:e47002c0…``); only the attestation step failed.

* docs(cicd): note GHCR visibility default + attestation gating

* fix(ci): exclude ./vendor/ from ruff so framework clones aren't linted

The PR-gate workflow clones fireflyframework-pyfly and
fireflyframework-agentic into ./vendor/ so the Dockerfile's BuildKit
``--build-context`` references resolve in CI the same way they do
locally. ``uv run ruff check .`` then descends into those clones and
fails on framework code we don't own. ``extend-exclude = ["vendor"]``
keeps the framework trees out of the lint scope while still letting
the docker job pick them up.

---------

Co-authored-by: ancongui <andres.contreras@soon.es>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant