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
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ Include relevant manual verification and redacted screenshots for UI changes. --
- [ ] I have read CONTRIBUTING.md and CODE_OF_CONDUCT.md.
- [ ] The change is focused and contains no credentials or sensitive data.
- [ ] I have added or updated relevant documentation and tests, where applicable.
- [ ] Theme changes: I have updated `tests/snapshots/themes` and checked the new images
(see CONTRIBUTING.md, Theme changes).
- [ ] New providers: `every_provider_meets_the_contract` passes with a redacted fixture
(see CONTRIBUTING.md, Provider changes).
- [ ] I have left changelog and version changes to maintainers unless requested.
160 changes: 160 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: CI

on:
pull_request:
push:
branches: [main]
workflow_dispatch:
workflow_call:

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
CARGO_TERM_COLOR: always
# Keep in sync with rust-toolchain.toml.
RUST_TOOLCHAIN: 1.95.0

jobs:
fmt:
name: rustfmt
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt

- name: Check formatting
run: cargo fmt --all -- --check

clippy:
name: clippy
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: clippy

- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Run Clippy
run: cargo clippy --locked --all-targets -- -D warnings

test:
name: test
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}

- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
save-if: ${{ github.ref == 'refs/heads/main' }}

# Tests needing signed-in providers, the live Internet or the current
# desktop are #[ignore]d and do not run here.
- name: Run tests
run: cargo test --locked

# Every theme surface rendered in dark and light mode by the snapshot
# tests, plus a -diff.png for each mismatch, so theme changes can be
# reviewed as pictures.
- name: Upload theme renders
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: theme-snapshots
path: target/theme-snapshots
if-no-files-found: ignore
retention-days: 14

release-build:
name: release build
runs-on: windows-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}

- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Build release binary
run: cargo build --release --locked

# Release metadata and tracked-file rules from scripts/ReleaseTools.psm1. Uses
# Windows PowerShell 5.1, the shell the local release scripts run in.
repository:
name: repository checks
runs-on: windows-latest
timeout-minutes: 10
defaults:
run:
shell: powershell
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Test release tooling
run: ./tests/Test-ReleaseTools.ps1

- name: Check repository state
run: ./tests/Test-Repository.ps1

# cargo-audit and cargo-deny. Part of CI passed, so a pull request that adds
# a vulnerable or disallowed dependency cannot merge.
dependency-security:
name: dependency security
uses: ./.github/workflows/dependency-security.yml
permissions:
contents: read

# Single stable check name to require in branch protection.
ci-passed:
name: CI passed
if: always()
needs: [fmt, clippy, test, release-build, repository, dependency-security]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Require every CI job to succeed
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
echo "Job results: $RESULTS"
for result in $RESULTS; do
if [ "$result" != "success" ]; then
exit 1
fi
done
45 changes: 45 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Dependabot auto-merge

# Turns on auto-merge for Dependabot pull requests that only make patch-level
# Cargo updates. GitHub merges them once the required "CI passed" check
# succeeds. Minor and major updates, the egui group (the local egui-winit patch
# needs review, see docs/dependency-security.md) and GitHub Actions updates
# (workflow code that runs with release secrets) still wait for a maintainer. Merged updates collect
# on main until the next release, and scripts/New-Release.ps1 lists them in
# CHANGELOG.md. See docs/releasing.md.
#
# Needs "Allow auto-merge" in the repository settings and a branch protection
# rule (or ruleset) on main that requires "CI passed". Without the required
# check, auto-merge would merge immediately.

on:
pull_request_target:
types: [opened, reopened, synchronize]

permissions: {}

jobs:
auto-merge:
name: auto-merge patch updates
# pull_request_target runs with write access, so this job never checks out
# or runs code from the pull request.
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'CodeZeno/Claude-Code-Usage-Monitor'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
pull-requests: write
steps:
- name: Read Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0

- name: Enable auto-merge
if: >-
steps.metadata.outputs.update-type == 'version-update:semver-patch' &&
steps.metadata.outputs.package-ecosystem == 'cargo' &&
steps.metadata.outputs.dependency-group != 'egui'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: gh pr merge --auto --squash "$PR_URL"
5 changes: 2 additions & 3 deletions .github/workflows/dependency-security.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Dependency security

# Pull requests and pushes to main run these checks through ci.yml, as part of
# the CI passed status.
on:
pull_request:
push:
branches: ["**"]
schedule:
# Find newly published advisories even when the lockfile has not changed.
- cron: "23 3 * * *"
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ env:
WINGET_PACKAGE_ID: CodeZeno.ClaudeCodeUsageMonitor

jobs:
dependency-security:
uses: ./.github/workflows/dependency-security.yml
# Includes the dependency security checks.
ci:
uses: ./.github/workflows/ci.yml
permissions:
contents: read

build:
needs: dependency-security
needs: [ci]
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
Expand Down
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@ Notable changes to Claude Code Usage Monitor are documented here, newest first.
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), with
changes grouped into Added, Changed, Fixed, and Removed where applicable.

## [Unreleased]

### Added

