Skip to content

Commit cd04762

Browse files
authored
ci: add GitHub Actions workflows (#30)
* ci: add GitHub Actions workflows - Add build.yml: Rust build/test on Linux, macOS, Windows - Rustfmt check - Clippy linting (all platforms) - Tests (all platforms) - Release builds (4 targets) - Add commit-lint.yml: PR title and commit message validation - Add contributors.yml: Uses reusable workflow from .github - Add .commitlintrc.yml: Conventional commits configuration * ci: add preview-changelog workflow
1 parent 3880af6 commit cd04762

File tree

5 files changed

+338
-0
lines changed

5 files changed

+338
-0
lines changed

.commitlintrc.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Commitlint configuration for conventional commits
2+
# Based on: https://www.conventionalcommits.org/
3+
4+
extends:
5+
- '@commitlint/config-conventional'
6+
7+
rules:
8+
# Type enum - allowed commit types
9+
type-enum:
10+
- 2 # Level: error
11+
- always
12+
- # Allowed types:
13+
- feat # New feature
14+
- fix # Bug fix
15+
- docs # Documentation only changes
16+
- style # Code style changes (formatting, missing semi-colons, etc)
17+
- refactor # Code refactoring (neither fixes a bug nor adds a feature)
18+
- perf # Performance improvements
19+
- test # Adding or updating tests
20+
- build # Changes to build system or dependencies
21+
- ci # CI/CD configuration changes
22+
- chore # Other changes that don't modify src or test files
23+
- revert # Revert a previous commit
24+
25+
# Type case should be lowercase
26+
type-case:
27+
- 2
28+
- always
29+
- lower-case
30+
31+
# Type must not be empty
32+
type-empty:
33+
- 2
34+
- never
35+
36+
# Scope case should be lowercase
37+
scope-case:
38+
- 2
39+
- always
40+
- lower-case
41+
42+
# Subject must not be empty
43+
subject-empty:
44+
- 2
45+
- never
46+
47+
# Subject must not end with a period
48+
subject-full-stop:
49+
- 2
50+
- never
51+
- '.'
52+
53+
# Disable subject-case to allow uppercase abbreviations (PR, API, CLI, etc.)
54+
subject-case:
55+
- 0
56+
57+
# Header (first line) max length
58+
header-max-length:
59+
- 2
60+
- always
61+
- 72
62+
63+
# Body should have a blank line before it
64+
body-leading-blank:
65+
- 1 # Warning level
66+
- always
67+
68+
# Footer should have a blank line before it
69+
footer-leading-blank:
70+
- 1 # Warning level
71+
- always
72+
73+
# Body max line length
74+
body-max-line-length:
75+
- 1 # Warning level
76+
- always
77+
- 100
78+
79+
# Help URL shown in error messages
80+
helpUrl: 'https://www.conventionalcommits.org/'

.github/workflows/build.yml

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: Build & Test
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
paths-ignore:
8+
- '**.md'
9+
- '.github/ISSUE_TEMPLATE/**'
10+
- '.github/workflows/contributors.yml'
11+
- '.idea/**'
12+
- '.claude/**'
13+
- '.gitignore'
14+
- '.commitlintrc.yml'
15+
- 'LICENSE'
16+
pull_request:
17+
branches: [ main ]
18+
paths-ignore:
19+
- '**.md'
20+
- '.github/ISSUE_TEMPLATE/**'
21+
- '.github/workflows/contributors.yml'
22+
- '.idea/**'
23+
- '.claude/**'
24+
- '.gitignore'
25+
- '.commitlintrc.yml'
26+
- 'LICENSE'
27+
28+
permissions:
29+
contents: read
30+
31+
env:
32+
CARGO_TERM_COLOR: always
33+
34+
jobs:
35+
fmt:
36+
name: Rustfmt
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Install Rust toolchain
43+
uses: dtolnay/rust-toolchain@stable
44+
with:
45+
components: rustfmt
46+
47+
- name: Check formatting
48+
run: cargo fmt --all -- --check
49+
50+
clippy:
51+
name: Clippy (${{ matrix.os }})
52+
runs-on: ${{ matrix.os }}
53+
strategy:
54+
matrix:
55+
os: [ubuntu-latest, macos-latest, windows-latest]
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
60+
- name: Install Rust toolchain
61+
uses: dtolnay/rust-toolchain@stable
62+
with:
63+
components: clippy
64+
65+
- name: Cache cargo registry
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
~/.cargo/registry
70+
~/.cargo/git
71+
target
72+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
73+
restore-keys: |
74+
${{ runner.os }}-cargo-
75+
76+
- name: Run Clippy
77+
run: cargo clippy --all-targets --all-features -- -D warnings
78+
79+
test:
80+
name: Test (${{ matrix.os }})
81+
runs-on: ${{ matrix.os }}
82+
strategy:
83+
matrix:
84+
os: [ubuntu-latest, macos-latest, windows-latest]
85+
steps:
86+
- name: Checkout code
87+
uses: actions/checkout@v4
88+
89+
- name: Install Rust toolchain
90+
uses: dtolnay/rust-toolchain@stable
91+
92+
- name: Cache cargo registry
93+
uses: actions/cache@v4
94+
with:
95+
path: |
96+
~/.cargo/registry
97+
~/.cargo/git
98+
target
99+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
100+
restore-keys: |
101+
${{ runner.os }}-cargo-
102+
103+
- name: Run tests
104+
run: cargo test --verbose
105+
106+
- name: Generate test summary
107+
if: always()
108+
shell: bash
109+
run: |
110+
echo "## Test Results - ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY
111+
echo "" >> $GITHUB_STEP_SUMMARY
112+
echo "✅ Tests completed" >> $GITHUB_STEP_SUMMARY
113+
114+
build:
115+
name: Build ${{ matrix.platform }}
116+
needs: [fmt, clippy, test]
117+
runs-on: ${{ matrix.os }}
118+
strategy:
119+
matrix:
120+
include:
121+
- os: ubuntu-latest
122+
target: x86_64-unknown-linux-gnu
123+
platform: linux-amd64
124+
binary: rnr
125+
126+
- os: macos-latest
127+
target: x86_64-apple-darwin
128+
platform: macos-amd64
129+
binary: rnr
130+
131+
- os: macos-latest
132+
target: aarch64-apple-darwin
133+
platform: macos-arm64
134+
binary: rnr
135+
136+
- os: windows-latest
137+
target: x86_64-pc-windows-msvc
138+
platform: windows-amd64
139+
binary: rnr.exe
140+
141+
steps:
142+
- name: Checkout code
143+
uses: actions/checkout@v4
144+
145+
- name: Install Rust toolchain
146+
uses: dtolnay/rust-toolchain@stable
147+
with:
148+
targets: ${{ matrix.target }}
149+
150+
- name: Cache cargo registry
151+
uses: actions/cache@v4
152+
with:
153+
path: |
154+
~/.cargo/registry
155+
~/.cargo/git
156+
target
157+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
158+
restore-keys: |
159+
${{ runner.os }}-${{ matrix.target }}-cargo-
160+
161+
- name: Build release binary
162+
run: cargo build --release --target ${{ matrix.target }}
163+
164+
- name: Verify build
165+
if: matrix.target != 'aarch64-apple-darwin'
166+
shell: bash
167+
run: |
168+
./target/${{ matrix.target }}/release/${{ matrix.binary }} --version
169+
./target/${{ matrix.target }}/release/${{ matrix.binary }} --help
170+
171+
- name: Upload build artifact
172+
uses: actions/upload-artifact@v4
173+
with:
174+
name: rnr-${{ matrix.platform }}
175+
path: target/${{ matrix.target }}/release/${{ matrix.binary }}
176+
retention-days: 7

.github/workflows/commit-lint.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Lint Commit Messages
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
lint-pr-title:
13+
name: Lint PR Title
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
24+
- name: Install commitlint
25+
run: |
26+
npm install --save-dev @commitlint/[email protected] @commitlint/[email protected]
27+
28+
- name: Validate PR title
29+
env:
30+
PR_TITLE: ${{ github.event.pull_request.title }}
31+
run: |
32+
echo "Validating PR title: $PR_TITLE"
33+
echo "$PR_TITLE" | npx commitlint --verbose
34+
35+
commitlint:
36+
name: Lint Commit Messages
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0 # Fetch all history for all branches and tags
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: '20'
48+
49+
- name: Install commitlint
50+
run: |
51+
npm install --save-dev @commitlint/[email protected] @commitlint/[email protected]
52+
53+
- name: Validate PR commits
54+
run: |
55+
# Get the base branch (usually main)
56+
BASE_SHA=$(git merge-base origin/${{ github.base_ref }} HEAD)
57+
58+
# Lint all commits in the PR
59+
npx commitlint --from $BASE_SHA --to HEAD --verbose

.github/workflows/contributors.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Update Contributors
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run daily at midnight UTC
6+
workflow_dispatch: # Allow manual trigger
7+
8+
jobs:
9+
contributors:
10+
uses: CodingWithCalvin/.github/.github/workflows/contributors.yml@main
11+
secrets: inherit
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Preview Changelog
2+
3+
run-name: Preview release notes for next release
4+
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
preview:
10+
name: Preview
11+
uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main
12+
secrets: inherit

0 commit comments

Comments
 (0)