Skip to content

Commit 47ce23e

Browse files
authored
Merge pull request #30 from RAprogramm/new_version
New version
2 parents f913ec3 + 5527cc2 commit 47ce23e

30 files changed

+1922
-200
lines changed

.github/scripts/gen_readme.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Deterministic env for local runs too
5+
export TZ="${TZ:-UTC}"
6+
export LC_ALL="${LC_ALL:-C.UTF-8}"
7+
export NO_COLOR="${NO_COLOR:-1}"
8+
export CARGO_TERM_COLOR="${CARGO_TERM_COLOR:-never}"
9+
export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-0}"
10+
11+
# Allow forcing toolchain via TOOLCHAIN env (e.g. "+1.78.0")
12+
TOOLCHAIN="${TOOLCHAIN:-}"
13+
14+
# If you use cargo-readme, prefer it
15+
if command -v cargo-readme >/dev/null 2>&1; then
16+
cargo ${TOOLCHAIN} readme > README.md
17+
exit 0
18+
fi
19+
20+
# If you have your own generator, call it here instead.
21+
# Examples (uncomment the one you actually use):
22+
# cargo ${TOOLCHAIN} xtask readme
23+
# cargo ${TOOLCHAIN} run -p readme-gen
24+
# cargo ${TOOLCHAIN} run --bin readme_gen
25+
# cargo ${TOOLCHAIN} readme > README.md
26+
27+
# Fallback: no-op to keep CI green if README is static
28+
touch README.md
29+

.github/workflows/reusable-ci.yml

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ jobs:
1111
ci:
1212
runs-on: ubuntu-latest
1313
env:
14-
CARGO_LOCKED: "true" # don't mutate Cargo.lock during CI
14+
CARGO_LOCKED: "true"
1515
CARGO_TERM_COLOR: always
16+
1617
steps:
1718
- uses: actions/checkout@v4
1819
with:
1920
fetch-depth: 0
21+
persist-credentials: true
2022

21-
# Read MSRV (rust-version) from Cargo.toml
2223
- name: Read MSRV from Cargo.toml
2324
id: msrv
2425
shell: bash
@@ -36,14 +37,12 @@ jobs:
3637
echo "msrv=${RV}" >> "$GITHUB_OUTPUT"
3738
echo "Using MSRV: $RV"
3839
39-
# Install MSRV for clippy/tests/package
4040
- name: Install Rust (${{ steps.msrv.outputs.msrv }})
4141
uses: dtolnay/rust-toolchain@v1
4242
with:
4343
toolchain: ${{ steps.msrv.outputs.msrv }}
4444
components: clippy
4545

46-
# Pin nightly for rustfmt because unstable_features = true in .rustfmt.toml
4746
- name: Install nightly rustfmt
4847
uses: dtolnay/rust-toolchain@v1
4948
with:
@@ -55,7 +54,6 @@ jobs:
5554
with:
5655
save-if: ${{ github.ref == 'refs/heads/main' }}
5756

58-
# Ensure Cargo.lock is present when CARGO_LOCKED=1
5957
- name: Verify lockfile is committed
6058
shell: bash
6159
run: |
@@ -65,6 +63,61 @@ jobs:
6563
exit 1
6664
fi
6765
66+
# ---------- README: regenerate early, normalize, drift handling ----------
67+
- name: Regenerate README via build.rs (MSRV, deterministic)
68+
shell: bash
69+
run: |
70+
set -euo pipefail
71+
export TZ=UTC
72+
export LC_ALL=C.UTF-8
73+
export NO_COLOR=1
74+
export CARGO_TERM_COLOR=never
75+
export SOURCE_DATE_EPOCH=0
76+
cargo +${{ steps.msrv.outputs.msrv }} build --workspace -q || cargo +${{ steps.msrv.outputs.msrv }} build -q
77+
78+
- name: Normalize README (ensure trailing newline) — bash only
79+
if: hashFiles('README.md') != ''
80+
shell: bash
81+
run: |
82+
set -euo pipefail
83+
if [ -f README.md ] && [ -s README.md ]; then
84+
last_byte="$(tail -c1 README.md 2>/dev/null || true)"
85+
if [ "$last_byte" != $'\n' ]; then
86+
printf '\n' >> README.md
87+
fi
88+
fi
89+
90+
- name: README drift report (PR)
91+
if: github.event_name == 'pull_request'
92+
shell: bash
93+
run: |
94+
set -euo pipefail
95+
if git diff --quiet -- README.md; then
96+
echo "README is up to date (PR)."
97+
else
98+
echo "::warning::README differs on PR. Tests will use regenerated content."
99+
git --no-pager diff -- README.md || true
100+
fi
101+
102+
- name: README drift autocommit (main)
103+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
104+
shell: bash
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
run: |
108+
set -euo pipefail
109+
if git diff --quiet -- README.md; then
110+
echo "README is up to date (main)."
111+
exit 0
112+
fi
113+
echo "Auto-committing refreshed README on main..."
114+
git config user.name "github-actions[bot]"
115+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
116+
git add README.md
117+
git commit -m "chore(readme): auto-refresh [skip ci]"
118+
git push
119+
# -----------------------------------------------------------------------
120+
68121
- name: Check formatting (nightly rustfmt)
69122
run: cargo +nightly-2025-08-01 fmt --all -- --check
70123

