From 9f7a2d72425aaf1d5598ca2edaff76cf293e33a9 Mon Sep 17 00:00:00 2001 From: Pavel Mikhalkevich Date: Mon, 8 Jan 2024 16:56:43 +0500 Subject: [PATCH 1/6] Add 'Makefile' with useful repetitive commands --- Makefile | 38 ++++++++++++++++++++++++++++++++++++++ README.md | 4 ++++ README.tpl | 4 ++++ 3 files changed, 46 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..20bd694e --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +FAKTORY_HOST=127.0.0.1 +FAKTORY_PORT=7419 +FAKTORY_PORT_UI=7420 + +check: + cargo fmt --check + cargo clippy + cargo d --no-deps --all-features + +doc: + RUSTDOCFLAGS='--cfg docsrs' cargo +nightly d --all-features --open + +faktory: + docker run --rm -d \ + -v faktory-data:/var/lib/faktory \ + -p ${FAKTORY_HOST}:${FAKTORY_PORT}:7419 \ + -p ${FAKTORY_HOST}:${FAKTORY_PORT_UI}:7420 \ + --name faktory \ + contribsys/faktory:latest \ + /faktory -b :7419 -w :7420 + +faktory/kill: + docker stop faktory + +fmt: + cargo fmt + +readme: + cargo readme > README.md + +test: + cargo t --locked --all-features --all-targets + +test/e2e: + FAKTORY_URL=tcp://${FAKTORY_HOST}:${FAKTORY_PORT} cargo test --locked --all-features --all-targets + +test/load: + cargo run --features binaries diff --git a/README.md b/README.md index 299f924d..75ab8eb8 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,7 @@ After that run the tests: FAKTORY_URL=tcp://127.0.0.1:7419 cargo test --all-features --locked --all-targets ``` Please note that setting "FAKTORY_URL" environment variable is required for e2e tests to not be skipped. + +Provided you have [make](https://www.gnu.org/software/make/#download) installed and `docker` daemon running, +you can launch a `Faktory` container with `make faktory` command. After that, hit `make test/e2e` to run the end-to-end test suite. +Remove the container with `make faktory/kill`, if it's no longer needed. diff --git a/README.tpl b/README.tpl index f1ec8085..4a74e9d1 100644 --- a/README.tpl +++ b/README.tpl @@ -19,3 +19,7 @@ After that run the tests: FAKTORY_URL=tcp://127.0.0.1:7419 cargo test --all-features --locked --all-targets ``` Please note that setting "FAKTORY_URL" environment variable is required for e2e tests to not be skipped. + +Provided you have [make](https://www.gnu.org/software/make/#download) installed and `docker` daemon running, +you can launch a `Faktory` container with `make faktory` command. After that, hit `make test/e2e` to run the end-to-end test suite. +Remove the container with `make faktory/kill`, if it's no longer needed. From 13c2e5a6df6917855e64b0f367ce798d6d9ef712 Mon Sep 17 00:00:00 2001 From: Pavel Mikhalkevich Date: Wed, 10 Jan 2024 01:37:16 +0500 Subject: [PATCH 2/6] Add test/doc phony target to makefile --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 20bd694e..32241930 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ readme: test: cargo t --locked --all-features --all-targets +test/doc: + cargo test --locked --all-features --doc + test/e2e: FAKTORY_URL=tcp://${FAKTORY_HOST}:${FAKTORY_PORT} cargo test --locked --all-features --all-targets From a0b9217722ee9089ec29fe202da90855556a2063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavie=C5=82=20Michalkievi=C4=8D?= <117771945+rustworthy@users.noreply.github.com> Date: Sat, 20 Jan 2024 21:04:54 +0500 Subject: [PATCH 3/6] Use README.md: README.tpl src/lib.rs Co-authored-by: Jon Gjengset --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 32241930..793aff93 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ faktory/kill: fmt: cargo fmt -readme: +README.md: README.tpl src/lib.rs cargo readme > README.md test: From df131c1a41bb55d9a725d27622986232d9834686 Mon Sep 17 00:00:00 2001 From: Pavel Mikhalkevich Date: Sat, 20 Jan 2024 22:25:33 +0500 Subject: [PATCH 4/6] Use .PHONY. Add 'test/perf' for flamegraph --- .gitignore | 1 + Makefile | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index eccd7b4a..7dc25afe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target/ **/*.rs.bk +perf_* diff --git a/Makefile b/Makefile index 793aff93..9d8d2e26 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: check doc faktory faktory/* test test/* + FAKTORY_HOST=127.0.0.1 FAKTORY_PORT=7419 FAKTORY_PORT_UI=7420 @@ -22,9 +24,6 @@ faktory: faktory/kill: docker stop faktory -fmt: - cargo fmt - README.md: README.tpl src/lib.rs cargo readme > README.md @@ -38,4 +37,13 @@ test/e2e: FAKTORY_URL=tcp://${FAKTORY_HOST}:${FAKTORY_PORT} cargo test --locked --all-features --all-targets test/load: - cargo run --features binaries + cargo run --release --features binaries + +test/perf: + cargo build --release --features binaries + perf record -o perf_loadtest.data --call-graph dwarf target/release/loadtest + perf script -i perf_loadtest.data | inferno-collapse-perf > perf_loadtest_stacks.folded + cat perf_loadtest_stacks.folded | inferno-flamegraph > perf_loadtest.svg + +test/perf/clean: + rm perf_loadtest* From 9fd5a0d271139fc11bf28ce36c252d5f26fb1373 Mon Sep 17 00:00:00 2001 From: Pavel Mikhalkevich Date: Sun, 21 Jan 2024 17:57:30 +0500 Subject: [PATCH 5/6] Use cargo-flamegraph --- .gitignore | 2 +- Makefile | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 7dc25afe..e8da9172 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /target/ **/*.rs.bk -perf_* +perf.* diff --git a/Makefile b/Makefile index 9d8d2e26..9090cfa0 100644 --- a/Makefile +++ b/Makefile @@ -40,10 +40,7 @@ test/load: cargo run --release --features binaries test/perf: - cargo build --release --features binaries - perf record -o perf_loadtest.data --call-graph dwarf target/release/loadtest - perf script -i perf_loadtest.data | inferno-collapse-perf > perf_loadtest_stacks.folded - cat perf_loadtest_stacks.folded | inferno-flamegraph > perf_loadtest.svg + CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -o perf.flamegraph.svg -f binaries -b loadtest test/perf/clean: - rm perf_loadtest* + rm perf.* From 61afdf1d2b73a1bac358f5ab924c009cc79aad0d Mon Sep 17 00:00:00 2001 From: Pavel Mikhalkevich Date: Sun, 28 Jan 2024 21:54:28 +0500 Subject: [PATCH 6/6] Add phony targets as prerequisite of .PHONY right before target declaration --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9090cfa0..23b9a17a 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,18 @@ -.PHONY: check doc faktory faktory/* test test/* - FAKTORY_HOST=127.0.0.1 FAKTORY_PORT=7419 FAKTORY_PORT_UI=7420 +.PHONY: check check: cargo fmt --check cargo clippy cargo d --no-deps --all-features +.PHONY: doc doc: RUSTDOCFLAGS='--cfg docsrs' cargo +nightly d --all-features --open +.PHONY: faktory faktory: docker run --rm -d \ -v faktory-data:/var/lib/faktory \ @@ -21,26 +22,33 @@ faktory: contribsys/faktory:latest \ /faktory -b :7419 -w :7420 +.PHONY: faktory/kill faktory/kill: docker stop faktory README.md: README.tpl src/lib.rs cargo readme > README.md +.PHONY: test test: cargo t --locked --all-features --all-targets +.PHONY: test/doc test/doc: cargo test --locked --all-features --doc +.PHONY: test/e2e test/e2e: FAKTORY_URL=tcp://${FAKTORY_HOST}:${FAKTORY_PORT} cargo test --locked --all-features --all-targets +.PHONY: test/load test/load: cargo run --release --features binaries +.PHONY: test/perf test/perf: CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -o perf.flamegraph.svg -f binaries -b loadtest +.PHONY: test/perf/clean test/perf/clean: rm perf.*