chore: add makefile

Signed-off-by: azjezz <azjezz@protonmail.com>
This commit is contained in:
azjezz 2022-12-05 12:55:44 +01:00
parent 2e68dd8f35
commit e3960994d0
6 changed files with 39 additions and 21 deletions

View File

@ -34,9 +34,7 @@ jobs:
- name: check
if: matrix.rust == 'stable'
run: |
cargo fmt --all -- --check
cargo clippy
run: make lint
- name: test
run: ./meta/test --all -- --skip third_party
run: make test

View File

@ -32,4 +32,5 @@ jobs:
uses: Swatinem/rust-cache@v2.0.0
- name: test third-party
run: ./meta/test third_party
run: make test-third-party

35
Makefile Normal file
View File

@ -0,0 +1,35 @@
# If the first argument is "dump"...
ifeq (dump,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "dump"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif# If the first argument is "dump"...
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
lint: ## lint code for formatting issues.
cargo fmt --all -- --check
cargo clippy
fix: ## fix linting problems.
cargo fmt
cargo clippy --fix --allow-dirty --allow-staged
dump: ## dump AST for given files.
cargo run --bin php-parser-rs -- $(RUN_ARGS)
snapshot: ## dump a snapshot for intergration tests.
cargo run --bin snapshot
test: ## run integration tests, use filter="..." argument to filter out a specific test.
BUILD_INTEGRATION_TESTS="1" cargo build
cargo test --all $(filter) -- --skip third_party
test-third-party: ## run integration tests against third-party libraries.
BUILD_INTEGRATION_TESTS="1" cargo build
cargo test third_party

View File

@ -1,5 +0,0 @@
#!/usr/bin/env sh
set -xe
cargo run --bin php-parser-rs -- $1

View File

@ -1,5 +0,0 @@
#!/usr/bin/env sh
set -xe
cargo run --bin snapshot

View File

@ -1,6 +0,0 @@
#!/usr/bin/env sh
set -xe
BUILD_INTEGRATION_TESTS="1" cargo build
cargo test "$@"