Skip to content

feat: Add cs_eql_version function #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release-eql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Build EQL release
run: |
mise run build
mise run build --version ${{github.event.release.tag_name}}

- name: Upload EQL artifacts
uses: actions/upload-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

sql/000-version.sql

# Logs

logs
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions tasks/000-version-template.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DROP FUNCTION IF EXISTS cs_eql_version();

CREATE FUNCTION cs_eql_version()
RETURNS text
IMMUTABLE STRICT PARALLEL SAFE
AS $$
SELECT '$RELEASE_VERSION';
$$ LANGUAGE SQL;

7 changes: 7 additions & 0 deletions tasks/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#MISE alias="b"
#MISE sources=["sql/*.sql"]
#MISE outputs=["release/cipherstash-encrypt.sql","release/cipherstash-encrypt-uninstall.sql"]
#USAGE flag "--version <version>" help="Specify release version of EQL" default="DEV"

#!/bin/bash

Expand All @@ -13,6 +14,12 @@ mkdir -p release
rm -f release/cipherstash-encrypt-uninstall.sql
rm -f release/cipherstash-encrypt.sql

rm -f sql/000-version.sql

RELEASE_VERSION=${usage_version}
sed "s/\$RELEASE_VERSION/$RELEASE_VERSION/g" tasks/000-version-template.sql > sql/000-version.sql


# Collect all the drops
# In reverse order (tac) so that we drop the constraints before the tables
grep -h -E '^(DROP)' sql/0*-*.sql | tac > release/cipherstash-encrypt-tmp-drop-install.sql
Expand Down
1 change: 1 addition & 0 deletions tasks/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ mise run build
mise run reset --postgres ${POSTGRES_VERSION}

# tests
run_test tests/version.sql
run_test tests/core.sql
run_test tests/core-functions.sql
run_test tests/config.sql
Expand Down
8 changes: 8 additions & 0 deletions tests/version.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\set ON_ERROR_STOP on

DO $$
BEGIN
ASSERT (SELECT true WHERE cs_eql_version() = 'DEV');

END;
$$ LANGUAGE plpgsql;