diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64e2bf412..46d1d4808 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -165,8 +165,7 @@ jobs: - uses: dtolnay/rust-toolchain@nightly with: components: rustfmt - - run: | - cargo fmt --all -- --check + - run: make fmt clippy: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7504a58d7..a4b3951eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,9 +66,7 @@ jobs: target: ${{ matrix.target.triple }} - name: "Run prepare tests" run: ci/prepare-tests.sh - - run: | - cargo build --release --workspace - cargo test --release --workspace + - run: make release - name: "Strip release binary" run: | # strip target/release/pica-lint @@ -119,9 +117,7 @@ jobs: target: ${{ matrix.target.triple }} - name: "Run prepare tests" run: ci/prepare-tests.sh - - run: | - cargo build --release --workspace - cargo test --release --workspace + - run: make release - name: "Build release archive" id: build-archive shell: bash @@ -164,9 +160,7 @@ jobs: target: ${{ matrix.target.triple }} - name: "Run prepare tests" run: ci/prepare-tests.sh - - run: | - cargo build --release --workspace - cargo test --release --workspace + - run: make release - name: "Strip release binary" run: | strip target/release/pica-lint diff --git a/Makefile b/Makefile index 0d7d99e3e..880a47c3a 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,39 @@ +.DEFAULT_GOAL := build + +# Don't use implicit rules or variables. +MAKEFLAGS += -rR + +DESTDIR= CARGO ?= cargo +PREFIX=/usr/local +BINDIR=$(PREFIX)/bin -.PHONY: check check: $(CARGO) check --workspace --all-features -.PHONY: clippy +build: + $(CARGO) build --workspace --all-features + clippy: - $(CARGO) clippy --workspace --all-features -- \ - -D warnings -D rust-2021-compatibility -D future-incompatible \ - -W unreachable-pub + $(CARGO) clippy --workspace --all-features -.PHONY: test test: $(CARGO) test --workspace --all-features --no-fail-fast + +fmt: + $(CARGO) fmt --all -- --check + +doc: + $(CARGO) doc --no-deps + +release: + $(CARGO) build --workspace --all-features --release + $(CARGO) test --workspace --all-features --release + +install: release + sudo install -Dm755 target/release/pica $(DESTDIR)$(BINDIR) + +clean: + $(CARGO) clean + +.PHONY: build clean check clippy test fmt doc release install