2023-05-30 01:19:32 +00:00
## Script for executing commands for the project.
2023-05-31 17:23:43 +00:00
export TARGET_DIR := join( justfile_directory( ) , "target" )
export TDNS_BIND_PATH := join( TARGET_DIR, "bind" )
2023-06-02 04:37:58 +00:00
export TEST_DATA := join( join( justfile_directory( ) , "tests" ) , "test-data" )
2023-05-31 17:23:43 +00:00
2024-05-29 15:48:16 +00:00
NIGHTLY_DATE := "2024-05-23"
2023-09-26 00:01:08 +00:00
## MSRV
MSRV := env_var_or_default( 'MSRV' , "" )
2023-06-06 18:54:05 +00:00
## Code coverage config
COV_RUSTFLAGS := "-C instrument-coverage -C llvm-args=--instrprof-atomic-counter-update-all --cfg=coverage --cfg=trybuild_no_target"
COV_CARGO_INCREMENTAL := "0"
COV_CARGO_LLVM_COV := "1"
COV_CARGO_LLVM_COV_TARGET_DIR := join( TARGET_DIR, "llvm-cov-target" )
2023-10-14 01:39:28 +00:00
COV_LLVM_PROFILE_FILE := join( COV_CARGO_LLVM_COV_TARGET_DIR, "hickory-dns-%p-%m_%c.profraw" )
2023-06-06 18:54:05 +00:00
2023-05-31 17:23:43 +00:00
BIND_VER := "9.16.41"
2023-05-30 01:19:32 +00:00
2023-06-01 22:01:36 +00:00
# Check, build, and test all crates with default features enabled
default feature='' ignore='' : (check feature ignore ) (build feature ignore ) (test feature ignore )
# Check, build, and test all crates with all-features enabled
all-features : (default "--all -features ")
# Check, build, and test all crates with no-default-features
2023-10-14 01:39:28 +00:00
no-default-features : (default "--no -default -features " "--ignore =\\{hickory -compatibility \\}")
2023-06-01 22:01:36 +00:00
# Check, build, and test all crates with dns-over-rustls enabled
2023-10-14 01:39:28 +00:00
dns-over-rustls : (default "--features =dns -over -rustls " "--ignore =\\{async -std -resolver , hickory -compatibility \\}")
2023-06-01 22:01:36 +00:00
# Check, build, and test all crates with dns-over-https-rustls enabled
2023-10-14 01:39:28 +00:00
dns-over-https-rustls : (default "--features =dns -over -https -rustls " "--ignore =\\{async -std -resolver , hickory -compatibility \\}")
2023-06-01 22:01:36 +00:00
# Check, build, and test all crates with dns-over-quic enabled
2023-10-14 01:39:28 +00:00
dns-over-quic : (default "--features =dns -over -quic " "--ignore =\\{async -std -resolver , hickory -compatibility \\}")
2023-06-01 22:01:36 +00:00
2023-07-07 15:42:31 +00:00
# Check, build, and test all crates with dns-over-h3 enabled
2023-10-14 01:39:28 +00:00
dns-over-h3 : (default "--features =dns -over -h 3" "--ignore =\\{async -std -resolver , hickory -compatibility , hickory -client \\}")
2023-07-07 15:42:31 +00:00
2023-06-01 22:01:36 +00:00
# Check, build, and test all crates with dns-over-native-tls enabled
2023-10-14 01:39:28 +00:00
dns-over-native-tls : (default "--features =dns -over -native -tls " "--ignore =\\{async -std -resolver , hickory -compatibility , hickory -server , hickory -dns , hickory -util , hickory -integration \\}")
2023-06-01 22:01:36 +00:00
# Check, build, and test all crates with dns-over-openssl enabled
2023-10-14 01:39:28 +00:00
dns-over-openssl : (default "--features =dnssec -openssl " "--ignore =\\{async -std -resolver , hickory -compatibility \\}")
2023-06-01 22:01:36 +00:00
# Check, build, and test all crates with dnssec-openssl enabled
2023-10-14 01:39:28 +00:00
dnssec-openssl : (default "--features =dnssec -openssl " "--ignore =\\{async -std -resolver , hickory -compatibility \\}")
2023-06-01 22:01:36 +00:00
# Check, build, and test all crates with dnssec-ring enabled
2023-10-14 01:39:28 +00:00
dnssec-ring : (default "--features =dnssec -ring " "--ignore =\\{async -std -resolver , hickory -compatibility \\}")
2023-05-30 01:19:32 +00:00
2023-05-31 17:31:06 +00:00
# Run check on all projects in the workspace
2023-06-01 22:01:36 +00:00
check feature='' ignore='' :
2023-09-26 00:01:08 +00:00
cargo ws exec { { ignore} } cargo { { MSRV} } check --all-targets --benches --examples --bins --tests { { feature} }
cargo { { MSRV} } check --manifest-path fuzz/Cargo.toml --all-targets --benches --examples --bins --tests
2023-05-30 01:19:32 +00:00
2023-05-31 17:31:06 +00:00
# Run build on all projects in the workspace
2023-06-01 22:01:36 +00:00
build feature='' ignore='' :
2023-09-26 00:01:08 +00:00
cargo ws exec { { ignore} } cargo { { MSRV} } build --all-targets --benches --examples --bins --tests { { feature} }
2023-05-30 01:19:32 +00:00
2023-05-31 17:31:06 +00:00
# Run tests on all projects in the workspace
2023-06-01 22:01:36 +00:00
test feature='' ignore='' :
2023-09-26 00:01:08 +00:00
cargo ws exec { { ignore} } cargo { { MSRV} } test --all-targets --benches --examples --bins --tests { { feature} }
2023-11-06 10:00:05 +00:00
doc feature='' :
cargo ws exec --ignore= hickory-dns cargo { { MSRV} } test --doc { { feature} }
2023-05-31 04:41:12 +00:00
# This tests compatibility with BIND9, TODO: support other feature sets besides openssl for tests
2023-05-31 17:31:06 +00:00
compatibility : init -bind 9
2023-05-31 04:41:12 +00:00
cargo test --manifest-path tests/compatibility-tests/Cargo.toml --all-targets --benches --examples --bins --tests --no-default-features --features= none;
cargo test --manifest-path tests/compatibility-tests/Cargo.toml --all-targets --benches --examples --bins --tests --no-default-features --features= bind;
2023-05-30 01:19:32 +00:00
2023-05-31 17:41:39 +00:00
# Build all bench marking tools, i.e. check that they work, but don't run
build-bench :
2024-05-29 15:48:16 +00:00
cargo ws exec cargo +nightly-{ { NIGHTLY_DATE} } bench --no-run
2023-05-31 17:41:39 +00:00
2023-05-31 18:09:24 +00:00
[ p r i v a t e ]
clippy-inner feature='' :
2023-09-26 00:01:08 +00:00
cargo ws exec cargo { { MSRV} } clippy --all-targets --benches --examples --bins --tests { { feature} } -- -D warnings
2023-05-31 18:09:24 +00:00
# Run clippy on all targets and all sources
clippy :
find { { justfile_directory( ) } } -name '*.rs' -exec touch { } \;
just clippy-inner --no-default-features
just clippy-inner
just clippy-inner --all-features
2023-05-31 18:13:11 +00:00
# Check the format of all the Rust code with rustfmt
fmt :
cargo ws exec cargo fmt -- --check
cargo fmt --manifest-path fuzz/Cargo.toml -- --check
2023-05-31 18:26:59 +00:00
# Audit all depenedencies
audit : init -audit (check '--all -features ')
cargo audit --deny warnings
cargo audit --file fuzz/Cargo.lock --deny warnings
2023-05-31 18:33:14 +00:00
# Task to run clippy, rustfmt, and audit on all crates
cleanliness : clippy fmt audit
2023-06-01 03:04:00 +00:00
# Generate coverage report
coverage : init -llvm -cov
#!/usr/bin/env bash
set -euxo pipefail
2023-06-06 18:54:05 +00:00
export RUSTFLAGS = "{{COV_RUSTFLAGS}}"
export CARGO_LLVM_COV = { { COV_CARGO_LLVM_COV} }
export CARGO_LLVM_COV_TARGET_DIR = { { COV_CARGO_LLVM_COV_TARGET_DIR} }
export LLVM_PROFILE_FILE = { { COV_LLVM_PROFILE_FILE} }
2023-06-01 03:04:00 +00:00
echo $RUSTFLAGS
cargo +nightly llvm-cov clean
2023-06-06 18:54:05 +00:00
mkdir -p { { COV_CARGO_LLVM_COV_TARGET_DIR} }
2023-06-01 03:04:00 +00:00
cargo +nightly build --workspace --all-targets --all-features
2023-06-06 18:54:05 +00:00
cargo +nightly llvm-cov test --workspace --no-report --all-targets --benches --examples --bins --tests --all-features
cargo +nightly llvm-cov test --workspace --no-report --doc --doctests --all-features
2023-10-14 01:39:28 +00:00
cargo +nightly llvm-cov report --codecov --output-path { { join( COV_CARGO_LLVM_COV_TARGET_DIR, "hickory-dns-coverage.json" ) } }
2023-06-01 03:04:00 +00:00
2023-06-05 18:29:46 +00:00
# Open the html view of the coverage report
coverage-html : coverage
#!/usr/bin/env bash
set -euxo pipefail
2023-06-06 18:54:05 +00:00
export RUSTFLAGS = "{{COV_RUSTFLAGS}}"
export CARGO_LLVM_COV = { { COV_CARGO_LLVM_COV} }
export CARGO_LLVM_COV_TARGET_DIR = { { COV_CARGO_LLVM_COV_TARGET_DIR} }
export LLVM_PROFILE_FILE = { { COV_LLVM_PROFILE_FILE} }
2023-06-05 18:29:46 +00:00
2023-06-06 18:54:05 +00:00
cargo +nightly llvm-cov report --html --open --output-dir { { COV_CARGO_LLVM_COV_TARGET_DIR} }
2023-06-05 18:29:46 +00:00
2023-06-02 04:37:58 +00:00
# (Re)generates Test Certificates, if tests are failing, this needs to be run yearly
generate-test-certs : init -openssl
2023-12-02 20:09:51 +00:00
cd { { TEST_DATA} } && rm -f ca.key ca.pem cert.key cert-key.pkcs8 cert.csr cert.pem cert.p12
2023-06-02 04:37:58 +00:00
scripts/gen_certs.sh
2023-06-01 22:08:28 +00:00
# Publish all crates
publish :
cargo ws publish --from-git --token $CRATES_IO_TOKEN
2023-05-31 17:31:06 +00:00
# Removes the target directory cleaning all built artifacts
2023-05-31 17:23:43 +00:00
clean :
rm -rf { { TARGET_DIR} }
2024-05-29 13:54:39 +00:00
conformance : (conformance -framework ) (conformance -unbound ) (conformance -bind ) (conformance -hickory ) (conformance -ignored ) (conformance -clippy ) (conformance -fmt )
conformance-framework :
DNS_TEST_VERBOSE_DOCKER_BUILD = 1 cargo t --manifest-path conformance/Cargo.toml -p dns-test
conformance-unbound filter='' :
DNS_TEST_VERBOSE_DOCKER_BUILD = 1 DNS_TEST_PEER = bind DNS_TEST_SUBJECT = unbound cargo t --manifest-path conformance/Cargo.toml -p conformance-tests -- --include-ignored { { filter} }
conformance-bind filter='' :
DNS_TEST_VERBOSE_DOCKER_BUILD = 1 DNS_TEST_PEER = unbound DNS_TEST_SUBJECT = bind cargo t --manifest-path conformance/Cargo.toml -p conformance-tests -- --include-ignored { { filter} }
conformance-hickory filter='' :
DNS_TEST_VERBOSE_DOCKER_BUILD = 1 DNS_TEST_PEER = unbound DNS_TEST_SUBJECT = "hickory {{justfile_directory()}}" cargo t --manifest-path conformance/Cargo.toml -p conformance-tests -- { { filter} }
conformance-ignored :
#!/usr/bin/env bash
tmpfile = " $( mktemp) "
DNS_TEST_VERBOSE_DOCKER_BUILD = 1 DNS_TEST_PEER = unbound DNS_TEST_SUBJECT = "hickory {{justfile_directory()}}" cargo test --manifest-path conformance/Cargo.toml -p conformance-tests -- --ignored | tee " $tmpfile "
grep 'test result: FAILED. 0 passed' " $tmpfile " || ( echo "expected ALL tests to fail but at least one passed; the passing tests must be un-#[ignore]-d" && exit 1 )
conformance-clippy :
cargo clippy --manifest-path conformance/Cargo.toml --workspace --all-targets -- -D warnings
conformance-fmt :
cargo fmt --manifest-path conformance/Cargo.toml --all -- --check
2024-06-07 20:55:27 +00:00
conformance-clean : (conformance -clean -containers ) (conformance -clean -networks )
conformance-clean-containers :
docker rm -f $( docker ps | grep dns-test | cut -f 1 -d " " )
conformance-clean-networks :
docker network rm $( docker network ls | grep dns-test | cut -f 1 -d " " )
2023-05-31 04:41:12 +00:00
[ p r i v a t e ]
[ m a c o s ]
2023-06-02 04:37:58 +00:00
init-openssl :
openssl version || brew install openssl@1.1
[ p r i v a t e ]
[ l i n u x ]
init-openssl :
openssl version
[ p r i v a t e ]
[ m a c o s ]
init-bind9-deps : init -openssl
2023-05-31 04:41:12 +00:00
pip install ply
brew install wget
[ p r i v a t e ]
[ l i n u x ]
init-bind9-deps :
if apt-get --version ; then sudo apt-get install -y python3-ply ; fi
2023-05-31 17:23:43 +00:00
# Install BIND9, needed for compatability tests
2023-05-31 04:41:12 +00:00
[ u n i x ]
2023-05-31 17:31:06 +00:00
init-bind9 :
2023-05-31 04:41:12 +00:00
#!/usr/bin/env bash
set -euxo pipefail
if { { TDNS_BIND_PATH} } /sbin/named -v ; then exit 0 ; fi
2023-05-31 17:31:06 +00:00
just init-bind9-deps
2023-05-31 04:41:12 +00:00
## This must run after OpenSSL installation
if openssl version ; then WITH_OPENSSL = " --with-openssl= $( dirname $( dirname $( which openssl) ) ) " ; fi
2023-05-30 01:19:32 +00:00
2023-05-31 04:41:12 +00:00
mkdir -p { { TARGET_DIR} }
echo "----> downloading bind"
rm -rf { { TARGET_DIR} } /bind-{ { BIND_VER} }
2023-05-31 17:23:43 +00:00
wget -O { { TARGET_DIR} } /bind-{ { BIND_VER} } .tar.xz https://downloads.isc.org/isc/bind9/{ { BIND_VER} } /bind-{ { BIND_VER} } .tar.xz
ls -la { { TARGET_DIR} } /bind-{ { BIND_VER} } .tar.xz
tar -xJf { { TARGET_DIR} } /bind-{ { BIND_VER} } .tar.xz -C { { TARGET_DIR} }
2023-05-31 04:41:12 +00:00
echo "----> compiling bind"
cd { { TARGET_DIR} } /bind-{ { BIND_VER} }
./configure --prefix { { TDNS_BIND_PATH} } ${ WITH_OPENSSL }
make install
cd -
2023-05-31 17:23:43 +00:00
{ { TDNS_BIND_PATH} } /sbin/named -v
2023-05-31 04:41:12 +00:00
2023-05-31 17:23:43 +00:00
rm { { TARGET_DIR} } /bind-{ { BIND_VER} } .tar.xz
rm -rf { { TARGET_DIR} } /bind-{ { BIND_VER} }
2023-05-31 04:41:12 +00:00
# Check for the cargo-workspaces command, install if it does not exist
init-cargo-workspaces :
@cargo ws --version || cargo install cargo-workspaces
2023-06-02 04:37:58 +00:00
# Install audit tools
2023-05-31 18:26:59 +00:00
init-audit :
@cargo audit --version || cargo install cargo-audit
2023-06-01 03:04:00 +00:00
2023-06-02 04:37:58 +00:00
# Install the code coverage components for LLVM
2023-06-01 03:04:00 +00:00
init-llvm-cov :
@cargo llvm-cov --version || cargo install cargo-llvm-cov
2023-06-02 04:10:20 +00:00
@rustup component add llvm-tools-preview
2023-06-01 03:04:00 +00:00
2023-05-31 04:41:12 +00:00
# Initialize all tools needed for running tests, etc.
2023-05-31 18:26:59 +00:00
init : init -cargo -workspaces init -audit init -bind 9
2023-05-31 04:41:12 +00:00
@echo 'all tools initialized'
2023-09-06 16:02:45 +00:00
# Run the server with example config, for manual testing purposes
run-example :
2023-10-14 01:39:28 +00:00
@cargo { { MSRV} } run --bin hickory-dns -- -d -c { { TEST_DATA} } /test_configs/example.toml -z { { TEST_DATA} } /test_configs -p 2053
2024-05-29 13:54:39 +00:00