StakingRewards Integration (#38)

This commit is contained in:
Jim Myers 2023-08-15 12:48:51 -04:00 committed by GitHub
parent 5f4077015e
commit e7abfe2d87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 99 additions and 6 deletions

View File

@ -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
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

View File

@ -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 %}

View File

@ -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

View File

@ -0,0 +1,5 @@
-- depends_on: {{ ref('live') }}
{%- set configs = [
config_stakingrewards_udfs,
] -%}
{{- ephemeral_deploy_marketplace(configs) -}}