Skip to content

Commit 99844e5

Browse files
authored
Merge pull request #42 from cipherstash/uninstall
Build and Uninstall
2 parents 9b70f95 + 7cacfce commit 99844e5

18 files changed

+747
-3287
lines changed

.github/workflows/release-eql.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ jobs:
3636
- name: Build EQL release
3737
run: |
3838
just build
39-
mv release/cipherstash-encrypt-dsl.sql release/cipherstash-eql.sql
4039
4140
- name: Publish EQL release artifacts
4241
uses: softprops/action-gh-release@v2
4342
if: startsWith(github.ref, 'refs/tags/')
4443
with:
45-
files: release/cipherstash-eql.sql
44+
files: |
45+
release/cipherstash-eql.sql
46+
release/cipherstash-eql-uninstall.sql

.github/workflows/test-eql.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "Test EQL"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- ".github/workflows/test-eql.yml"
8+
- "sql/*.sql"
9+
10+
pull_request:
11+
branches:
12+
- main
13+
paths:
14+
- ".github/workflows/test-eql.yml"
15+
- "sql/*.sql"
16+
17+
workflow_dispatch:
18+
19+
defaults:
20+
run:
21+
shell: bash -l {0}
22+
23+
jobs:
24+
test:
25+
name: "Test EQL SQL components"
26+
runs-on: ubuntu-24.04
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
postgres-version: [17, 16, 15, 14]
32+
33+
env:
34+
CS_DATABASE__PASSWORD:
35+
CS_DATABASE__PORT: 5432
36+
CS_DATABASE__NAME: test
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: extractions/setup-just@v1
42+
43+
- uses: ankane/setup-postgres@v1
44+
with:
45+
postgres-version: ${{ matrix.postgres-version }}
46+
database: ${{ env.CS_DATABASE__NAME }}
47+
48+
- name: Test EQL
49+
run: |
50+
just build test
51+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,5 @@ cipherstash-proxy.toml
183183

184184
# build artifacts
185185
release/
186+
187+
.mise.*

justfile

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,68 @@ set dotenv-load
22
set positional-arguments
33

44

5-
test_dsl:
5+
test:
66
#!/usr/bin/env bash
77
set -euxo pipefail
88

9-
PGPASSWORD=$CS_DATABASE__PASSWORD dropdb --force --if-exists --username $CS_DATABASE__USERNAME --port $CS_DATABASE__PORT cs_migrator_test
10-
PGPASSWORD=$CS_DATABASE__PASSWORD createdb --username $CS_DATABASE__USERNAME --port $CS_DATABASE__PORT cs_migrator_test
9+
just build
10+
just reset
1111

12-
connection_url=postgresql://$CS_DATABASE__USERNAME:@localhost:$CS_DATABASE__PORT/cs_migrator_test
13-
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f sql/dsl-core.sql
14-
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f sql/dsl-config-schema.sql
15-
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f sql/dsl-config-functions.sql
16-
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f sql/dsl-encryptindex.sql
12+
connection_url=postgresql://${CS_DATABASE__USERNAME:-$USER}:@localhost:$CS_DATABASE__PORT/$CS_DATABASE__NAME
1713

1814
# tests
1915
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f tests/core.sql
2016
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f tests/config.sql
2117
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f tests/encryptindex.sql
2218

23-
dropdb --username $CS_DATABASE__USERNAME --port $CS_DATABASE__PORT cs_migrator_test
19+
# Uninstall
20+
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f release/cipherstash-encrypt-uninstall.sql
21+
2422

2523

2624
build:
2725
#!/usr/bin/env bash
2826
set -euxo pipefail
2927

30-
cat sql/database-extensions/postgresql/install.sql sql/ore-cllw.sql sql/ste-vec.sql sql/dsl-core.sql sql/dsl-config-schema.sql sql/dsl-config-functions.sql sql/dsl-encryptindex.sql > release/cipherstash-encrypt-dsl.sql
28+
mkdir -p release
29+
30+
rm -f release/cipherstash-encrypt-uninstall.sql
31+
rm -f release/cipherstash-encrypt.sql
32+
33+
# Collect all the drops
34+
# In reverse order (tac) so that we drop the constraints before the tables
35+
grep -h -E '^(DROP|ALTER DOMAIN [^ ]+ DROP CONSTRAINT)' sql/0*-*.sql | tac > release/cipherstash-encrypt-tmp-drop.sql
36+
# types are always last
37+
cat sql/666-drop_types.sql >> release/cipherstash-encrypt-tmp-drop.sql
38+
39+
40+
# Build cipherstash-encrypt.sql
41+
# drop everything first
42+
cat release/cipherstash-encrypt-tmp-drop.sql > release/cipherstash-encrypt.sql
43+
# cat the rest of the sql files
44+
cat sql/0*-*.sql >> release/cipherstash-encrypt.sql
45+
46+
47+
# Build cipherstash-encrypt-uninstall.sql
48+
# prepend the drops to the main sql file
49+
cat release/cipherstash-encrypt-tmp-drop.sql >> release/cipherstash-encrypt-uninstall.sql
50+
# uninstall renames configuration table
51+
cat sql/666-rename_configuration_table.sql >> release/cipherstash-encrypt-uninstall.sql
52+
53+
# remove the drop file
54+
rm release/cipherstash-encrypt-tmp-drop.sql
55+
56+
57+
reset:
58+
#!/usr/bin/env bash
59+
set -euxo pipefail
60+
61+
PGPASSWORD=$CS_DATABASE__PASSWORD dropdb --force --if-exists --username ${CS_DATABASE__USERNAME:-$USER} --port $CS_DATABASE__PORT $CS_DATABASE__NAME
62+
PGPASSWORD=$CS_DATABASE__PASSWORD createdb --username ${CS_DATABASE__USERNAME:-$USER} --port $CS_DATABASE__PORT $CS_DATABASE__NAME
63+
64+
connection_url=postgresql://${CS_DATABASE__USERNAME:-$USER}:@localhost:$CS_DATABASE__PORT/$CS_DATABASE__NAME
65+
66+
PGPASSWORD=$CS_DATABASE__PASSWORD psql $connection_url -f release/cipherstash-encrypt.sql
3167

3268

3369
psql:

0 commit comments

Comments
 (0)