@@ -88,6 +141,17 @@ jobs:
88141
cargo +${{ steps.msrv.outputs.msrv }} test --workspace --no-fail-fast
89142
fi
90143
144+
# На PR возвращаем README к HEAD, чтобы дерево стало чистым перед упаковкой
145+
- name: Restore README to HEAD on PR (keep tree clean)
146+
if: github.event_name == 'pull_request'
147+
shell: bash
148+
run: |
149+
set -euo pipefail
150+
if ! git diff --quiet -- README.md; then
151+
echo "Restoring README.md to HEAD to keep tree clean on PR..."
152+
git restore --worktree --source=HEAD -- README.md || git checkout -- README.md
153+
fi
154+
91155
- name: Ensure tree is clean before package
92156
shell: bash
93157
run: |
@@ -100,3 +164,4 @@ jobs:
100164
101165
- name: Package (dry-run)
102166
run: cargo +${{ steps.msrv.outputs.msrv }} package --locked
167+

.hooks/pre-commit

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,20 @@ cargo test --workspace --all-features
2020
# echo "📦 Validating SQLx prepare..."
2121
# cargo sqlx prepare --check --workspace
2222

23+
# same deterministic env
24+
export TZ=UTC
25+
export LC_ALL=C.UTF-8
26+
export NO_COLOR=1
27+
export CARGO_TERM_COLOR=never
28+
export SOURCE_DATE_EPOCH=0
29+
30+
# Generate
31+
./.github/scripts/gen_readme.sh
32+
33+
# Stage README if changed
34+
if ! git diff --quiet -- README.md; then
35+
git add README.md
36+
fi
37+
2338
echo "✅ All checks passed!"
2439

CHANGELOG.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,35 @@ All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
55

6+
_No changes yet._
7+
8+
## [0.5.0] - 2025-09-23
9+
10+
### Added
11+
- Re-exported `thiserror::Error` as `masterror::Error`, making it possible to
12+
derive domain errors without an extra dependency. The derive supports
13+
`#[from]` conversions, validates `#[error(transparent)]` wrappers, and mirrors
14+
`thiserror`'s ergonomics.
15+
- Added `BrowserConsoleError::context()` for retrieving browser-provided
16+
diagnostics when console logging fails.
17+
18+
### Changed
19+
- README generation now pulls from crate metadata via the build script while
20+
staying inert during `cargo package`, preventing dirty worktrees in release
21+
workflows.
22+
23+
### Documentation
24+
- Documented deriving custom errors via `masterror::Error` and expanded the
25+
browser console section with context-handling guidance.
26+
- Added a release checklist and described the automated README sync process.
27+
28+
### Tests
29+
- Added regression tests covering derive behaviour (including `#[from]` and
30+
transparent wrappers) and ensuring the README stays in sync with its
31+
template.
32+
- Added a guard test that enforces the `AppResult<_>` alias over raw
33+
`Result<_, AppError>` usages within the crate.
34+
635
## [0.4.0] - 2025-09-15
736
### Added
837
- Optional `frontend` feature:
@@ -113,6 +142,8 @@ All notable changes to this project will be documented in this file.
113142
- **MSRV:** 1.89
114143
- **No unsafe:** the crate forbids `unsafe`.
115144

145+
[0.5.0]: https://github.com/RAprogramm/masterror/releases/tag/v0.5.0
146+
[0.4.0]: https://github.com/RAprogramm/masterror/releases/tag/v0.4.0
116147
[0.3.5]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.5
117148
[0.3.4]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.4
118149
[0.3.3]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.3
@@ -121,5 +152,4 @@ All notable changes to this project will be documented in this file.
121152
[0.3.0]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.0
122153
[0.2.1]: https://github.com/RAprogramm/masterror/releases/tag/v0.2.1
123154
[0.2.0]: https://github.com/RAprogramm/masterror/releases/tag/v0.2.0
124-
[0.4.0]: https://github.com/RAprogramm/masterror/releases/tag/v0.4.0
125155

0 commit comments

Comments
 (0)