Skip to content

Commit 7c5e365

Browse files
committed
Added github workflows
1 parent 3291fb8 commit 7c5e365

2 files changed

Lines changed: 200 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
test:
15+
name: Test
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- name: "default features"
22+
features: ""
23+
- name: "rust_decimal"
24+
features: "--features rust_decimal"
25+
- name: "bigdecimal"
26+
features: "--features bigdecimal"
27+
- name: "all features"
28+
features: "--all-features"
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Install Rust toolchain
33+
uses: dtolnay/rust-action@stable
34+
35+
- name: Cache cargo registry and build
36+
uses: actions/cache@v4
37+
with:
38+
path: |
39+
~/.cargo/registry
40+
~/.cargo/git
41+
target
42+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
43+
restore-keys: |
44+
${{ runner.os }}-cargo-
45+
46+
- name: Run tests (${{ matrix.name }})
47+
run: cargo test ${{ matrix.features }} --verbose
48+
49+
clippy:
50+
name: Clippy
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Install Rust toolchain
56+
uses: dtolnay/rust-action@stable
57+
with:
58+
components: clippy
59+
60+
- name: Cache cargo registry and build
61+
uses: actions/cache@v4
62+
with:
63+
path: |
64+
~/.cargo/registry
65+
~/.cargo/git
66+
target
67+
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
68+
restore-keys: |
69+
${{ runner.os }}-cargo-clippy-
70+
71+
- name: Run Clippy (all features)
72+
run: cargo clippy --all-features -- -D warnings
73+
74+
fmt:
75+
name: Format
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- name: Install Rust toolchain
81+
uses: dtolnay/rust-action@stable
82+
with:
83+
components: rustfmt
84+
85+
- name: Check formatting
86+
run: cargo fmt --all -- --check
87+
88+
docs:
89+
name: Documentation
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v4
93+
94+
- name: Install Rust toolchain
95+
uses: dtolnay/rust-action@stable
96+
97+
- name: Cache cargo registry and build
98+
uses: actions/cache@v4
99+
with:
100+
path: |
101+
~/.cargo/registry
102+
~/.cargo/git
103+
target
104+
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
105+
restore-keys: |
106+
${{ runner.os }}-cargo-docs-
107+
108+
- name: Check documentation
109+
env:
110+
RUSTDOCFLAGS: -D warnings
111+
run: cargo doc --all-features --no-deps
112+
113+
msrv:
114+
name: Minimum Supported Rust Version
115+
runs-on: ubuntu-latest
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- name: Install Rust toolchain (MSRV)
120+
uses: dtolnay/rust-action@1.85
121+
122+
- name: Cache cargo registry and build
123+
uses: actions/cache@v4
124+
with:
125+
path: |
126+
~/.cargo/registry
127+
~/.cargo/git
128+
target
129+
key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
130+
restore-keys: |
131+
${{ runner.os }}-cargo-msrv-
132+
133+
- name: Check MSRV compatibility
134+
run: cargo check --all-features

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
validate:
13+
name: Validate Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install Rust toolchain
19+
uses: dtolnay/rust-action@stable
20+
21+
- name: Verify version matches tag
22+
run: |
23+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
24+
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
25+
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
26+
echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
27+
exit 1
28+
fi
29+
echo "Version validated: $TAG_VERSION"
30+
31+
- name: Run tests
32+
run: cargo test --all-features --verbose
33+
34+
- name: Run clippy
35+
run: cargo clippy --all-features -- -D warnings
36+
37+
publish:
38+
name: Publish to crates.io
39+
needs: validate
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install Rust toolchain
45+
uses: dtolnay/rust-action@stable
46+
47+
- name: Publish to crates.io
48+
env:
49+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
50+
run: cargo publish
51+
52+
github-release:
53+
name: Create GitHub Release
54+
needs: publish
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: write
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Create GitHub Release
62+
uses: softprops/action-gh-release@v2
63+
with:
64+
generate_release_notes: true
65+
draft: false
66+
prerelease: ${{ contains(github.ref, '-') }}

0 commit comments

Comments
 (0)