Skip to content

Commit

Permalink
fix: Hasura deploy fix (#1464)
Browse files Browse the repository at this point in the history
- GitHub action should specify DBT_TARGET
- Add DBT_TARGET to .env and load .env
- Generate new tables
- genTables should throw errors, not swallow
- Build should generate metadata to checkin
  • Loading branch information
ryscheng authored May 21, 2024
1 parent c8fccf3 commit c739720
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 30 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-hasura.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ env:
HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
HASURA_GRAPHQL_ENDPOINT: ${{ vars.HASURA_GRAPHQL_ENDPOINT }}
HASURA_GRAPHQL_DATABASE_URL: ${{ secrets.HASURA_GRAPHQL_DATABASE_URL }}
DBT_TARGET: "production"
GOOGLE_CREDENTIALS_JSON: ${{ vars.GOOGLE_TEST_DUMMY_CREDENTIALS_JSON }}
GOOGLE_PROJECT_ID: opensource-observer

Expand Down
1 change: 1 addition & 0 deletions apps/hasura/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
HASURA_GRAPHQL_ADMIN_SECRET=
HASURA_GRAPHQL_ENDPOINT=https://opensource-observer.hasura.app/
HASURA_GRAPHQL_DATABASE_URL=postgresql://user:password@host:port
DBT_TARGET=production
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: artifacts_by_project_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
22 changes: 22 additions & 0 deletions apps/hasura/metadata/databases/cloudsql/tables/artifacts_v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: artifacts_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: code_metrics_by_project_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
22 changes: 22 additions & 0 deletions apps/hasura/metadata/databases/cloudsql/tables/collections_v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: collections_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: event_indexing_status_by_project_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
22 changes: 22 additions & 0 deletions apps/hasura/metadata/databases/cloudsql/tables/event_types_v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: event_types_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: onchain_metrics_by_project_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: projects_by_collection_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
22 changes: 22 additions & 0 deletions apps/hasura/metadata/databases/cloudsql/tables/projects_v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: projects_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
37 changes: 10 additions & 27 deletions apps/hasura/metadata/databases/cloudsql/tables/tables.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
- "!include artifacts.yaml"
- "!include artifacts_by_project.yaml"
- "!include code_metrics_by_collection.yaml"
- "!include code_metrics_by_project.yaml"
- "!include collections.yaml"
- "!include deployers_by_project.yaml"
- "!include event_totals_by_project.yaml"
- "!include event_types.yaml"
- "!include events_daily_from_artifact.yaml"
- "!include events_daily_from_collection.yaml"
- "!include events_daily_from_project.yaml"
- "!include artifacts_by_project_v1.yaml"
- "!include artifacts_v1.yaml"
- "!include code_metrics_by_project_v1.yaml"
- "!include collections_v1.yaml"
- "!include event_indexing_status_by_project_v1.yaml"
- "!include event_types_v1.yaml"
- "!include events_daily_to_artifact.yaml"
- "!include events_daily_to_collection.yaml"
- "!include events_daily_to_project.yaml"
- "!include events_monthly_from_artifact.yaml"
- "!include events_monthly_from_collection.yaml"
- "!include events_monthly_from_project.yaml"
- "!include events_monthly_to_artifact.yaml"
- "!include events_monthly_to_collection.yaml"
- "!include events_monthly_to_project.yaml"
- "!include events_weekly_from_artifact.yaml"
- "!include events_weekly_from_collection.yaml"
- "!include events_weekly_from_project.yaml"
- "!include events_weekly_to_artifact.yaml"
- "!include events_weekly_to_collection.yaml"
- "!include events_weekly_to_project.yaml"
- "!include first_contribution_to_project.yaml"
- "!include last_contribution_to_project.yaml"
- "!include onchain_metrics_by_collection.yaml"
- "!include onchain_metrics_by_project.yaml"
- "!include pm_dev_months.yaml"
- "!include pm_new_contribs.yaml"
- "!include projects.yaml"
- "!include projects_by_collection.yaml"
- "!include repos_by_project.yaml"
- "!include users_monthly_to_project.yaml"
- "!include onchain_metrics_by_project_v1.yaml"
- "!include projects_by_collection_v1.yaml"
- "!include projects_v1.yaml"
- "!include users_v1.yaml"
22 changes: 22 additions & 0 deletions apps/hasura/metadata/databases/cloudsql/tables/users_v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: users_v1
schema: public
select_permissions:
- role: anonymous
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: user
permission:
columns: "*"
filter: {}
allow_aggregations: false
comment: ""
- role: developer
permission:
columns: "*"
filter: {}
allow_aggregations: true
comment: ""
5 changes: 3 additions & 2 deletions apps/hasura/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
"node": ">=20"
},
"scripts": {
"build": "tsc",
"build:ts": "tsc",
"build": "pnpm build:ts && pnpm metadata:genTables",
"lint": "tsc --noEmit && pnpm lint:eslint && pnpm lint:prettier",
"lint:eslint": "eslint --ignore-path ../../.gitignore --max-warnings 0 .",
"lint:prettier": "prettier --ignore-path ../../.gitignore --log-level warn --check **/*.{js,jsx,ts,tsx,sol,md,json}",
"metadata:genTables": "node --loader ts-node/esm src/genTables.ts",
"metadata:genTables": "dotenv -- node --loader ts-node/esm src/genTables.ts",
"metadata:pull": "hasura metadata export",
"metadata:reload": "hasura metadata reload",
"metadata:apply": "hasura metadata apply",
Expand Down
3 changes: 2 additions & 1 deletion apps/hasura/src/genTables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,6 @@ async function main(): Promise<void> {
main()
.then(() => console.log("Done"))
.catch((e) => {
console.warn(e);
//console.warn(e);
throw e;
});

0 comments on commit c739720

Please sign in to comment.