From 586547189711d167476ae589f6b6258da49278a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 1 Aug 2024 08:22:48 -0600 Subject: [PATCH 1/6] ci: Add release workflow --- .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ca5510f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +name: Release + +on: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: hynek/build-and-inspect-python-package@v2 + + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + needs: [build] + environment: + name: pypi + url: https://pypi.org/p/dbt-ext + if: startsWith(github.ref, 'refs/tags/') + permissions: + id-token: write # Needed for OIDC PyPI publishing + steps: + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + - name: Publish + uses: pypa/gh-action-pypi-publish@v1.9.0 + + upload-to-release: + name: Upload files to release + runs-on: ubuntu-latest + needs: [build] + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write # Needed for uploading files to the release + id-token: write # Needed for attestations + attestations: write # Needed for attestations + + steps: + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + - name: Upload wheel and sdist to release + uses: svenstaro/upload-release-action@v2 + with: + file: dist/singer_sdk* + tag: ${{ github.ref }} + overwrite: true + file_glob: true + - uses: actions/attest-build-provenance@v1 + id: attest + with: + subject-path: "./dist/edk*" + - name: Upload attestations to release + uses: svenstaro/upload-release-action@v2 + with: + file: ${{ steps.attest.outputs.bundle-path }} + tag: ${{ github.ref }} + overwrite: true + asset_name: attestations.intoto.jsonl From f94cf94de50b0628638b9ce5e24336f7cbb6504a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 1 Aug 2024 08:26:54 -0600 Subject: [PATCH 2/6] Use files as package data, not additional package --- files_dbt_ext/bundle/__init__.py | 0 files_dbt_ext/bundle/transform/__init__.py | 0 files_dbt_ext/profiles/__init__.py | 0 pyproject.toml | 1 - 4 files changed, 1 deletion(-) delete mode 100644 files_dbt_ext/bundle/__init__.py delete mode 100644 files_dbt_ext/bundle/transform/__init__.py delete mode 100644 files_dbt_ext/profiles/__init__.py diff --git a/files_dbt_ext/bundle/__init__.py b/files_dbt_ext/bundle/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/files_dbt_ext/bundle/transform/__init__.py b/files_dbt_ext/bundle/transform/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/files_dbt_ext/profiles/__init__.py b/files_dbt_ext/profiles/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyproject.toml b/pyproject.toml index f7b8524..5416eff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,6 @@ license = "Apache-2.0" packages = [ { include = "dbt_ext" }, - { include = "files_dbt_ext" }, ] # If you need to static assets with your extension, you can add them here. From 3942c63573f60aecf2f307bf9be2aaf5b44dc3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 1 Aug 2024 08:41:06 -0600 Subject: [PATCH 3/6] Move files to package --- dbt_ext/extension.py | 12 ++++++++---- .../models/.gitkeep => dbt_ext/files/__init__.py | 0 .../files}/bundle/transform/.gitignore | 0 .../files}/bundle/transform/dbt_project.yml | 0 dbt_ext/files/bundle/transform/models/.gitkeep | 0 .../files}/profiles/athena/profiles.yml | 0 .../files}/profiles/bigquery/profiles.yaml | 0 .../files}/profiles/duckdb/profiles.yml | 0 .../files}/profiles/postgres/profiles.yml | 0 .../files}/profiles/redshift/profiles.yml | 0 .../files}/profiles/snowflake/profiles.yml | 0 11 files changed, 8 insertions(+), 4 deletions(-) rename files_dbt_ext/bundle/transform/models/.gitkeep => dbt_ext/files/__init__.py (100%) rename {files_dbt_ext => dbt_ext/files}/bundle/transform/.gitignore (100%) rename {files_dbt_ext => dbt_ext/files}/bundle/transform/dbt_project.yml (100%) create mode 100644 dbt_ext/files/bundle/transform/models/.gitkeep rename {files_dbt_ext => dbt_ext/files}/profiles/athena/profiles.yml (100%) rename {files_dbt_ext => dbt_ext/files}/profiles/bigquery/profiles.yaml (100%) rename {files_dbt_ext => dbt_ext/files}/profiles/duckdb/profiles.yml (100%) rename {files_dbt_ext => dbt_ext/files}/profiles/postgres/profiles.yml (100%) rename {files_dbt_ext => dbt_ext/files}/profiles/redshift/profiles.yml (100%) rename {files_dbt_ext => dbt_ext/files}/profiles/snowflake/profiles.yml (100%) diff --git a/dbt_ext/extension.py b/dbt_ext/extension.py index b42600c..b47b694 100644 --- a/dbt_ext/extension.py +++ b/dbt_ext/extension.py @@ -14,10 +14,12 @@ from meltano.edk.process import Invoker, log_subprocess_error from meltano.edk.types import ExecArg +from . import files + try: - from importlib.resources import files as ir_files + from importlib import resources except ImportError: - from importlib_resources import files as ir_files + import importlib_resources as resources log = structlog.get_logger() @@ -130,7 +132,9 @@ def initialize(self, force: bool = False) -> None: log.info("creating dbt project directory", path=self.dbt_project_dir) self.dbt_project_dir.mkdir(parents=True, exist_ok=True) - for entry in ir_files("files_dbt_ext.bundle.transform").iterdir(): + files_dir = resources.files(files) + + for entry in files_dir.joinpath("bundle", "transform").iterdir(): if entry.name == "__pycache__": continue log.debug(f"deploying {entry.name}", entry=entry, dst=self.dbt_project_dir) @@ -145,7 +149,7 @@ def initialize(self, force: bool = False) -> None: log.info("creating dbt profiles directory", path=self.dbt_profiles_dir) self.dbt_profiles_dir.mkdir(parents=True, exist_ok=True) - for entry in ir_files("files_dbt_ext.profiles").iterdir(): + for entry in files_dir.joinpath("profiles").iterdir(): if entry.name == self.dbt_ext_type and entry.is_dir(): log.debug( f"deploying {entry.name} profile", diff --git a/files_dbt_ext/bundle/transform/models/.gitkeep b/dbt_ext/files/__init__.py similarity index 100% rename from files_dbt_ext/bundle/transform/models/.gitkeep rename to dbt_ext/files/__init__.py diff --git a/files_dbt_ext/bundle/transform/.gitignore b/dbt_ext/files/bundle/transform/.gitignore similarity index 100% rename from files_dbt_ext/bundle/transform/.gitignore rename to dbt_ext/files/bundle/transform/.gitignore diff --git a/files_dbt_ext/bundle/transform/dbt_project.yml b/dbt_ext/files/bundle/transform/dbt_project.yml similarity index 100% rename from files_dbt_ext/bundle/transform/dbt_project.yml rename to dbt_ext/files/bundle/transform/dbt_project.yml diff --git a/dbt_ext/files/bundle/transform/models/.gitkeep b/dbt_ext/files/bundle/transform/models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/files_dbt_ext/profiles/athena/profiles.yml b/dbt_ext/files/profiles/athena/profiles.yml similarity index 100% rename from files_dbt_ext/profiles/athena/profiles.yml rename to dbt_ext/files/profiles/athena/profiles.yml diff --git a/files_dbt_ext/profiles/bigquery/profiles.yaml b/dbt_ext/files/profiles/bigquery/profiles.yaml similarity index 100% rename from files_dbt_ext/profiles/bigquery/profiles.yaml rename to dbt_ext/files/profiles/bigquery/profiles.yaml diff --git a/files_dbt_ext/profiles/duckdb/profiles.yml b/dbt_ext/files/profiles/duckdb/profiles.yml similarity index 100% rename from files_dbt_ext/profiles/duckdb/profiles.yml rename to dbt_ext/files/profiles/duckdb/profiles.yml diff --git a/files_dbt_ext/profiles/postgres/profiles.yml b/dbt_ext/files/profiles/postgres/profiles.yml similarity index 100% rename from files_dbt_ext/profiles/postgres/profiles.yml rename to dbt_ext/files/profiles/postgres/profiles.yml diff --git a/files_dbt_ext/profiles/redshift/profiles.yml b/dbt_ext/files/profiles/redshift/profiles.yml similarity index 100% rename from files_dbt_ext/profiles/redshift/profiles.yml rename to dbt_ext/files/profiles/redshift/profiles.yml diff --git a/files_dbt_ext/profiles/snowflake/profiles.yml b/dbt_ext/files/profiles/snowflake/profiles.yml similarity index 100% rename from files_dbt_ext/profiles/snowflake/profiles.yml rename to dbt_ext/files/profiles/snowflake/profiles.yml From 99dd3691444e3dfad9f426b2cafe214fafa3bfcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 1 Aug 2024 08:42:37 -0600 Subject: [PATCH 4/6] Rename to "dbt_files" --- dbt_ext/{files => dbt_files}/__init__.py | 0 dbt_ext/{files => dbt_files}/bundle/transform/.gitignore | 0 dbt_ext/{files => dbt_files}/bundle/transform/dbt_project.yml | 0 dbt_ext/{files => dbt_files}/bundle/transform/models/.gitkeep | 0 dbt_ext/{files => dbt_files}/profiles/athena/profiles.yml | 0 dbt_ext/{files => dbt_files}/profiles/bigquery/profiles.yaml | 0 dbt_ext/{files => dbt_files}/profiles/duckdb/profiles.yml | 0 dbt_ext/{files => dbt_files}/profiles/postgres/profiles.yml | 0 dbt_ext/{files => dbt_files}/profiles/redshift/profiles.yml | 0 dbt_ext/{files => dbt_files}/profiles/snowflake/profiles.yml | 0 dbt_ext/extension.py | 4 ++-- 11 files changed, 2 insertions(+), 2 deletions(-) rename dbt_ext/{files => dbt_files}/__init__.py (100%) rename dbt_ext/{files => dbt_files}/bundle/transform/.gitignore (100%) rename dbt_ext/{files => dbt_files}/bundle/transform/dbt_project.yml (100%) rename dbt_ext/{files => dbt_files}/bundle/transform/models/.gitkeep (100%) rename dbt_ext/{files => dbt_files}/profiles/athena/profiles.yml (100%) rename dbt_ext/{files => dbt_files}/profiles/bigquery/profiles.yaml (100%) rename dbt_ext/{files => dbt_files}/profiles/duckdb/profiles.yml (100%) rename dbt_ext/{files => dbt_files}/profiles/postgres/profiles.yml (100%) rename dbt_ext/{files => dbt_files}/profiles/redshift/profiles.yml (100%) rename dbt_ext/{files => dbt_files}/profiles/snowflake/profiles.yml (100%) diff --git a/dbt_ext/files/__init__.py b/dbt_ext/dbt_files/__init__.py similarity index 100% rename from dbt_ext/files/__init__.py rename to dbt_ext/dbt_files/__init__.py diff --git a/dbt_ext/files/bundle/transform/.gitignore b/dbt_ext/dbt_files/bundle/transform/.gitignore similarity index 100% rename from dbt_ext/files/bundle/transform/.gitignore rename to dbt_ext/dbt_files/bundle/transform/.gitignore diff --git a/dbt_ext/files/bundle/transform/dbt_project.yml b/dbt_ext/dbt_files/bundle/transform/dbt_project.yml similarity index 100% rename from dbt_ext/files/bundle/transform/dbt_project.yml rename to dbt_ext/dbt_files/bundle/transform/dbt_project.yml diff --git a/dbt_ext/files/bundle/transform/models/.gitkeep b/dbt_ext/dbt_files/bundle/transform/models/.gitkeep similarity index 100% rename from dbt_ext/files/bundle/transform/models/.gitkeep rename to dbt_ext/dbt_files/bundle/transform/models/.gitkeep diff --git a/dbt_ext/files/profiles/athena/profiles.yml b/dbt_ext/dbt_files/profiles/athena/profiles.yml similarity index 100% rename from dbt_ext/files/profiles/athena/profiles.yml rename to dbt_ext/dbt_files/profiles/athena/profiles.yml diff --git a/dbt_ext/files/profiles/bigquery/profiles.yaml b/dbt_ext/dbt_files/profiles/bigquery/profiles.yaml similarity index 100% rename from dbt_ext/files/profiles/bigquery/profiles.yaml rename to dbt_ext/dbt_files/profiles/bigquery/profiles.yaml diff --git a/dbt_ext/files/profiles/duckdb/profiles.yml b/dbt_ext/dbt_files/profiles/duckdb/profiles.yml similarity index 100% rename from dbt_ext/files/profiles/duckdb/profiles.yml rename to dbt_ext/dbt_files/profiles/duckdb/profiles.yml diff --git a/dbt_ext/files/profiles/postgres/profiles.yml b/dbt_ext/dbt_files/profiles/postgres/profiles.yml similarity index 100% rename from dbt_ext/files/profiles/postgres/profiles.yml rename to dbt_ext/dbt_files/profiles/postgres/profiles.yml diff --git a/dbt_ext/files/profiles/redshift/profiles.yml b/dbt_ext/dbt_files/profiles/redshift/profiles.yml similarity index 100% rename from dbt_ext/files/profiles/redshift/profiles.yml rename to dbt_ext/dbt_files/profiles/redshift/profiles.yml diff --git a/dbt_ext/files/profiles/snowflake/profiles.yml b/dbt_ext/dbt_files/profiles/snowflake/profiles.yml similarity index 100% rename from dbt_ext/files/profiles/snowflake/profiles.yml rename to dbt_ext/dbt_files/profiles/snowflake/profiles.yml diff --git a/dbt_ext/extension.py b/dbt_ext/extension.py index b47b694..04e4360 100644 --- a/dbt_ext/extension.py +++ b/dbt_ext/extension.py @@ -14,7 +14,7 @@ from meltano.edk.process import Invoker, log_subprocess_error from meltano.edk.types import ExecArg -from . import files +from . import dbt_files try: from importlib import resources @@ -132,7 +132,7 @@ def initialize(self, force: bool = False) -> None: log.info("creating dbt project directory", path=self.dbt_project_dir) self.dbt_project_dir.mkdir(parents=True, exist_ok=True) - files_dir = resources.files(files) + files_dir = resources.files(dbt_files) for entry in files_dir.joinpath("bundle", "transform").iterdir(): if entry.name == "__pycache__": From 69db7335260dca59ad0ef835ac34ede8b4fed9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 1 Aug 2024 08:45:05 -0600 Subject: [PATCH 5/6] Add name to job --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca5510f..77222e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,7 @@ on: jobs: build: + name: Build and Inspect runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 4c58af5d87ea39d06b7f7000ff8dc00b3b380b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 1 Aug 2024 08:48:25 -0600 Subject: [PATCH 6/6] Add docstring --- dbt_ext/dbt_files/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_ext/dbt_files/__init__.py b/dbt_ext/dbt_files/__init__.py index e69de29..c05b4a1 100644 --- a/dbt_ext/dbt_files/__init__.py +++ b/dbt_ext/dbt_files/__init__.py @@ -0,0 +1 @@ +"""Files used to initialize a dbt project."""