Skip to content

Commit 0188985

Browse files
committed
Add mise tasks
1 parent d489193 commit 0188985

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

mise.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[settings]
2+
# Config for test environments
3+
# Can be invoked with: mise --env tcp run <task>
4+
# trusted_config_paths = [
5+
# "./tests/mise.toml",
6+
# "./tests/mise.tcp.toml",
7+
# "./tests/mise.tls.toml",
8+
# ]
9+
[task_config]
10+
includes = ["tasks"]
11+
12+
13+
[env]
14+
# Default configuration for running cipherstash-proxy out of the box
15+
CS_DATABASE__NAME = "cipherstash"
16+
CS_DATABASE__USERNAME = "cipherstash"
17+
CS_DATABASE__PASSWORD = "password"
18+
CS_DATABASE__HOST = "localhost"
19+
CS_DATABASE__PORT = "5532"

tasks/build.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Build SQL into single release file"
3+
set -euxo pipefail
4+
5+
mkdir -p release
6+
7+
rm -f release/cipherstash-encrypt-uninstall.sql
8+
rm -f release/cipherstash-encrypt.sql
9+
10+
# Collect all the drops
11+
# In reverse order (tac) so that we drop the constraints before the tables
12+
grep -h -E '^(DROP)' sql/0*-*.sql | tac > release/cipherstash-encrypt-tmp-drop-install.sql
13+
# types are always last
14+
cat sql/666-drop_types.sql >> release/cipherstash-encrypt-tmp-drop-install.sql
15+
16+
17+
# Build cipherstash-encrypt.sql
18+
# drop everything first
19+
cat release/cipherstash-encrypt-tmp-drop-install.sql > release/cipherstash-encrypt.sql
20+
# cat the rest of the sql files
21+
cat sql/0*-*.sql >> release/cipherstash-encrypt.sql
22+
23+
# Collect all the drops
24+
# In reverse order (tac) so that we drop the constraints before the tables
25+
grep -h -E '^(DROP|ALTER DOMAIN [^ ]+ DROP CONSTRAINT)' sql/0*-*.sql | tac > release/cipherstash-encrypt-tmp-drop-uninstall.sql
26+
# types are always last
27+
cat sql/666-drop_types.sql >> release/cipherstash-encrypt-tmp-drop-uninstall.sql
28+
29+
30+
# Build cipherstash-encrypt-uninstall.sql
31+
# prepend the drops to the main sql file
32+
cat release/cipherstash-encrypt-tmp-drop-uninstall.sql >> release/cipherstash-encrypt-uninstall.sql
33+
# uninstall renames configuration table
34+
cat sql/666-rename_configuration_table.sql >> release/cipherstash-encrypt-uninstall.sql
35+
36+
# remove the drop file
37+
rm release/cipherstash-encrypt-tmp-drop-install.sql
38+
rm release/cipherstash-encrypt-tmp-drop-uninstall.sql

tasks/reset.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Clean install of EQL"
3+
set -euxo pipefail
4+
5+
# PGPASSWORD=$CS_DATABASE__PASSWORD dropdb --force --if-exists --username ${CS_DATABASE__USERNAME:-$USER} --port $CS_DATABASE__PORT $CS_DATABASE__NAME
6+
# PGPASSWORD=$CS_DATABASE__PASSWORD createdb --username ${CS_DATABASE__USERNAME:-$USER} --port $CS_DATABASE__PORT $CS_DATABASE__NAME
7+
8+
connection_url=postgresql://${CS_DATABASE__USERNAME:-$USER}:@localhost:$CS_DATABASE__PORT/$CS_DATABASE__NAME
9+
10+
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f release/cipherstash-encrypt.sql

tasks/test.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Build, reset and run test"
3+
set -euxo pipefail
4+
5+
mise run build
6+
mise run reset
7+
8+
connection_url=postgresql://${CS_DATABASE__USERNAME:-$USER}:@localhost:$CS_DATABASE__PORT/$CS_DATABASE__NAME
9+
10+
# tests
11+
# PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f tests/core.sql
12+
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f tests/core-functions.sql
13+
# PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f tests/config.sql
14+
# PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f tests/encryptindex.sql
15+
16+
# Uninstall
17+
# PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f release/cipherstash-encrypt-uninstall.sql
18+

0 commit comments

Comments
 (0)