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
35 changes: 35 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Audit
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: audit-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: stable
jobs:
audit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Setup just
uses: extractions/setup-just@v2
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Run cargo audit
run: just audit
32 changes: 32 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Clippy
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: clippy-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: stable
jobs:
clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain (stable + clippy)
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Setup just
uses: extractions/setup-just@v2
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2
- name: Run clippy
run: just clippy
30 changes: 30 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Format
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: fmt-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: stable
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain (stable + rustfmt)
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- name: Setup just
uses: extractions/setup-just@v2
- name: Check formatting
run: just fmt-check
37 changes: 37 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: rust-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: stable
jobs:
check-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Setup just
uses: extractions/setup-just@v2
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2
- name: Install cargo-deny
run: cargo install cargo-deny --locked
- name: Deny (licenses, advisories, bans)
run: just deny
- name: Check (platform-independent)
run: just check
- name: Test (platform-independent)
run: just test
51 changes: 51 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Code of Conduct

## Our Pledge

We, the rustyfarians and all contributors, pledge to make participation in this project
a welcoming experience for everyone — regardless of age, body size, visible or invisible
disability, ethnicity, sex characteristics, gender identity and expression, level of
experience, education, socioeconomic status, nationality, personal appearance, race,
caste, colour, religion, or sexual identity and orientation.

We pledge to act in ways that contribute to an open, welcoming, diverse, inclusive,
and healthy community.

## Our Standards

**Behaviour that contributes to a positive environment:**

- Being respectful and friendly in all interactions
- Assuming good intent — we are all here to build something cool together
- Giving and receiving constructive feedback graciously
- Accepting responsibility for mistakes and learning from them
- Keeping discussions technical and on-topic

**Behaviour that is not acceptable:**

- Harassment, insults, or personal attacks of any kind
- Sexualised language or imagery, or unwelcome sexual attention
- Trolling or deliberate intimidation
- Publishing others' private information without permission
- Any other conduct that would reasonably be considered unprofessional

## Enforcement

Instances of unacceptable behaviour may be reported to the project maintainers via
a GitHub issue or by contacting the datenkollektiv organisation directly.

All reports will be handled with discretion.
Maintainers are obligated to respect the privacy and safety of anyone who reports an incident.

Maintainers who do not follow or enforce this Code of Conduct in good faith may face
temporary or permanent consequences as determined by other members of the project leadership.

## Scope

This Code of Conduct applies in all project spaces — GitHub issues, pull requests,
discussions, and any other venue where the project is represented.

## Attribution

This Code of Conduct is adapted from the
[Contributor Covenant, version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
101 changes: 101 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Contributing to rustyfarian-power

Thanks for your interest in contributing!
This project is maintained by the *rustyfarians* (Rust enthusiasts around datenkollektiv)
and is part of the [rustyfarian family](README.md#rustyfarian-family) of embedded-Rust crates
for battery-powered ESP32 field deployments.

All kinds of contributions are welcome — code, documentation, bug reports, ideas, or small cleanups.

---

## 🧰 Prerequisites

- **[`just`](https://github.com/casey/just)** — the task runner behind every build/test/lint command; install it before running any `just …` recipe.
- **Rust + the `esp` toolchain** — install via [`espup`](https://github.com/esp-rs/espup) (or `just setup-toolchain`); the channel is pinned in `rust-toolchain.toml`. Host-only checks run on stable, but building for the device needs the Espressif Xtensa toolchain.
- **ESP-IDF tooling** — only required for device tasks (`just check-all`, `just build-example`, `just flash`); it is fetched automatically on the first ESP-IDF build. Pure host-side work (`just verify`) needs none of it.
- Optional: `cargo-deny` and `cargo-audit` (for `just deny` / `just audit`) — CI installs these automatically.

Run `just doctor` for a one-glance check of your environment.

---

## 🚀 How to Contribute

### 1. Fork & Branch
- Fork the repository
- Create a feature branch from `main`
- Keep changes focused and small where possible

### 2. Make Your Changes
- Read [AGENTS.md](AGENTS.md) first — it is the cross-tool operating guide (project overview, architecture, conventions)
- Follow existing code style; prefer clarity over cleverness
- Keep the hardware-independent core (`config.rs`, `sleep.rs`, `charging.rs`) free of ESP-IDF dependencies so it stays host-testable
- Avoid breaking existing behavior unless discussed

### 3. Validate Before Opening a PR
Run the non-modifying verification suite — this **mirrors the host-side CI gates** (the `fmt`, `clippy`, and `rust` workflows):

```shell
just verify
```

For changes to ESP-IDF-gated code (`esp_*.rs`) or examples, also validate the cross-compile **locally** (these are *not* run in CI, which has no ESP toolchain):

```shell
just check-all
just build-example <example>
```

`just audit` (and the scheduled Audit workflow) scans dependencies for security advisories. Note it generates a `Cargo.lock` if one isn't present — the lockfile is gitignored for this library, so this is expected and not something to commit.

### 4. Open a Pull Request
- Describe **what** you changed and **why**
- If the change is visible or behavioral, mention it explicitly
- If it's cleanup-only, say so clearly

---

## 🧹 "Boy Scout Pass" (Cleanup Changes)

We sometimes refer to a **"Boy Scout pass"**, inspired by the Boy Scout Rule:

> *Always leave the code a little cleaner than you found it.*

A Boy Scout pass means small cleanups, improved readability, or structure — with no intentional
behavior changes. When in doubt, label your change `cleanup`, `refactor`, or
`boy scout pass (no behavior change)`.

---

## 🧪 Testing

- Host-side logic lives behind traits and is unit-tested without hardware — add tests for new core logic
- If your change affects behavior, mention what you tested in the PR (and, for hardware changes, which board you flashed)
- Cleanup-only changes need only a quick sanity check

---

## 📝 Commit Messages

We prefer simple, descriptive commit messages. No need to be overly formal — just be clear.

---

## 💬 Communication & Conduct

- Be respectful and friendly; assume good intent
- Keep discussions technical and constructive
- See our [Code of Conduct](CODE_OF_CONDUCT.md)

This is an open-source hobby project — let's keep it enjoyable.

---

## ❓ Questions or Ideas?

- Open an issue
- Start a discussion
- Or just submit a PR and see what happens 🙂

Thanks for helping make `rustyfarian-power` better!
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = ["crates/*"]
[workspace.package]
authors = ["datenkollektiv"]
edition = "2021"
rust-version = "1.88"
license = "MIT OR Apache-2.0"
repository = "https://github.com/datenkollektiv/rustyfarian-power"

Expand Down
Loading
Loading