Skip to content

Commit 35a153f

Browse files
committed
Merge branch 'project_dir_parameter'
2 parents 9a01c93 + 1fd8a45 commit 35a153f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ inputs:
1010
warehouse-type:
1111
description: 'The type of your warehouse (snowflake, bigquery, redshift, etc)'
1212
required: true
13+
project-dir:
14+
description: |
15+
The path to your project dir.
16+
You should pass this parameter if the dbt project dir is not located in the current directory (normally the
17+
repository root) - the EDR command will run with this directory as the working directory.
18+
required: false
1319
profiles-yml:
1420
description: |
1521
The content of dbt's `profiles.yml` with the `elementary` profile.

entrypoint.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setup_env(
3333
Path("/tmp/gcs_keyfile.json").write_text(gcs_keyfile)
3434

3535

36-
def install_edr(adapter: str):
36+
def install_edr(adapter: str, project_dir: Optional[str]):
3737
logging.info("Getting Elementary dbt package version.")
3838
try:
3939
dbt_pkg_ver = (
@@ -48,6 +48,7 @@ def install_edr(adapter: str):
4848
],
4949
check=True,
5050
capture_output=True,
51+
cwd=project_dir
5152
)
5253
.stdout.decode()
5354
.strip()
@@ -84,13 +85,14 @@ def install_edr(adapter: str):
8485
)
8586

8687

87-
def run_edr(edr_command: str):
88+
def run_edr(edr_command: str, project_dir: Optional[str]):
8889
logging.info(f"Running the edr command.")
89-
subprocess.run(edr_command, shell=True, check=True)
90+
subprocess.run(edr_command, shell=True, check=True, cwd=project_dir)
9091

9192

9293
class Args(BaseModel):
9394
adapter: str
95+
project_dir: Optional[str]
9496
profiles_yml: Optional[str]
9597
edr_command: str
9698
bigquery_keyfile: Optional[str]
@@ -100,16 +102,17 @@ class Args(BaseModel):
100102
def main():
101103
args = Args(
102104
adapter=os.getenv("INPUT_WAREHOUSE-TYPE"),
105+
project_dir=os.getenv("INPUT_PROJECT-DIR"),
103106
profiles_yml=os.getenv("INPUT_PROFILES-YML"),
104107
edr_command=os.getenv("INPUT_EDR-COMMAND"),
105108
bigquery_keyfile=os.getenv("INPUT_BIGQUERY-KEYFILE"),
106109
gcs_keyfile=os.getenv("INPUT_GCS-KEYFILE"),
107110
)
108111
install_dbt(args.adapter)
109112
setup_env(args.profiles_yml, args.bigquery_keyfile, args.gcs_keyfile)
110-
install_edr(args.adapter)
113+
install_edr(args.adapter, args.project_dir)
111114
try:
112-
run_edr(args.edr_command)
115+
run_edr(args.edr_command, args.project_dir)
113116
except subprocess.CalledProcessError:
114117
logging.exception(f"Failed to run the edr command.")
115118
raise

0 commit comments

Comments
 (0)