Skip to content

Commit 39ae943

Browse files
committed
Add repo configs
1 parent 3763e02 commit 39ae943

File tree

6 files changed

+167
-0
lines changed

6 files changed

+167
-0
lines changed

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
charset = utf-8
9+
10+
[*.{js,jsx,ts,tsx}]
11+
indent_size = 2
12+
13+
[*.{rs,py}]
14+
indent_size = 4
15+
16+
[*.go]
17+
indent_style = tab
18+
19+
[*.md]
20+
trim_trailing_whitespace = false
21+
22+
[Makefile]
23+
indent_style = tab

.github/workflows/general-rust.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: General Rust
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths-ignore:
8+
- "**.md"
9+
- "**.png"
10+
- "**.yml"
11+
pull_request:
12+
workflow_dispatch:
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
test:
19+
name: Test
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v3
24+
25+
- name: Cache dependencies
26+
id: cache-dependencies
27+
uses: actions/cache@v3
28+
with:
29+
path: |
30+
~/.cargo/registry
31+
~/.cargo/git
32+
target
33+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
34+
35+
- name: Update Rust
36+
run: rustup update
37+
38+
- name: Run cargo test
39+
run: make test
40+
41+
fmt:
42+
name: Rustfmt
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v3
46+
47+
- name: Update Rust
48+
run: rustup update
49+
50+
- name: Install Rust nightly
51+
run: rustup install nightly --profile minimal
52+
53+
- name: Install Rustfmt
54+
run: rustup component add rustfmt --toolchain nightly
55+
56+
- name: Run cargo fmt
57+
run: make fmt-rust-check
58+
59+
clippy:
60+
name: Clippy
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v3
65+
66+
- name: Cache dependencies
67+
id: cache-dependencies
68+
uses: actions/cache@v3
69+
with:
70+
path: |
71+
~/.cargo/registry
72+
~/.cargo/git
73+
target
74+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
75+
76+
- name: Update Rust
77+
run: rustup update
78+
79+
- name: Run clippy
80+
run: make lint-rust

.gitignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -------------------------------------------------------------------------------------
2+
# -------------------------------------- Rust -----------------------------------------
3+
# -------------------------------------------------------------------------------------
4+
5+
# Generated by Cargo
6+
# will have compiled files and executables
7+
debug/
8+
target/
9+
10+
# These are backup files generated by rustfmt
11+
**/*.rs.bk
12+
13+
# MSVC Windows builds of rustc generate these, which store debugging information
14+
*.pdb
15+
16+
# -------------------------------------------------------------------------------------
17+
# -------------------------------------- Misc -----------------------------------------
18+
# -------------------------------------------------------------------------------------
19+
20+
# OSX
21+
.DS_Store
22+
23+
# Logs
24+
logs
25+
*.log
26+
27+
# Environment variables
28+
.env
29+
.env.*
30+
node_modules

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"editorconfig.editorconfig",
4+
"esbenp.prettier-vscode",
5+
"dbaeumer.vscode-eslint",
6+
"rust-lang.rust-analyzer"
7+
]
8+
}

.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
3+
"rust-analyzer.showUnlinkedFileNotification": false
4+
}

Makefile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ci: fmt lint test
2+
ci-check: fmt-check lint test
3+
4+
fmt: fmt-rust
5+
fmt-check: fmt-rust-check
6+
lint: lint-rust
7+
8+
fmt-rust:
9+
@echo "Formatting Rust code..."
10+
@cargo +nightly fmt --all
11+
12+
fmt-rust-check:
13+
@echo "Checking Rust code formatting..."
14+
@cargo +nightly fmt --all -- --check
15+
16+
lint-rust:
17+
@echo "Linting Rust code..."
18+
@cargo clippy --all --all-features -- -D warnings
19+
20+
test:
21+
@echo "Running tests..."
22+
@cargo test --all --all-features

0 commit comments

Comments
 (0)