Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ jobs:
name: "coverage"
runs-on: ubuntu-latest
timeout-minutes: 20
env:
# Dependabot PRs run against the Dependabot secret store, which does not
# carry CODECOV_TOKEN. Compute the flag here (job-level env is visible to
# a step's own `if:`, step-level env is not) and skip the upload rather
# than failing the whole run.
HAS_CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN != '' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down Expand Up @@ -112,13 +118,18 @@ jobs:
run: pytest tests/ --ignore=tests/test_benches.py --ignore=tests/test_wasm.py --cov --cov-report=xml

- name: "Upload coverage to Codecov"
if: env.HAS_CODECOV_TOKEN == 'true'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
files: coverage.xml
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: "Skipped coverage upload (no CODECOV_TOKEN)"
if: env.HAS_CODECOV_TOKEN != 'true'
run: echo "::notice::CODECOV_TOKEN is not available to this run; coverage was measured but not uploaded."

tests:
uses: ./.github/workflows/tests.yaml

Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,15 @@ events: list[tuple[str, list[int], str]] = []
moka: Moka[str, list[int]] = Moka(2, eviction_listener=key_evicted, ttl=0.5)
moka.set("hello", [1, 2, 3])
moka.set("hello", [3, 2, 1]) # replaced
moka.set("foo", [4]) # expired
moka.set("baz", "size")
moka.set("foo", [4])
moka.remove("foo") # explicit
for i in range(10):
moka.set(f"overflow-{i}", [i]) # over capacity, so most of these go away with "size"

# Maintenance is lazy, so ask for it explicitly instead of guessing when it happens
moka.run_pending_tasks()
sleep(1.0)
moka.get("anything") # this will trigger eviction for expired
moka.run_pending_tasks() # whatever survived is past its TTL by now: "expired"

causes = {c for _, _, c in events}
assert causes == {"size", "expired", "replaced", "explicit"}, events
Expand Down
Loading