diff --git a/.github/workflows/dbt_test.yml b/.github/workflows/dbt_test.yml index 15656bd..044f3f0 100644 --- a/.github/workflows/dbt_test.yml +++ b/.github/workflows/dbt_test.yml @@ -1,6 +1,31 @@ name: test udfs on: + push: + branches: + - "main" + workflow_dispatch: + inputs: + environment: + type: choice + description: DBT Run Environment + required: true + options: + - dev + - prod + default: dev + warehouse: + type: choice + description: Snowflake warehouse + required: true + options: + - DBT + - DBT_CLOUD + default: DBT + dbt_command: + type: string + description: 'DBT Run Command' + required: true schedule: # Runs “Daily at midnight GMT” (see https://crontab.guru) - cron: '0 0 * * *' @@ -22,11 +47,11 @@ concurrency: group: ${{ github.workflow }} jobs: - run_tests: + scheduled_job: + if: ${{ github.event_name == 'schedule' }} || github.event_name == 'push' runs-on: ubuntu-latest environment: name: workflow_prod - steps: - uses: actions/checkout@v3 @@ -44,8 +69,26 @@ jobs: run: | dbt test --selector test_udfs - - name: Store logs - uses: actions/upload-artifact@v3 + manual_job: + if: ${{ github.event_name == 'workflow_dispatch' }} + runs-on: ubuntu-latest + env: + WAREHOUSE: ${{ inputs.warehouse }} + environment: + name: workflow_${{ inputs.environment }} + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 with: - name: dbt-logs - path: logs \ No newline at end of file + python-version: "3.10" + cache: "pip" + + + - name: install dependencies + run: | + pip install -r requirements.txt + dbt deps + - name: Run DBT Jobs + run: | + dbt test --selector test_udfs diff --git a/macros/marketplace/stakingrewards/udfs.yaml.sql b/macros/marketplace/stakingrewards/udfs.yaml.sql new file mode 100644 index 0000000..5d2b6b6 --- /dev/null +++ b/macros/marketplace/stakingrewards/udfs.yaml.sql @@ -0,0 +1,23 @@ +{% macro config_stakingrewards_udfs(schema_name = "stakingrewards", utils_schema_name="stakingrewards_utils") -%} +{# + This macro is used to generate the StakingRewards Base endpoints + #} + +- name: {{ schema_name -}}.query + signature: + - [QUERY, OBJECT, The GraphQL query] + return_type: + - "VARIANT" + options: | + COMMENT = $$Used to issue a Graphql Query to the StakingRewards API. [StakingRewards docs here](https://api-docs.stakingrewards.com/api-docs/get-started/quick-start-guide).$$ + sql: | + SELECT + live.udf_api( + 'POST', + 'https:/api.stakingrewards.com/public/query', + {'X-API-KEY': '{API_KEY}'}, + QUERY, + '_FSC_SYS/STAKINGREWARDS' + ) as response + +{% endmacro %} \ No newline at end of file diff --git a/models/deploy/marketplace/stakingrewards/stakingrewards__ .yml b/models/deploy/marketplace/stakingrewards/stakingrewards__ .yml new file mode 100644 index 0000000..f6ccf36 --- /dev/null +++ b/models/deploy/marketplace/stakingrewards/stakingrewards__ .yml @@ -0,0 +1,22 @@ +version: 2 +models: + - name: stakingrewards__ + columns: + - name: query + tests: + - test_udf: + name: test_stakingrewards__query_status_200 + args: > + { + 'query': '{ + assets(where: {symbols: ["ETH"]}, limit: 1) { + name + slug + description + symbol + } + }', + 'variables': {} + } + assertions: + - result:status_code = 200 diff --git a/models/deploy/marketplace/stakingrewards/stakingrewards__.sql b/models/deploy/marketplace/stakingrewards/stakingrewards__.sql new file mode 100644 index 0000000..062a11b --- /dev/null +++ b/models/deploy/marketplace/stakingrewards/stakingrewards__.sql @@ -0,0 +1,5 @@ +-- depends_on: {{ ref('live') }} +{%- set configs = [ + config_stakingrewards_udfs, + ] -%} +{{- ephemeral_deploy_marketplace(configs) -}} \ No newline at end of file