Skip to content

Commit

Permalink
new: added code formatting checks (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
pamburus authored Jun 8, 2024
1 parent 8aef1af commit 37cfaa5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
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

0 comments on commit 37cfaa5

Please sign in to comment.