11#! /bin/sh
22
3- # This file provides command alias commonly used by the developers involved in Canyon-SQL
4- # This alias avoid the usage of a bunch of commands for performn an integrated task that
5- # depends on several concatenated commands.
6-
7- # In order to run the script, simply type `$ . ./bash_aliases.sh` from the root of the project.
8- # (refreshing the current terminal session could be required)
9-
10- # Executes the docker compose script to wake up the containers
11- alias DockerUp=' docker-compose -f ./docker/docker-compose.yml up'
12- # Shutdown the postgres container
13- alias DockerDown=' docker-compose -f ./docker/docker-compose.yml down'
14- # Cleans the generated cache folder for the postgres in the docker
15- alias CleanPostgres=' rm -rf ./docker/postgres-data'
16-
17- # Code Quality
18- alias Clippy=' cargo clippy --all-targets --all-features --workspace -- -D warnings'
19- alias Fmt=' cargo fmt --all -- --check'
20-
21- # Build the project for Windows targets
22- alias BuildCanyonWin=' cargo build --all-features --target=x86_64-pc-windows-msvc'
23- alias BuildCanyonWinFull=' cargo clean && cargo build --all-features --target=x86_64-pc-windows-msvc'
24-
25- # Build the project for Linux targets
26- alias BuildCanyonLinux=' cargo build --all-features --target=x86_64-unknown-linux-gnu'
27- alias BuildCanyonLinuxFull=' cargo clean && cargo build --all-features --target=x86_64-unknown-linux-gnu'
28-
29- # Runs all the tests within Canyon-SQL for Windows targets
30- alias TestsWin=' cargo test --all-features --no-fail-fast --target=x86_64-pc-windows-msvc -- --show-output --nocapture'
31- # Runs all the tests within Canyon-SQL for Linux targets
32- alias TestsLinux=' cargo test --all-features --no-fail-fast --target=x86_64-unknown-linux-gnu -- --show-output --nocapture'
33-
34- # Runs the integration tests of the project for a Windows target
35- alias IntegrationTestsWin=' cargo test --all-features --no-fail-fast -p tests --target=x86_64-pc-windows-msvc -- --show-output --test-threads=1 --nocapture'
36- alias ITIncludeIgnoredWin=' cargo test --all-features --no-fail-fast -p tests --target=x86_64-pc-windows-msvc -- --show-output --test-threads=1 --nocapture --test-threads=1 --include-ignored'
37- alias SqlServerInitializationWin=' cargo test initialize_sql_server_docker_instance -p tests --all-features --no-fail-fast --target=x86_64-pc-windows-msvc -- --show-output --test-threads=1 --nocapture --include-ignored'
38-
39- # Runs the integration tests of the project for a Linux target
40- alias IntegrationTestsLinux=' cargo test --all-features --no-fail-fast -p tests --target=x86_64-unknown-linux-gnu -- --show-output --test-threads=1 --nocapture'
41- alias ITIncludeIgnoredLinux=' cargo test --all-features --no-fail-fast -p tests --target=x86_64-unknown-linux-gnu -- --show-output --test-threads=1 --nocapture --test-threads=1 --include-ignored'
42- alias SqlServerInitializationLinux=' cargo test initialize_sql_server_docker_instance -p tests --all-features --no-fail-fast --target=x86_64-unknown-linux-gnu -- --show-output --test-threads=1 --nocapture --include-ignored'
43-
44- # -----
45- # Publish Canyon-SQL to the registry with its dependencies
46- alias PublishCanyon=' cargo publish -p canyon_connection && cargo publish -p canyon_crud && cargo publish -p canyon_migrations && cargo publish -p canyon_macros && cargo publish -p canyon_sql_root'
47-
48- # -----
49- # Collects the code coverage for the project (tests must run before this)
50- alias CcEnvVars=' export CARGO_INCREMENTAL=0
51- export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
52- export RUSTDOCFLAGS="-Cpanic=abort"'
53-
54- alias CodeCov=' grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage'
3+ # Canyon-SQL development commands, grouped by database backend and feature set.
4+ #
5+ # Load them from the repository root with:
6+ # . ./bash_aliases.sh
7+ #
8+ # Stable aliases never enable the experimental `migrations` feature. Migration
9+ # aliases are deliberately explicit so they cannot be selected accidentally.
10+
11+ _canyon_unit_test () {
12+ if [ " $2 " = " with-migrations" ]; then
13+ cargo test --workspace --lib --no-default-features --features " $1 " --no-fail-fast -- --show-output --nocapture
14+ else
15+ cargo test --workspace --exclude canyon_migrations --lib --no-default-features --features " $1 " --no-fail-fast -- --show-output --nocapture
16+ fi
17+ }
18+
19+ _canyon_doc_test () {
20+ if [ " $2 " = " with-migrations" ]; then
21+ cargo test --workspace --doc --no-default-features --features " $1 " --no-fail-fast -- --show-output --nocapture
22+ else
23+ cargo test --workspace --exclude canyon_migrations --doc --no-default-features --features " $1 " --no-fail-fast -- --show-output --nocapture
24+ fi
25+ }
26+
27+ _canyon_it_test () {
28+ cargo test -p tests --no-default-features --features " $1 " --no-fail-fast -- --show-output --nocapture --test-threads=1
29+ }
30+
31+ _canyon_test () {
32+ _canyon_unit_test " $1 " " $2 " &&
33+ _canyon_doc_test " $1 " " $2 " &&
34+ _canyon_it_test " $1 "
35+ }
36+
37+ _canyon_check () {
38+ if [ " $2 " = " with-migrations" ]; then
39+ cargo check --workspace --all-targets --no-default-features --features " $1 "
40+ else
41+ cargo check --workspace --exclude canyon_migrations --all-targets --no-default-features --features " $1 "
42+ fi
43+ }
44+
45+ _canyon_build () {
46+ if [ " $2 " = " with-migrations" ]; then
47+ cargo build --workspace --all-targets --no-default-features --features " $1 "
48+ else
49+ cargo build --workspace --exclude canyon_migrations --all-targets --no-default-features --features " $1 "
50+ fi
51+ }
52+
53+ _canyon_clippy () {
54+ if [ " $2 " = " with-migrations" ]; then
55+ cargo clippy --workspace --all-targets --no-default-features --features " $1 " -- -D warnings
56+ else
57+ cargo clippy --workspace --exclude canyon_migrations --all-targets --no-default-features --features " $1 " -- -D warnings
58+ fi
59+ }
60+
61+ _canyon_init_mssql () {
62+ cargo test initialize_sql_server_docker_instance -p tests --no-default-features --features " $1 " --no-fail-fast -- --show-output --nocapture --test-threads=1 --include-ignored
63+ }
64+
65+ # Stable PostgreSQL commands.
66+ alias TEST_PG=' _canyon_test postgres without-migrations'
67+ alias UNIT_TEST_PG=' _canyon_unit_test postgres without-migrations'
68+ alias DOC_TEST_PG=' _canyon_doc_test postgres without-migrations'
69+ alias IT_TEST_PG=' _canyon_it_test postgres'
70+ alias CHECK_PG=' _canyon_check postgres without-migrations'
71+ alias BUILD_PG=' _canyon_build postgres without-migrations'
72+ alias CLIPPY_PG=' _canyon_clippy postgres without-migrations'
73+
74+ # Stable MySQL commands.
75+ alias TEST_MYSQL=' _canyon_test mysql without-migrations'
76+ alias UNIT_TEST_MYSQL=' _canyon_unit_test mysql without-migrations'
77+ alias DOC_TEST_MYSQL=' _canyon_doc_test mysql without-migrations'
78+ alias IT_TEST_MYSQL=' _canyon_it_test mysql'
79+ alias CHECK_MYSQL=' _canyon_check mysql without-migrations'
80+ alias BUILD_MYSQL=' _canyon_build mysql without-migrations'
81+ alias CLIPPY_MYSQL=' _canyon_clippy mysql without-migrations'
82+
83+ # Stable SQL Server commands.
84+ alias TEST_MSSQL=' _canyon_test mssql without-migrations'
85+ alias UNIT_TEST_MSSQL=' _canyon_unit_test mssql without-migrations'
86+ alias DOC_TEST_MSSQL=' _canyon_doc_test mssql without-migrations'
87+ alias IT_TEST_MSSQL=' _canyon_it_test mssql'
88+ alias CHECK_MSSQL=' _canyon_check mssql without-migrations'
89+ alias BUILD_MSSQL=' _canyon_build mssql without-migrations'
90+ alias CLIPPY_MSSQL=' _canyon_clippy mssql without-migrations'
91+ alias INIT_MSSQL=' _canyon_init_mssql mssql'
92+
93+ # Stable commands for all database backends. These do not enable migrations.
94+ alias TEST_ALL=' _canyon_test postgres,mysql,mssql without-migrations'
95+ alias UNIT_TEST_ALL=' _canyon_unit_test postgres,mysql,mssql without-migrations'
96+ alias DOC_TEST_ALL=' _canyon_doc_test postgres,mysql,mssql without-migrations'
97+ alias IT_TEST_ALL=' _canyon_it_test postgres,mysql,mssql'
98+ alias CHECK_ALL=' _canyon_check postgres,mysql,mssql without-migrations'
99+ alias BUILD_ALL=' _canyon_build postgres,mysql,mssql without-migrations'
100+ alias CLIPPY_ALL=' _canyon_clippy postgres,mysql,mssql without-migrations'
101+
102+ # Experimental migrations commands, kept separate from the stable test line.
103+ alias TEST_MIGRATIONS_PG=' _canyon_test postgres,migrations with-migrations'
104+ alias UNIT_TEST_MIGRATIONS_PG=' _canyon_unit_test postgres,migrations with-migrations'
105+ alias DOC_TEST_MIGRATIONS_PG=' _canyon_doc_test postgres,migrations with-migrations'
106+ alias IT_TEST_MIGRATIONS_PG=' _canyon_it_test postgres,migrations'
107+ alias CHECK_MIGRATIONS_PG=' _canyon_check postgres,migrations with-migrations'
108+ alias BUILD_MIGRATIONS_PG=' _canyon_build postgres,migrations with-migrations'
109+ alias CLIPPY_MIGRATIONS_PG=' _canyon_clippy postgres,migrations with-migrations'
110+
111+ alias TEST_MIGRATIONS_MYSQL=' _canyon_test mysql,migrations with-migrations'
112+ alias UNIT_TEST_MIGRATIONS_MYSQL=' _canyon_unit_test mysql,migrations with-migrations'
113+ alias DOC_TEST_MIGRATIONS_MYSQL=' _canyon_doc_test mysql,migrations with-migrations'
114+ alias IT_TEST_MIGRATIONS_MYSQL=' _canyon_it_test mysql,migrations'
115+ alias CHECK_MIGRATIONS_MYSQL=' _canyon_check mysql,migrations with-migrations'
116+ alias BUILD_MIGRATIONS_MYSQL=' _canyon_build mysql,migrations with-migrations'
117+ alias CLIPPY_MIGRATIONS_MYSQL=' _canyon_clippy mysql,migrations with-migrations'
118+
119+ alias TEST_MIGRATIONS_MSSQL=' _canyon_test mssql,migrations with-migrations'
120+ alias UNIT_TEST_MIGRATIONS_MSSQL=' _canyon_unit_test mssql,migrations with-migrations'
121+ alias DOC_TEST_MIGRATIONS_MSSQL=' _canyon_doc_test mssql,migrations with-migrations'
122+ alias IT_TEST_MIGRATIONS_MSSQL=' _canyon_it_test mssql,migrations'
123+ alias CHECK_MIGRATIONS_MSSQL=' _canyon_check mssql,migrations with-migrations'
124+ alias BUILD_MIGRATIONS_MSSQL=' _canyon_build mssql,migrations with-migrations'
125+ alias CLIPPY_MIGRATIONS_MSSQL=' _canyon_clippy mssql,migrations with-migrations'
126+ alias INIT_MIGRATIONS_MSSQL=' _canyon_init_mssql mssql,migrations'
127+
128+ alias TEST_MIGRATIONS_ALL=' _canyon_test postgres,mysql,mssql,migrations with-migrations'
129+ alias UNIT_TEST_MIGRATIONS_ALL=' _canyon_unit_test postgres,mysql,mssql,migrations with-migrations'
130+ alias DOC_TEST_MIGRATIONS_ALL=' _canyon_doc_test postgres,mysql,mssql,migrations with-migrations'
131+ alias IT_TEST_MIGRATIONS_ALL=' _canyon_it_test postgres,mysql,mssql,migrations'
132+ alias CHECK_MIGRATIONS_ALL=' _canyon_check postgres,mysql,mssql,migrations with-migrations'
133+ alias BUILD_MIGRATIONS_ALL=' _canyon_build postgres,mysql,mssql,migrations with-migrations'
134+ alias CLIPPY_MIGRATIONS_ALL=' _canyon_clippy postgres,mysql,mssql,migrations with-migrations'
135+
136+ # Shared tooling.
137+ alias FMT=' cargo fmt --all -- --check'
138+ alias DOCKER_UP=' docker compose -f ./docker/docker-compose.yml up -d'
139+ alias DOCKER_DOWN=' docker compose -f ./docker/docker-compose.yml down'
140+ alias CLEAN_DB_DATA=' rm -rf ./docker/postgres-data ./docker/mysql-data'
141+
142+ # Coverage support. Run the desired TEST_* alias before CODE_COV.
143+ COVERAGE_ENV () {
144+ export CARGO_INCREMENTAL=0
145+ export RUSTFLAGS=" -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
146+ export RUSTDOCFLAGS=" -Cpanic=abort"
147+ }
148+
149+ alias CODE_COV=' grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage'
150+
151+ # Publishing remains intentionally explicit because crate order matters.
152+ alias PUBLISH_CANYON=' cargo publish -p canyon_core && cargo publish -p canyon_crud && cargo publish -p canyon_entities && cargo publish -p canyon_migrations && cargo publish -p canyon_macros && cargo publish -p canyon_sql'
0 commit comments