Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: Added code formatting checks #295

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Build
run: cargo build --verbose --benches
run: cargo build --verbose --benches --workspace

- name: Run tests
run: cargo test --verbose
run: cargo test --verbose --workspace

- name: Run executable
run: cargo run

- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt

- name: Check formatting
run: cargo +nightly fmt --verbose --all --check
3 changes: 2 additions & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# enum_discrim_align_threshold = 8
enum_discrim_align_threshold = 32
max_width = 120
hard_tabs = false
ignore = ["*_capnp.rs"]
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ help:
@echo "$$(tput setaf 2)Usage$$(tput sgr0)";sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## /---/;td" -e"s/:.*//;G;s/\\n## /===/;s/\\n//g;p;}" ${MAKEFILE_LIST}|awk -F === -v n=$$(tput cols) -v i=4 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf" '$$(tput setaf 2)make$$(tput sgr0)' %s%s%s\t",a,$$1,z;m=split($$2,w,"---");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;}printf"%*s%s\n",-i," ",w[j];}}' | column -ts $$'\t'
.PHONY: help

## Run continuous integration tests
ci: check-fmt test build
@cargo run -- --version
.PHONY: ci

## Run code formatting tests
check-fmt:
@cargo +nightly fmt --all -- --check
.PHONY: check-fmt

## Automatically format code
fmt:
@cargo +nightly fmt --all
.PHONY: fmt

## Build debug target
build: contrib-build
@cargo build --benches
Expand Down
4 changes: 3 additions & 1 deletion src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ pub fn enable_ansi_support() -> Result<(), ConsoleError> {
use winapi_util::console::Console;

let mut console = Console::stdout().map_err(ConsoleError::FailedToGetStandardOutputHandle)?;
console.set_virtual_terminal_processing(true).map_err(ConsoleError::FailedToSetConsoleMode)?;
console
.set_virtual_terminal_processing(true)
.map_err(ConsoleError::FailedToSetConsoleMode)?;

Ok(())
}
Expand Down
Loading