Skip to content

Commit 820ecaf

Browse files
Copilotnpv2k1
andcommitted
Complete Rust template with todo app, SQLite database, TUI, and CI/CD
Co-authored-by: npv2k1 <[email protected]>
1 parent 0dcbbd3 commit 820ecaf

File tree

14 files changed

+3679
-4
lines changed

14 files changed

+3679
-4
lines changed

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install Rust
19+
uses: dtolnay/rust-toolchain@stable
20+
- name: Cache dependencies
21+
uses: actions/cache@v3
22+
with:
23+
path: |
24+
~/.cargo/registry
25+
~/.cargo/git
26+
target
27+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
28+
- name: Run tests
29+
run: cargo test --verbose
30+
31+
clippy:
32+
name: Clippy
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Install Rust
37+
uses: dtolnay/rust-toolchain@stable
38+
with:
39+
components: clippy
40+
- name: Cache dependencies
41+
uses: actions/cache@v3
42+
with:
43+
path: |
44+
~/.cargo/registry
45+
~/.cargo/git
46+
target
47+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
48+
- name: Run clippy
49+
run: cargo clippy -- -D warnings
50+
51+
fmt:
52+
name: Rustfmt
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
- name: Install Rust
57+
uses: dtolnay/rust-toolchain@stable
58+
with:
59+
components: rustfmt
60+
- name: Check formatting
61+
run: cargo fmt --all -- --check
62+
63+
build:
64+
name: Build
65+
runs-on: ${{ matrix.os }}
66+
strategy:
67+
matrix:
68+
os: [ubuntu-latest, windows-latest, macos-latest]
69+
steps:
70+
- uses: actions/checkout@v4
71+
- name: Install Rust
72+
uses: dtolnay/rust-toolchain@stable
73+
- name: Cache dependencies
74+
uses: actions/cache@v3
75+
with:
76+
path: |
77+
~/.cargo/registry
78+
~/.cargo/git
79+
target
80+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
81+
- name: Build
82+
run: cargo build --verbose --release

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
build-and-release:
10+
name: Build and Release
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
target: x86_64-unknown-linux-gnu
17+
artifact_name: template-rust
18+
asset_name: template-rust-linux-x86_64
19+
- os: windows-latest
20+
target: x86_64-pc-windows-msvc
21+
artifact_name: template-rust.exe
22+
asset_name: template-rust-windows-x86_64.exe
23+
- os: macos-latest
24+
target: x86_64-apple-darwin
25+
artifact_name: template-rust
26+
asset_name: template-rust-macos-x86_64
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Install Rust
32+
uses: dtolnay/rust-toolchain@stable
33+
with:
34+
targets: ${{ matrix.target }}
35+
36+
- name: Cache dependencies
37+
uses: actions/cache@v3
38+
with:
39+
path: |
40+
~/.cargo/registry
41+
~/.cargo/git
42+
target
43+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
44+
45+
- name: Build release binary
46+
run: cargo build --release --target ${{ matrix.target }}
47+
48+
- name: Upload release binary
49+
uses: actions/upload-artifact@v3
50+
with:
51+
name: ${{ matrix.asset_name }}
52+
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
53+
54+
release:
55+
name: Create Release
56+
needs: build-and-release
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Download all artifacts
62+
uses: actions/download-artifact@v3
63+
64+
- name: Create Release
65+
uses: softprops/action-gh-release@v1
66+
with:
67+
files: |
68+
template-rust-linux-x86_64/template-rust
69+
template-rust-windows-x86_64.exe/template-rust.exe
70+
template-rust-macos-x86_64/template-rust
71+
generate_release_notes: true
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/security.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Security Audit
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0' # Weekly on Sunday
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
jobs:
12+
audit:
13+
name: Security Audit
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Install Rust
18+
uses: dtolnay/rust-toolchain@stable
19+
- name: Install cargo-audit
20+
run: cargo install cargo-audit
21+
- name: Cache dependencies
22+
uses: actions/cache@v3
23+
with:
24+
path: |
25+
~/.cargo/registry
26+
~/.cargo/git
27+
target
28+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
29+
- name: Run audit
30+
run: cargo audit

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
/target
2+
*.db
3+
*.db-*
4+
.env
5+
.DS_Store

0 commit comments

Comments
 (0)