Skip to content

Commit ff0590d

Browse files
committed
First beta
1 parent 2f29479 commit ff0590d

22 files changed

+810
-589
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
charset = utf-8
6+
indent_style = space
7+
trim_trailing_whitespace = true
8+
indent_size = 2
9+
10+
[*.rs]
11+
indent_size = 4
12+
13+
[*.{hledger,journal,j}]
14+
indent_size = 4

.github/workflows/ci.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- v*
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
qa:
14+
name: QA
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Setup Rust
19+
uses: hecrj/setup-rust-action@v2
20+
with:
21+
rust-version: stable
22+
profile: minimal
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
- name: Install dependencies
28+
run: |
29+
pip install --upgrade pip
30+
pip install pre-commit
31+
- name: Cache dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
~/.cargo/registry
36+
~/.cargo/git
37+
target
38+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }}
39+
- name: Lint
40+
uses: nick-fields/retry@v3
41+
with:
42+
timeout_minutes: 25
43+
max_attempts: 3
44+
retry_wait_seconds: 15
45+
warning_on_retry: false
46+
command: pre-commit run --all-files --show-diff-on-failure
47+
48+
build:
49+
name: Build
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Setup Rust
53+
uses: hecrj/setup-rust-action@v2
54+
with:
55+
rust-version: stable
56+
profile: minimal
57+
- name: Build
58+
run: cargo build --release --workspace --all-features
59+
60+
unit-tests:
61+
name: Unit tests
62+
runs-on: ${{ matrix.runs-on }}
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
runs-on:
67+
- ubuntu-latest
68+
- macos-latest
69+
- windows-latest
70+
steps:
71+
- name: Setup Rust
72+
uses: hecrj/setup-rust-action@v2
73+
with:
74+
rust-version: stable
75+
profile: minimal
76+
- name: Cache dependencies
77+
uses: actions/cache@v4
78+
with:
79+
path: |
80+
~/.cargo/registry
81+
~/.cargo/git
82+
target
83+
key: ${{ runner.os }}-cargo-unit-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }}
84+
- name: Run unit tests
85+
run: cargo test
86+
87+
test-release:
88+
needs:
89+
- qa
90+
- unit-tests
91+
- build
92+
if: |
93+
'${{ github.event.pull_request.user.login }}' == 'mondeja' ||
94+
startsWith(github.ref, 'refs/tags/') ||
95+
github.ref == 'refs/heads/master'
96+
name: Test release
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v4
100+
- name: Setup Rust
101+
uses: hecrj/setup-rust-action@v2
102+
- name: Publish
103+
run: |
104+
cargo login ${{ secrets.CRATES_TOKEN }}
105+
cargo publish -v --dry-run
106+
107+
release:
108+
if: startsWith(github.ref, 'refs/tags/')
109+
name: Release heldger-fmt
110+
needs:
111+
- test-release
112+
runs-on: ubuntu-latest
113+
steps:
114+
- uses: actions/checkout@v4
115+
- name: Setup Rust
116+
uses: hecrj/setup-rust-action@v2
117+
- name: Publish
118+
run: |
119+
cargo login ${{ secrets.CRATES_TOKEN }}
120+
cargo publish -v
121+
122+
create-release:
123+
if: startsWith(github.ref, 'refs/tags/')
124+
name: Create release
125+
needs:
126+
- release
127+
permissions:
128+
contents: write
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/checkout@v4
132+
- name: Get tag metadata
133+
id: tag
134+
run: |
135+
TAG_TITLE=${GITHUB_REF#refs/*/}
136+
echo "title=$TAG_TITLE" >> $GITHUB_OUTPUT
137+
- name: Create release
138+
uses: softprops/action-gh-release@v2
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
with:
142+
name: ${{ steps.tag.outputs.title }}
143+
tag_name: ${{ steps.tag.outputs.title }}
144+
body: |
145+
See [CHANGELOG](https://github.com/mondeja/hledger-fmt/blob/master/CHANGELOG.md).
146+
draft: false
147+
prerelease: false
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: pre-commit autoupdate
2+
3+
permissions:
4+
pull-requests: write
5+
contents: write
6+
7+
on:
8+
workflow_dispatch:
9+
schedule:
10+
- cron: 0 3 1 1/6 *
11+
12+
jobs:
13+
autoupdate:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
- name: Install pre-commit
22+
run: pip install pre-commit
23+
- name: Run pre-commit autoupdate
24+
run: |
25+
pre-commit autoupdate
26+
pre-commit autoupdate --config end2end/.pre-commit-config.yaml
27+
- name: Open pull request
28+
uses: peter-evans/create-pull-request@v5
29+
with:
30+
branch: pre-commit-autoupdate
31+
title: Upgrade pre-commit hooks revisions
32+
commit-message: Upgrade pre-commit hooks revisions
33+
body: "Upgrades revisions of pre-commit hooks tools to latest versions :hammer_and_wrench:"
34+
labels: dependencies
35+
delete-branch: true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Update copyright years in license file
2+
3+
permissions:
4+
pull-requests: write
5+
contents: write
6+
7+
on:
8+
schedule:
9+
- cron: 0 3 2 1 *
10+
workflow_dispatch:
11+
12+
jobs:
13+
action-update-license-year:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- uses: FantasticFiasco/action-update-license-year@v3
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
.prettier-cache

.markdown-link-check.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^https://crates\\.io"
5+
}
6+
]
7+
}

