-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add checks and formatting (#64)
- Loading branch information
Showing
15 changed files
with
282 additions
and
4,670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
indent_style = space | ||
trim_trailing_whitespace = true | ||
indent_size = 2 | ||
|
||
[*.rs] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Get Rust toolchain configuration | ||
description: Get the Rust toolchain configuration for the current project defined in the `rust-toolchain` file | ||
outputs: | ||
channel: | ||
description: The Rust toolchain channel | ||
value: ${{ steps.get-toolchain.outputs.channel }} | ||
runs: | ||
using: composite | ||
steps: | ||
- id: get-toolchain | ||
shell: sh | ||
run: | | ||
echo "channel=$(grep channel -i rust-toolchain.toml | cut -d '"' -f2)" \ | ||
>> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get toolchain | ||
id: toolchain | ||
uses: ./.github/actions/get-toolchain | ||
- name: Setup Rust | ||
uses: hecrj/setup-rust-action@v2 | ||
with: | ||
rust-version: ${{ steps.toolchain.outputs.channel }} | ||
targets: wasm32-unknown-unknown | ||
- name: Install cargo binstall | ||
uses: cargo-bins/cargo-binstall@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Install cargo-make | ||
run: cargo binstall -y cargo-make | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Lint | ||
run: cargo make lint | ||
|
||
build-example: | ||
name: Build example | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- example: demo | ||
builder: trunk | ||
- example: ssr-demo | ||
builder: cargo-leptos | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get toolchain | ||
id: toolchain | ||
uses: ./.github/actions/get-toolchain | ||
- name: Setup Rust | ||
uses: hecrj/setup-rust-action@v2 | ||
with: | ||
rust-version: ${{ steps.toolchain.outputs.channel }} | ||
targets: wasm32-unknown-unknown | ||
- name: Install cargo binstall | ||
uses: cargo-bins/cargo-binstall@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Install builder | ||
run: cargo binstall -y ${{ matrix.builder }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ matrix.example }}-${{ matrix.builder }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Build with trunk | ||
if: ${{ matrix.builder == 'trunk' }} | ||
run: | | ||
cd examples/${{ matrix.example }} | ||
trunk build --release | ||
- name: Build with cargo-leptos | ||
if: ${{ matrix.builder == 'cargo-leptos' }} | ||
run: | | ||
cd examples/${{ matrix.example }} | ||
cargo leptos build --release |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Contributing guide | ||
|
||
## Setup | ||
|
||
In order to execute development tasks, you need to install [cargo-make](https://github.com/sagiegurari/cargo-make). | ||
|
||
## Lint | ||
|
||
```sh | ||
cargo make lint | ||
``` | ||
|
||
## Format | ||
|
||
```sh | ||
cargo make format | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
[config] | ||
default_to_workspace = false | ||
|
||
[tasks.lint] | ||
description = "Check format of files and run linters" | ||
run_task = { name = ["lint-rs"] } | ||
|
||
[tasks.lint-rs] | ||
description = "Lint Rust code" | ||
run_task = { name = ["clippy", "cargo-check", "format-check"] } | ||
|
||
[tasks.clippy] | ||
clear = true | ||
description = "Run clippy" | ||
run_task = { name = [ | ||
"clippy-no-features", | ||
"clippy-debug", | ||
"clippy-ssr" | ||
] } | ||
|
||
# TODO: Remove ["-W", "clippy::empty-docs"] when the next issue is resolved: | ||
# https://github.com/leptos-rs/leptos/issues/2406 | ||
[tasks.clippy-no-features] | ||
install_crate = "clippy" | ||
command = "cargo" | ||
args = ["clippy", "--", "-Dwarnings", "-A", "clippy::empty-docs"] | ||
|
||
[tasks.clippy-debug] | ||
install_crate = "clippy" | ||
command = "cargo" | ||
args = ["clippy", "--features=debug", "--", "-Dwarnings", "-A", "clippy::empty-docs"] | ||
|
||
[tasks.clippy-ssr] | ||
install_crate = "clippy" | ||
command = "cargo" | ||
args = ["clippy", "--features=ssr", "--", "-Dwarnings", "-A", "clippy::empty-docs"] | ||
|
||
[tasks.cargo-check] | ||
clear = true | ||
description = "Run cargo-check" | ||
run_task = { name = [ | ||
"cargo-check-no-features", | ||
"cargo-check-debug", | ||
"cargo-check-ssr" | ||
] } | ||
|
||
[tasks.cargo-check-no-features] | ||
command = "cargo" | ||
args = ["check"] | ||
|
||
[tasks.cargo-check-debug] | ||
command = "cargo" | ||
args = ["check", "--features=debug"] | ||
|
||
[tasks.cargo-check-ssr] | ||
command = "cargo" | ||
args = ["check", "--features=ssr"] | ||
|
||
[tasks.format-check] | ||
description = "Check Rust code formatting with rustfmt" | ||
install_crate = "rustfmt" | ||
command = "cargo" | ||
args = ["fmt", "--all", "--check"] | ||
|
||
[tasks.format] | ||
clear = true | ||
description = "Format files" | ||
run_task = { name = ["format-rs"] } | ||
|
||
[tasks.format-rs] | ||
description = "Format Rust code with rustfmt" | ||
install_crate = "rustfmt" | ||
command = "cargo" | ||
args = ["fmt", "--all"] |
Oops, something went wrong.