Skip to content

Commit cb348c5

Browse files
authored
Enhance Rust CI workflow with caching and checks
Updated the Rust CI workflow to include caching, formatting checks, linting, and artifact uploads for both Windows and Linux.
1 parent 47533ad commit cb348c5

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

.github/workflows/rust.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Rust CI & Build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
# Pozwala uruchomić ręcznie z zakładki Actions
9+
workflow_dispatch:
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
build-and-test:
16+
name: Build on ${{ matrix.os }}
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
# Testujemy na Windows (Twoje środowisko) i Ubuntu (dla pewności)
21+
os: [ubuntu-latest, windows-latest]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
# Cache przyspiesza budowanie przy kolejnych uruchomieniach
27+
- name: Cache Cargo
28+
uses: actions/cache@v3
29+
with:
30+
path: |
31+
~/.cargo/bin/
32+
~/.cargo/registry/index/
33+
~/.cargo/registry/cache/
34+
~/.cargo/git/db/
35+
target/
36+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
37+
38+
# 1. Sprawdzanie formatowania (czy użyłeś cargo fmt)
39+
- name: Check Formatting
40+
run: cargo fmt -- --check
41+
42+
# 2. Sprawdzanie jakości kodu (Linter Clippy)
43+
- name: Lint with Clippy
44+
run: cargo clippy -- -D warnings
45+
46+
# 3. Uruchomienie testów
47+
- name: Run tests
48+
run: cargo test --verbose
49+
50+
# 4. Budowanie wersji produkcyjnej (Release)
51+
- name: Build Release
52+
run: cargo build --release --verbose
53+
54+
# 5. Wyciągnięcie gotowego pliku .exe (Tylko dla Windows)
55+
- name: Upload Windows Artifact
56+
if: runner.os == 'Windows'
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: cargo-plot-fs-tree-windows
60+
path: target/release/cargo-plot-fs-tree.exe
61+
62+
# 6. Wyciągnięcie gotowego pliku binarnego (Tylko dla Linux)
63+
- name: Upload Linux Artifact
64+
if: runner.os == 'Linux'
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: cargo-plot-fs-tree-linux
68+
path: target/release/cargo-plot-fs-tree

0 commit comments

Comments
 (0)