.pre-commit-config.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
repos:
2+
- repo: https://github.com/rbubley/mirrors-prettier
3+
rev: v3.3.3
4+
hooks:
5+
- id: prettier
6+
args:
7+
- --cache
8+
- --cache-location=.prettier-cache
9+
- --ignore-path=.gitignore
10+
- repo: meta
11+
hooks:
12+
- id: check-hooks-apply
13+
name: check-hooks-apply
14+
- id: check-useless-excludes
15+
name: check-useless-excludes
16+
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
rev: v4.6.0
18+
hooks:
19+
- id: trailing-whitespace
20+
name: trailing-whitespace
21+
- id: end-of-file-fixer
22+
name: end-of-file-fixer
23+
- repo: https://github.com/DavidAnson/markdownlint-cli2
24+
rev: v0.13.0
25+
hooks:
26+
- id: markdownlint-cli2
27+
exclude: ^LICENSE$
28+
- repo: https://github.com/doublify/pre-commit-rust
29+
rev: v1.0
30+
hooks:
31+
- id: fmt
32+
- id: clippy
33+
alias: clippy-no-features
34+
name: clippy-no-features
35+
args:
36+
[
37+
--exclude=leptos-fluent-ssr-hydrate-axum-example,
38+
--workspace,
39+
--,
40+
-D,
41+
warnings,
42+
-D,
43+
clippy::perf,
44+
-D,
45+
clippy::print_stdout,
46+
-D,
47+
clippy::explicit_iter_loop,
48+
-D,
49+
clippy::uninlined_format_args,
50+
-D,
51+
clippy::semicolon_if_nothing_returned,
52+
]
53+
- repo: https://github.com/mondeja/rust-pc-hooks
54+
rev: v1.2.0
55+
hooks:
56+
- id: cargo-machete
57+
args:
58+
- --skip-target-dir
59+
- repo: https://github.com/tcort/markdown-link-check
60+
rev: v3.12.2
61+
hooks:
62+
- id: markdown-link-check
63+
name: markdown-link-check
64+
files: ^README\.md$
65+
args:
66+
- --config
67+
- .markdown-link-check.json

.pre-commit-hooks.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
- id: hledger-fmt
2+
name: hledger-fmt
3+
alias: hledger-fmt
4+
description: An opinionated hledger's journal files formatter.
5+
language: rust
6+
entry: hledger-fmt --fix
7+
files: \.(hledger)|(journal)|(j)$
8+
args: []
9+
pass_filenames: true
10+
additional_dependencies: []
11+
minimum_pre_commit_version: "2.21.0"
12+
- id: hledger-fmt-check
13+
name: hledger-fmt
14+
alias: hledger-fmt
15+
description: An opinionated hledger's journal files formatter.
16+
language: rust
17+
entry: hledger-fmt
18+
files: \.(hledger)|(journal)|(j)$
19+
args: []
20+
pass_filenames: true
21+
additional_dependencies: []
22+
minimum_pre_commit_version: "2.21.0"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CHANGELOG
2+
3+
## 2024-09-27 - 0.1.0
4+
5+
First beta release

Cargo.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
name = "hledger-fmt"
33
version = "0.1.0"
44
edition = "2021"
5+
description = "An opinionated hledger's journal files formatter."
6+
repository = "https://github.com/mondeja/hledger-fmt"
7+
keywords = [
8+
"hledger",
9+
"journal",
10+
"formatter",
11+
"accounting",
12+
]
513

614
[lib]
715
path = "src/lib.rs"
@@ -13,4 +21,8 @@ name = "hledger-fmt"
1321
clap = { version = "4", features = ["derive"] }
1422
walkdir = "2"
1523
similar = "2"
16-
colored = "2"
24+
colored = { version = "2", optional = true }
25+
26+
[features]
27+
default = ["color"]
28+
color = ["dep:colored"]

0 commit comments

Comments
 (0)