-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: unify the toolchain and commands in dev env and CI (#192)
* ci: unify the toolchain and commands in dev env and CI * add taplo.toml * move set-log.sh into scripts dir * rename job name: build => test * fix indent
- Loading branch information
Showing
8 changed files
with
142 additions
and
15 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 |
---|---|---|
|
@@ -36,19 +36,16 @@ jobs: | |
restore-keys: | | ||
${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }} | ||
${{ runner.os }}-cargo-lint- | ||
${{ runner.os }}-cargo- | ||
${{ runner.os }}-cargo- | ||
- name: Run sccache | ||
uses: mozilla-actions/[email protected] | ||
|
||
- name: Install toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: 1.78.0 | ||
components: rustfmt, clippy | ||
run: make setup | ||
|
||
- name: Check format | ||
run: cargo fmt --all -- --check | ||
run: make fmt-check | ||
|
||
- name: Check clippy | ||
run: cargo clippy --all-targets --all-features -- -D warnings | ||
run: make clippy |
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ env: | |
SCCACHE_GHA_ENABLED: true | ||
|
||
jobs: | ||
build: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
|
@@ -42,10 +42,7 @@ jobs: | |
uses: mozilla-actions/[email protected] | ||
|
||
- name: Install toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: 1.78.0 | ||
components: rustfmt, clippy | ||
run: make setup | ||
|
||
- name: Run tests | ||
run: cargo test --verbose | ||
run: make test |
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
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,71 @@ | ||
.PHONY: setup | ||
# Setup development environment | ||
setup: | ||
bash ./scripts/setup-dev.sh | ||
|
||
.PHONY: clean | ||
# Cleanup compilation outputs | ||
clean: | ||
cargo clean | ||
|
||
.PHONY: fmt-check fmt | ||
# Check the code format | ||
fmt-check: | ||
taplo fmt --check | ||
cargo fmt --all -- --check | ||
# Format the code | ||
fmt: | ||
taplo fmt | ||
cargo fmt --all | ||
|
||
.PHONY: clippy clippy-release | ||
# Run rust clippy with debug profile | ||
clippy: | ||
cargo clippy --all-targets --all-features -- -D warnings | ||
# Run rust clippy with release profile | ||
clippy-release: | ||
cargo clippy --release --all-targets --all-features -- -D warnings | ||
|
||
.PHONY: check check-release | ||
# Check code with debug profile | ||
check: | ||
cargo check | ||
# Check code with release profile | ||
check-release: | ||
cargo check --release | ||
|
||
.PHONY: build build-release | ||
# Build all binaries with debug profile | ||
build: | ||
cargo build | ||
# Build all binaries with release profile | ||
build-release: | ||
cargo build --release | ||
|
||
.PHONY: test test-release | ||
# Run all unit tests with debug profile | ||
test: | ||
cargo test --lib --all | ||
# Run all unit tests with release profile | ||
test-release: | ||
cargo test --release --lib --all | ||
|
||
.PHONY: help | ||
# Show help | ||
help: | ||
@echo '' | ||
@echo 'Usage:' | ||
@echo ' make [target]' | ||
@echo '' | ||
@echo 'Targets:' | ||
@awk '/^[a-zA-Z\-\_0-9]+:/ { \ | ||
helpMessage = match(lastLine, /^# (.*)/); \ | ||
if (helpMessage) { \ | ||
helpCommand = substr($$1, 0, index($$1, ":")); \ | ||
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \ | ||
printf "\033[36m%-30s\033[0m %s\n", helpCommand,helpMessage; \ | ||
} \ | ||
} \ | ||
{ lastLine = $$0 }' $(MAKEFILE_LIST) | ||
|
||
.DEFAULT_GOAL := help |
File renamed without changes.
File renamed without changes.
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,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
function install_rustup { | ||
echo "Installing Rust toolchain..." | ||
if rustup --version &> /dev/null; then | ||
echo "Rust toolchain has been installed" | ||
else | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none | ||
source "$HOME"/.cargo/env | ||
fi | ||
rustup show | ||
} | ||
|
||
function install_cargo_binary { | ||
CRATE_NAME=$1 | ||
BIN_NAME=${2:-$1} | ||
if command -v "$BIN_NAME" &> /dev/null; then | ||
echo "$CRATE_NAME has been installed" | ||
else | ||
cargo install "$CRATE_NAME" --force --locked | ||
fi | ||
} | ||
|
||
install_rustup | ||
install_cargo_binary "taplo-cli" "taplo" |
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,37 @@ | ||
## https://taplo.tamasfe.dev/configuration/#configuration-file | ||
|
||
include = ["**/Cargo.toml"] | ||
exclude = ["target/**/Cargo.toml"] | ||
|
||
[formatting] | ||
# Align consecutive entries vertically. | ||
align_entries = false | ||
# Append trailing commas for multi-line arrays. | ||
array_trailing_comma = true | ||
# Expand arrays to multiple lines that exceed the maximum column width. | ||
array_auto_expand = true | ||
# Collapse arrays that don't exceed the maximum column width and don't contain comments. | ||
array_auto_collapse = false | ||
# Omit white space padding from single-line arrays | ||
compact_arrays = true | ||
# Omit white space padding from the start and end of inline tables. | ||
compact_inline_tables = false | ||
# Maximum column width in characters, affects array expansion and collapse, this doesn't take whitespace into account. | ||
# Note that this is not set in stone, and works on a best-effort basis. | ||
column_width = 160 | ||
# Indent based on tables and arrays of tables and their subtables, subtables out of order are not indented. | ||
indent_tables = false | ||
# The substring that is used for indentation, should be tabs or spaces (but technically can be anything). | ||
indent_string = ' ' | ||
# Add trailing newline at the end of the file if not present. | ||
trailing_newline = true | ||
# Alphabetically reorder keys that are not separated by empty lines. | ||
reorder_keys = false | ||
# Maximum amount of allowed consecutive blank lines. This does not affect the whitespace at the end of the document, as it is always stripped. | ||
allowed_blank_lines = 1 | ||
# Use CRLF for line endings. | ||
crlf = false | ||
|
||
[[rule]] | ||
keys = ["workspace.dependencies", "dependencies", "dev-dependencies", "build-dependencies"] | ||
formatting = { reorder_keys = true } |