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
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Formatting-only commits, skipped by `git blame` (GitHub picks this file up;
# locally: `git config blame.ignoreRevsFile .git-blame-ignore-revs`).

# Adopt the operators' rustfmt config and reformat
dbfac6eacec02fe54ffd379b8e91b3827fcf3faf
53 changes: 27 additions & 26 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
#
# - a tag `vX.Y.Z` publishes `X.Y.Z` (the tag must match the Cargo.toml version)
# - a push to `main` publishes `0.0.0-dev` (floating) and `0.0.0-dev-<sha>`
# - a pull request only runs the checks and a test build (nothing is pushed)
# - a pull request only runs a test build (nothing is pushed) and cargo-udeps;
# the other checks are in pr_prek.yaml
#
# Repository settings needed:
# - variable `REGISTRY_NAMESPACE`: the Harbor project on oci.stackable.tech
# - secret `HARBOR_ROBOT_SECRET`: the secret of the robot account
# - secret `HARBOR_ROBOT_STACKABLE_GITHUB_ACTION_BUILD_SECRET`: the secret of the robot account
# `robot$<REGISTRY_NAMESPACE>+github-action-build`
name: Build

Expand All @@ -26,46 +27,34 @@ concurrency:
env:
REGISTRY: oci.stackable.tech
IMAGE_NAME: easybill-xero
# Keep in sync with the builder image in the Dockerfile.
RUST_TOOLCHAIN: 1.99.1

jobs:
check:
name: Check
cargo-udeps:
name: Run cargo-udeps
runs-on: ubuntu-latest
permissions:
contents: read
env:
# cargo-udeps needs nightly features; this unlocks them on the stable
# toolchain from rust-toolchain.toml, as the operators do.
RUSTC_BOOTSTRAP: 1
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: clippy, rustfmt

- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
key: udeps

- run: cargo fmt --all --check
- run: cargo clippy --workspace --all-targets --locked -- -D warnings
- run: cargo test --workspace --locked
- uses: stackabletech/cargo-install-action@e3e2dcf8d0f0e5bdbc619bf6ee7560dd68152d3c
with:
crate: cargo-udeps

- name: Check that the tag matches the Cargo.toml version
if: startsWith(github.ref, 'refs/tags/v')
env:
TAG: ${{ github.ref_name }}
run: |
version="$(cargo metadata --no-deps --format-version 1 --locked \
| jq -r '.packages[] | select(.name == "easybill-xero") | .version')"
if [ "${TAG#v}" != "$version" ]; then
echo "Tag $TAG does not match the Cargo.toml version $version" >&2
exit 1
fi
- run: cargo udeps --workspace --all-targets --locked

build:
name: Build/Publish Image
needs: check
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -78,6 +67,18 @@ jobs:
with:
persist-credentials: false

- name: Check that the tag matches the Cargo.toml version
if: startsWith(github.ref, 'refs/tags/v')
env:
TAG: ${{ github.ref_name }}
run: |
version="$(cargo metadata --no-deps --format-version 1 --locked \
| jq -r '.packages[] | select(.name == "easybill-xero") | .version')"
if [ "${TAG#v}" != "$version" ]; then
echo "Tag $TAG does not match the Cargo.toml version $version" >&2
exit 1
fi

- name: Check repository settings
if: env.PUBLISH == 'true'
env:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/general_daily_security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# Checks the dependencies against the RustSec advisory database every day,
# so new advisories show up even when no pull request touches Cargo.lock.
# Taken from stackabletech/operator-templating.
name: Daily Security Audit

on:
schedule:
- cron: "15 4 * * *"
workflow_dispatch:

permissions: {}

jobs:
audit:
runs-on: ubuntu-latest
permissions:
contents: read
# rustsec/audit-check publishes its results as a Check run, which requires this scope
checks: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0
# Build against stable because cargo-audit sometimes depends on things
# that require a newer Rust version than our pinned toolchain. This does
# not influence the result, so it should be safe.
env:
RUSTUP_TOOLCHAIN: stable
with:
token: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/pr_prek.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# Runs the hooks in .pre-commit-config.yaml on the files a pull request
# changes (lints, cargo-deny, rustfmt, clippy, tests). Modelled after
# stackabletech/operator-templating.
name: prek

on:
pull_request:

permissions: {}

env:
CARGO_TERM_COLOR: always
# Keep in sync with the cargo-rustfmt hook in .pre-commit-config.yaml. The
# stable toolchain comes from rust-toolchain.toml.
RUST_NIGHTLY_TOOLCHAIN_VERSION: "nightly-2026-11-02"
HADOLINT_VERSION: "v2.15.1"

jobs:
prek:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- uses: stackabletech/actions/run-prek@d5c85b3cef351617f19de803812b42b839e20168 # v0.18.4
with:
rust: ${{ env.RUST_NIGHTLY_TOOLCHAIN_VERSION }}
hadolint: ${{ env.HADOLINT_VERSION }}
12 changes: 12 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Taken from stackabletech/operator-templating, keep in sync.
---
ignored:
# Warning: Use the -y switch to avoid manual input dnf install -y <package>
# https://github.com/hadolint/hadolint/wiki/DL3038
# Reason: We set `assumeyes=True` in dnf.conf in our base image
- DL3038

# Warning: Specify version with dnf install -y <package>-<version>
# https://github.com/hadolint/hadolint/wiki/DL3041
# Reason: It's good advice, but we're not set up to pin versions just yet
- DL3041
28 changes: 28 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Taken from stackabletech/operator-templating, keep in sync.
---
# All defaults or options can be checked here:
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml

# Default state for all rules
default: true

# MD013/line-length - Line length
MD013:
# Number of characters
line_length: 9999
# Number of characters for headings
heading_line_length: 9999
# Number of characters for code blocks
code_block_line_length: 9999

# MD033/no-inline-html
MD033:
allowed_elements: [h1, img, p]

# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
MD024:
# Only check sibling headings
siblings_only: true

# MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading
MD041: false # Github issues and PRs already have titles, and H1 is enormous in the description box.
87 changes: 87 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Modelled after stackabletech/operator-templating; the hook versions are kept
# in sync with it. Hooks for Helm, Nix, Python and README rendering are left
# out, as this repo has none of those.
---
repos:
- repo: https://github.com/crate-ci/typos
rev: 7f9d0819ca1c008ade73f4b41fa9d258d48f605b # v1.51.1
hooks:
- id: typos
# Drop the upstream default `--write-changes` so the hook only
# reports failures instead of writing changes.
args: ["--force-exclude"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # 6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: detect-aws-credentials
args: ["--allow-missing-credentials"]
- id: detect-private-key

- repo: https://github.com/EmbarkStudios/cargo-deny
rev: 1c9ca2b643ee15722178c1350501aabb024dd6f3 # 0.19.9
hooks:
- id: cargo-deny
args: ["--all-features", "check", "advisories", "bans", "licenses", "sources"]

- repo: https://github.com/adrienverge/yamllint
rev: 79a6b2b1392eaf49cdd32ac4f14be1a809bbd8f7 # 1.37.1
hooks:
- id: yamllint
args: ["--strict"]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: cbcdc463be5464e25e3e955a511599a67b9b987f # 0.50.0
hooks:
- id: markdownlint
types: [text]
files: \.md$

- repo: https://github.com/rhysd/actionlint
rev: 914e7df21a07ef503a81201c76d2b11c789d3fca # 1.7.12
hooks:
- id: actionlint

- repo: https://github.com/hadolint/hadolint
rev: 2eece55955ced00200be9729e9728cb7dacca505 # 2.15.1
hooks:
- id: hadolint

- repo: local
hooks:
- id: cargo-doc
name: cargo-doc
language: system
env:
RUSTDOCFLAGS: "-D warnings"
entry: cargo doc --workspace --no-deps --document-private-items --locked
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test
name: cargo-test
language: system
entry: cargo test --workspace --locked
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-rustfmt
name: cargo-rustfmt
language: system
# Keep the nightly version in sync with .github/workflows/pr_prek.yaml.
entry: cargo +nightly-2026-11-02 fmt --all -- --check
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$

- id: cargo-clippy
name: cargo-clippy
language: system
entry: cargo clippy --workspace --all-targets --locked -- -D warnings
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)
17 changes: 17 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Taken from stackabletech/operator-templating (without the Helm ignore),
# keep in sync.
---
extends: default

rules:
line-length: disable
truthy:
check-keys: false
comments:
min-spaces-from-content: 1 # Needed due to https://github.com/adrienverge/yamllint/issues/443
indentation:
indent-sequences: consistent
comments-indentation: disable # This is generally useless and interferes with commented example values
braces:
max-spaces-inside: 1
max-spaces-inside-empty: 0
32 changes: 24 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,24 @@ grafana/ dashboard for the monitoring snapshot

## Before you finish a change

CI runs exactly these, all must pass:
CI runs the hooks in `.pre-commit-config.yaml` (through prek) and
`cargo-udeps`; all must pass. The Rust part of it:

```sh
cargo fmt --all --check
cargo +nightly-2026-11-02 fmt --all --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items --locked
cargo deny --all-features check advisories bans licenses sources
RUSTC_BOOTSTRAP=1 cargo udeps --workspace --all-targets --locked
```

`prek run --all-files` runs everything except `cargo-udeps`, including the
YAML, Markdown, Dockerfile and spelling lints. Formatting needs the nightly
toolchain (unstable options in `rustfmt.toml`). `deny.toml`, `rustfmt.toml`
and the lint configs are copied from stackabletech/operator-templating; keep
them in sync rather than editing them here.

Update `README.md` when behaviour, options, environment variables or metrics
change.

Expand Down Expand Up @@ -109,7 +119,8 @@ the README table and the dashboard legend panel.
This repo follows the Stackable Rust style guide; the points that matter
most, and where this repo differs:

**Errors**
### Errors

- `snafu` only (no `thiserror`, no `anyhow`). One `Error` enum per module,
explicit `.context(…Snafu)` at every call site; never
`#[snafu(context(false))]`.
Expand All @@ -121,19 +132,22 @@ most, and where this repo differs:
- Use `crate::sync::error_chain` to log an error with its full source chain
on one line.

**Panics**
### Panics

- No `unwrap()`, also not in tests. `unwrap_or*` are fine.
- `expect("…")` only where failure is impossible; the message states the
invariant (`must` in production code, `should` in tests).

**Types and signatures**
### Types and signatures

- No sentinel values (empty string, `-1`) for "nothing": use `Option`.
- Take owned values when you need ownership, instead of cloning a reference
inside.
- `Option` variables carry no `maybe_` / `opt_` prefix. Use full words for
names, except in closures.

**Formatting and docs**
### Formatting and docs

- `format!`/`println!` with three or more substitutions use named arguments.
Some older code still uses positional ones; fix them when you touch it.
- Every item gets a doc comment (summary sentence ending in a full stop);
Expand All @@ -143,7 +157,8 @@ most, and where this repo differs:
- Enum variants and struct fields with doc comments or attributes are
separated by blank lines.

**Tests**
### Tests

- Unit tests live in a `#[cfg(test)] mod tests` in the same file.
- Names describe what is verified, without a `test_` prefix.
- Prefer `assert_eq!` over `assert!`. For several inputs the guide asks for
Expand All @@ -152,7 +167,8 @@ most, and where this repo differs:
- No network in tests. Keep mapping and classification logic pure so it can
be tested without the APIs (see `snapshot` in `src/sync/report.rs`).

**Dependencies**
### Dependencies

- Check the licence before adding a crate: it must be compatible with
Apache-2.0, the project's licence.
- Keep the binary statically linkable: avoid crates with C dependencies, and
Expand Down
Loading