Skip to content

Commit

Permalink
ci: add PR code formatting check
Browse files Browse the repository at this point in the history
Add a CI pipeline to validate code formatting on Pull Requests.

Also, temporarily disable "wrap_comments = true" in rustfmt.toml until a
rustfmt regression [1] is fixed.

[1] rust-lang/rustfmt#5862

Signed-off-by: Renato Westphal <[email protected]>
  • Loading branch information
rwestphal committed Sep 4, 2023
1 parent cf80e37 commit 939c076
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: Code Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: "rustfmt --check"
run: |
if ! rustfmt --check --edition 2021 $(git ls-files '*.rs'); then
printf "Please run \`rustfmt --edition 2021 \$(git ls-files '*.rs')\` to fix rustfmt errors.\nSee CONTRIBUTING.md for more details.\n" >&2
exit 1
fi
test:
name: Test
name: Tests and Coverage Report
env:
holo: rust_ci_github_actions_workflow
CARGO_INCREMENTAL: 0
Expand Down Expand Up @@ -41,7 +53,8 @@ jobs:
files: ./lcov.info
fail_ci_if_error: true

push-store-image:
push-image:
name: Docker Image Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ group_imports = "StdExternalCrate"
imports_granularity = "Module"
max_width = 80
merge_derives = false
wrap_comments = true
wrap_comments = false

0 comments on commit 939c076

Please sign in to comment.