- Run formatting, Clippy with warnings denied, tests, a locked release build, and repository checks on every pull request and push to `main`, reporting a single `CI passed` status for branch protection.
- Check release metadata in CI and locally with `tests/Test-Repository.ps1`: tracked ignored or local-only files, the `Cargo.lock` package version, and `CHANGELOG.md` structure, ordering, links, and agreement with the `Cargo.toml` version. Merged changes accumulate under `[Unreleased]` until a release is prepared.
- Add `scripts/New-Release.ps1` to prepare a `vVERSION` release commit from the `[Unreleased]` entries, `scripts/Publish-Release.ps1` to tag a pushed release, and `scripts/Build-Release.ps1` for local release builds. See [docs/releasing.md](docs/releasing.md).
- Let theme colours set an optional light-mode colour (`light_color`), so one layer can serve both Windows appearances instead of a pair of layers gated on `system.dark`. In Theme Studio, the sun and moon button beside a colour expands it into separate Dark mode and Light mode colours; collapsing keeps the dark mode colour. Colours without `light_color` render and save as before, and themes that keep separate per-mode layers are unaffected.
- Add the Stacked Rows built-in theme: each provider's logo beside joined rows of four-section bars, one row per limit the account reports, with a magenta pace marker. Bars follow the Usage direction setting, and hovering a provider opens a flyout with each limit's usage, reset time and pace, or a waiting, error or no-usage message.
- Add a Provider logo layer type (`provider_mark`) to themes and Theme Studio. It draws a provider's brand mark from the dashboard's icon font, tinted and fitted to the layer, so themes need no image assets to show a provider.
- Render themes to PNG without starting the app: `--render-theme <theme.json | built-in id> --out <file.png | folder>`, with `--surface`, `--appearance`, `--fixture`, `--now`, `--utc-offset` and `--scale`. The clock, time zone and appearance are fixed, so the same input gives the same image. See [CONTRIBUTING.md](CONTRIBUTING.md#theme-changes).
- Test every surface of every built-in theme in dark and light mode against reference images in `tests/snapshots/themes`. CI uploads the renders as the `theme-snapshots` artifact, so a theme pull request can be reviewed as pictures.
- Add a provider contract test: every provider needs a redacted response fixture that its parser reads, usage that survives the usage cache and reaches themes, translated setting text, and unique identifiers. See [CONTRIBUTING.md](CONTRIBUTING.md#provider-changes).
- Add a [feature map](docs/feature-map.md) naming each part of the app and where its code lives.
- Add a generated [theme reference](docs/theme-reference.md) listing every theme field, expression value, operator, function, template format and mouse action, with results computed from the sample usage. It is generated from the definitions the theme engine and Theme Studio use, `cargo test` fails when it is out of date, and `--theme-reference` prints it.
- Report theme mistakes with the likely fix: `--render-theme` warns about fields the engine does not know (`'widht' is not a theme field; did you mean 'width'?`), and theme validation suggests the closest value, function, mouse action or template format for an unknown one.
- Auto-merge Dependabot pull requests with patch-level Cargo updates once `CI passed` succeeds. `scripts/New-Release.ps1` adds changelog entries for them and refuses to prepare a release when `origin/main` has commits that local `main` lacks. See [docs/releasing.md](docs/releasing.md#dependabot-updates).

### Changed

- Require the CI checks to pass before the tagged Release workflow builds and publishes artifacts.
- Resolve the remaining Clippy warnings in test code so CI can deny warnings.
- Enforce code boundaries with lints in `Cargo.toml` and `clippy.toml`, described in [CONTRIBUTING.md](CONTRIBUTING.md#lint-rules):
- unsafe code is allowed only in files that opt in;
- new unsafe blocks need a `// SAFETY:` comment, as a ratchet;
- production code cannot use `unwrap()`, and the 11 remaining calls are replaced;
- HTTP agents are created only in the poller and updater;
- code cannot modify the process environment.
- Draw the Classic, Compact Fluent Quad and Classic Vertical built-in themes from single layers with light-mode colours instead of duplicate layers gated on `system.dark` (163 to 124, 158 to 118 and 133 to 114 layers), with identical rendering in both appearances. Custom themes that keep separate dark and light layers render as before.
- Run the dependency security checks as part of `CI passed` on pull requests and pushes to `main`, and once in the tagged Release workflow through CI.

### Fixed

- Update the transitive `url` dependency from 2.5.8 to 2.5.9, with `form_urlencoded` from 1.2.2 to 1.2.3, to resolve RUSTSEC-2026-0592 found by the release dependency checks.
- Update the transitive `cookie` dependency from 0.18.2 to 0.18.3 to resolve RUSTSEC-2026-0594 found by the release dependency checks.
- Translate the Cursor and OpenCode Go provider setting descriptions, which showed in English in every other language.
- Reject a theme layer background with an invalid value, such as an unknown image `fit`, instead of silently replacing it with a default colour.
- Validate a surface's `placement.offset_x_expression` and `placement.offset_y_expression` when a theme loads, so a broken offset is reported instead of silently falling back to `offset_x` or `offset_y`.

## [2.25.3] - 2026-11-21

### Changed
Expand Down Expand Up @@ -1717,3 +1756,4 @@ changes grouped into Added, Changed, Fixed, and Removed where applicable.
[2.25.1]: https://github.com/CodeZeno/Claude-Code-Usage-Monitor/compare/v2.25.0...v2.25.1
[2.25.2]: https://github.com/CodeZeno/Claude-Code-Usage-Monitor/compare/v2.25.1...v2.25.2
[2.25.3]: https://github.com/CodeZeno/Claude-Code-Usage-Monitor/compare/v2.25.2...v2.25.3
[Unreleased]: https://github.com/CodeZeno/Claude-Code-Usage-Monitor/compare/v2.25.3...HEAD
Loading