Skip to content

Commit

Permalink
ci: Add rustfmt warning
Browse files Browse the repository at this point in the history
We are all human and forget to run formatters and checks. Let the CI
help us to recognize and remedy our human failings!

Signed-off-by: Peter Neuroth <[email protected]>
  • Loading branch information
nepet committed Nov 2, 2023
1 parent 5a670a8 commit 3ce544b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check Formatting

on:
pull_request:
types:
- synchronize
- opened
workflow_dispatch:

jobs:
check-formatting:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.73
components: rustfmt

- name: Check Rust Formatting
continue-on-error: true
run: |
make check-rustfmt
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: check-rustfm

ifdef GL_DOCKER
REPO_ROOT=/repo
else
Expand All @@ -23,6 +25,8 @@ endif
ARTIFACTS = \
.coverage

CHANGED_RUST_SOURCES=$(shell git diff --name-only origin/main | grep '\.rs')

# Variable to collect all generated files into, so we can clean and
# rebuild them easily.
GENALL =
Expand Down Expand Up @@ -66,6 +70,12 @@ check-self: ensure-docker
/repo/libs/gl-testing \
${PYTEST_OPTS}

check-rustfmt:
@if [ -n "${CHANGED_RUST_SOURCES}" ]; then \
rustfmt --edition 2021 --check ${CHANGED_RUST_SOURCES}; else \
echo "skip rustfmt check no changes detected ${CHANGED_RUST_SOURCES}"; \
fi

ensure-docker:
@if [ "x${GL_DOCKER}" != "x1" ]; then \
echo "We are not running in the gl-testing docker container, refusing to run"; \
Expand Down

0 comments on commit 3ce544b

Please sign in to comment.