From 326b55d6840135f0f3379eab82f38bbd7baf7cb1 Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Wed, 22 Jan 2025 10:04:42 +0200 Subject: [PATCH 1/3] Use `github.ref_name` for codegate version (#707) The auto-generated tag was used to set the codegate version. This had relevant information, but is not the version we actually wanted to set. This instead uses github action context variables to set the version appropriately. For Releases (the trigger for the image publish job) the `ref_name` refers to the tag the release had attached. This is what's used. Signed-off-by: Juan Antonio Osorio --- .github/workflows/image-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image-publish.yml b/.github/workflows/image-publish.yml index c4117d4e..a4f8cd8a 100644 --- a/.github/workflows/image-publish.yml +++ b/.github/workflows/image-publish.yml @@ -89,7 +89,7 @@ jobs: cache-to: type=gha,mode=max build-args: | LATEST_RELEASE=${{ env.LATEST_RELEASE }} - CODEGATE_VERSION=${{ steps.version-string.outputs.tag }} + CODEGATE_VERSION=${{ github.ref_name }} - name: Capture Image Digest id: image-digest run: | From a2b53b37211a9d6d195a3859de0599a782e1d2af Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Wed, 22 Jan 2025 10:04:57 +0200 Subject: [PATCH 2/3] Fetch tags to get appropriate codegate version on dev (#705) We need to rely on the tags to get the right version for codegate. This fetches them before building the image locally. Note that this is only for development. Signed-off-by: Juan Antonio Osorio --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 157d01bf..0a0999ba 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,9 @@ build: clean test poetry build image-build: + @echo "Fetching tags to get right version number..." + @git fetch -t + @echo "Building container..." DOCKER_BUILDKIT=1 $(CONTAINER_BUILD) \ -f Dockerfile \ --build-arg LATEST_RELEASE=$(shell curl -s "https://api.github.com/repos/stacklok/codegate-ui/releases/latest" | grep '"zipball_url":' | cut -d '"' -f 4) \ From 868afe6f56c60a6aecd918cfc301219a62f572f1 Mon Sep 17 00:00:00 2001 From: Alejandro Ponce de Leon Date: Wed, 22 Jan 2025 10:07:09 +0200 Subject: [PATCH 3/3] Added pragma on file connections and DROP TABLE IF EXISTS (#706) * Added pragma on file connections and DROP TABLE IF EXISTS * Changed comment * Formatting changes * Changes to PRAGMA --- migrations/env.py | 1 + .../2025_01_21_0820-4dec3e456c9e_add_on_delete_cascade.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/migrations/env.py b/migrations/env.py index 0729ead0..330a20e0 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -35,6 +35,7 @@ def run_migrations_offline() -> None: target_metadata=target_metadata, literal_binds=True, dialect_opts={"paramstyle": "named"}, + transactional_ddl=True, ) with context.begin_transaction(): diff --git a/migrations/versions/2025_01_21_0820-4dec3e456c9e_add_on_delete_cascade.py b/migrations/versions/2025_01_21_0820-4dec3e456c9e_add_on_delete_cascade.py index 5aaa4467..99a98404 100644 --- a/migrations/versions/2025_01_21_0820-4dec3e456c9e_add_on_delete_cascade.py +++ b/migrations/versions/2025_01_21_0820-4dec3e456c9e_add_on_delete_cascade.py @@ -21,6 +21,7 @@ def upgrade() -> None: # To add ON DELETE CASCADE to the foreign key constraint, we need to # rename the table, create a new table with the constraint, and copy # the data over. + op.execute("DROP TABLE IF EXISTS _prompts_old;") op.execute("ALTER TABLE prompts RENAME TO _prompts_old;") op.execute( """ @@ -39,6 +40,7 @@ def upgrade() -> None: op.execute("DROP TABLE _prompts_old;") # Doing the same for the sessions table + op.execute("DROP TABLE IF EXISTS _sessions_old;") op.execute("ALTER TABLE sessions RENAME TO _sessions_old;") op.execute( """ @@ -54,6 +56,7 @@ def upgrade() -> None: op.execute("DROP TABLE _sessions_old;") # Doing the same for the output table + op.execute("DROP TABLE IF EXISTS _outputs_old;") op.execute("ALTER TABLE outputs RENAME TO _outputs_old;") op.execute( """ @@ -70,6 +73,7 @@ def upgrade() -> None: op.execute("DROP TABLE _outputs_old;") # Doing the same for the alerts table + op.execute("DROP TABLE IF EXISTS _alerts_old;") op.execute("ALTER TABLE alerts RENAME TO _alerts_old;") op.execute( """ @@ -89,7 +93,7 @@ def upgrade() -> None: op.execute("DROP TABLE _alerts_old;") # Dropping unused table - op.execute("DROP TABLE settings;") + op.execute("DROP TABLE IF EXISTS settings;") # Create indexes for foreign keys op.execute("CREATE INDEX idx_outputs_prompt_id ON outputs(prompt_id);")