-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-devcontainer-nats
- Loading branch information
Showing
112 changed files
with
7,179 additions
and
16,855 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Apollo Schema Check | ||
|
||
# Generally running a pull_request_target with secrets from the fork is risky, however we are only using the schema.graphql | ||
# file and not executing any code from the branch so it's safe here. | ||
on: | ||
pull_request_target: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check: | ||
name: check | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
env: | ||
APOLLO_KEY: ${{ secrets.APOLLO_KEY }} | ||
APOLLO_VCS_COMMIT: ${{ github.event.pull_request.head.sha }} | ||
APOLLO_VCS_REMOTE_URL: ${{ github.event.pull_request.head.repo.clone_url }} | ||
APOLLO_VCS_BRANCH: ${{ github.event.pull_request.head.label }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Install Rover | ||
run: | | ||
curl -sSL https://rover.apollo.dev/nix/latest | sh | ||
echo "$HOME/.rover/bin" >> $GITHUB_PATH | ||
- name: Run check against infratographer supergraph | ||
run: | | ||
rover subgraph check --name load-balancer-api --schema schema.graphql infratographer@main --format json --output subgraph-check.json | ||
- name: Generate report comment | ||
run: | | ||
RESULTS_FILE=subgraph-check.json | ||
echo -e "#### GraphQL Schema Check\n" > comment.txt | ||
print_details () { | ||
TARGET_URL=$(jq '.data.tasks.operations.target_url' $RESULTS_FILE | tr -d \") | ||
echo -e "🔗 [View full schema check details]($TARGET_URL)\n" >> comment.txt | ||
} | ||
print_changes_for () { | ||
SEV=$(echo $1 | tr -d \") | ||
COUNT=$(jq -c ".data.tasks.operations.changes[] | select(.severity == \"$SEV\")" $RESULTS_FILE | wc -l) | ||
echo -e "<details>\n\n<summary>$COUNT $SEV Changes</summary>\n" >> comment.txt | ||
echo -e "| Change Type | Description |\n| --- | --- |" >> comment.txt | ||
jq -j ".data.tasks.operations.changes[] | select(.severity == \"$SEV\") | (\"| \", .code, \" | \", .description, \" |\"),\"\n\"" $RESULTS_FILE | sort >> comment.txt | ||
echo -e "\n</details>\n" >> comment.txt | ||
} | ||
print_errors () { | ||
SUMMARY=$(jq -j '.error.message' $RESULTS_FILE) | ||
echo -e "<details>\n\n<summary>$SUMMARY</summary>\n" >> comment.txt | ||
echo -e "| Error Type | Code | Message |\n| --- | --- | --- |" >> comment.txt | ||
jq -j '.error.details.build_errors[] | ("| ", .type, " | ", .code, " | ", .message, " |"),"\n"' $RESULTS_FILE >> comment.txt | ||
echo -e "\n</details>\n" >> comment.txt | ||
} | ||
ERROR=$(jq '.error' $RESULTS_FILE) | ||
if [ "$ERROR" != "null" ]; then | ||
echo -e "❌ Schema composition failed\n" >> comment.txt | ||
print_errors | ||
print_details | ||
exit 0 | ||
fi | ||
FAILURE_COUNT=$(jq '.data.tasks.operations.failure_count' $RESULTS_FILE) | ||
CHANGE_COUNT=$(jq '.data.tasks.operations.changes | length' $RESULTS_FILE) | ||
OP_CHECK_COUNT=$(jq '.data.tasks.operations.operation_check_count' $RESULTS_FILE) | ||
echo -e "Compared $CHANGE_COUNT schema changes against $OP_CHECK_COUNT operations\n" >> comment.txt | ||
if [ $CHANGE_COUNT -eq 0 ]; then | ||
echo -e "✅ Found **no changes**\n\n" >> comment.txt | ||
print_details | ||
exit 0 | ||
fi | ||
if [ $FAILURE_COUNT -eq 0 ] | ||
then | ||
echo -e "✅ Found **no breaking changes**\n" >> comment.txt | ||
else | ||
echo -e "❌ Found **$FAILURE_COUNT breaking changes**\n" >> comment.txt | ||
fi | ||
sev_array=() | ||
IFS=$'\n' read -r -d '' -a sev_array < <( jq '.data.tasks.operations.changes[].severity' $RESULTS_FILE | sort| uniq && printf '\0' ) | ||
for i in "${sev_array[@]}" | ||
do | ||
print_changes_for $i | ||
done | ||
print_details | ||
- name: Comment PR with execution number | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
filePath: comment.txt | ||
comment_tag: infratographer-apollo-graph-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Publish GraphQL Schema | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
APOLLO_KEY: ${{ secrets.APOLLO_KEY }} | ||
APOLLO_VCS_COMMIT: ${{ github.event.pull_request.head.sha }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Rover | ||
run: | | ||
curl -sSL https://rover.apollo.dev/nix/latest | sh | ||
echo "$HOME/.rover/bin" >> $GITHUB_PATH | ||
- name: Publish subgraph schema | ||
run: | | ||
rover subgraph publish --name load-balancer-api --schema schema.graphql infratographer@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
db/migrations/20230629085916_drop_status_and_annotations.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- +goose Up | ||
|
||
-- reverse: create index "loadbalancerstatus_created_at" to table: "load_balancer_status" | ||
DROP INDEX "loadbalancerstatus_created_at"; | ||
-- reverse: create index "loadbalancerstatus_load_balancer_id" to table: "load_balancer_status" | ||
DROP INDEX "loadbalancerstatus_load_balancer_id"; | ||
-- reverse: create index "loadbalancerstatus_load_balancer_id_namespace_source" to table: "load_balancer_status" | ||
DROP INDEX "loadbalancerstatus_load_balancer_id_namespace_source"; | ||
-- reverse: create index "loadbalancerstatus_namespace_data" to table: "load_balancer_status" | ||
DROP INDEX "loadbalancerstatus_namespace_data"; | ||
-- reverse: create index "loadbalancerstatus_updated_at" to table: "load_balancer_status" | ||
DROP INDEX "loadbalancerstatus_updated_at"; | ||
-- reverse: create "load_balancer_status" table | ||
DROP TABLE "load_balancer_status"; | ||
-- reverse: create index "loadbalancerannotation_created_at" to table: "load_balancer_annotations" | ||
DROP INDEX "loadbalancerannotation_created_at"; | ||
-- reverse: create index "loadbalancerannotation_load_balancer_id" to table: "load_balancer_annotations" | ||
DROP INDEX "loadbalancerannotation_load_balancer_id"; | ||
-- reverse: create index "loadbalancerannotation_load_balancer_id_namespace" to table: "load_balancer_annotations" | ||
DROP INDEX "loadbalancerannotation_load_balancer_id_namespace"; | ||
-- reverse: create index "loadbalancerannotation_namespace_data" to table: "load_balancer_annotations" | ||
DROP INDEX "loadbalancerannotation_namespace_data"; | ||
-- reverse: create index "loadbalancerannotation_updated_at" to table: "load_balancer_annotations" | ||
DROP INDEX "loadbalancerannotation_updated_at"; | ||
-- reverse: create "load_balancer_annotations" table | ||
DROP TABLE "load_balancer_annotations"; | ||
|
||
-- +goose Down | ||
-- create "load_balancer_annotations" table | ||
CREATE TABLE "load_balancer_annotations" ("id" character varying NOT NULL, "namespace" character varying NOT NULL, "data" jsonb NOT NULL, "created_at" timestamptz NOT NULL, "updated_at" timestamptz NOT NULL, "load_balancer_id" character varying NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "load_balancer_annotations_load_balancers_load_balancer" FOREIGN KEY ("load_balancer_id") REFERENCES "load_balancers" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION); | ||
-- create index "loadbalancerannotation_created_at" to table: "load_balancer_annotations" | ||
CREATE INDEX "loadbalancerannotation_created_at" ON "load_balancer_annotations" ("created_at"); | ||
-- create index "loadbalancerannotation_load_balancer_id" to table: "load_balancer_annotations" | ||
CREATE INDEX "loadbalancerannotation_load_balancer_id" ON "load_balancer_annotations" ("load_balancer_id"); | ||
-- create index "loadbalancerannotation_load_balancer_id_namespace" to table: "load_balancer_annotations" | ||
CREATE INDEX "loadbalancerannotation_load_balancer_id_namespace" ON "load_balancer_annotations" ("load_balancer_id", "namespace"); | ||
-- create index "loadbalancerannotation_namespace_data" to table: "load_balancer_annotations" | ||
CREATE INDEX "loadbalancerannotation_namespace_data" ON "load_balancer_annotations" USING gin ("namespace", "data"); | ||
-- create index "loadbalancerannotation_updated_at" to table: "load_balancer_annotations" | ||
CREATE INDEX "loadbalancerannotation_updated_at" ON "load_balancer_annotations" ("updated_at"); | ||
-- create "load_balancer_status" table | ||
CREATE TABLE "load_balancer_status" ("id" character varying NOT NULL, "namespace" character varying NOT NULL, "data" jsonb NOT NULL, "created_at" timestamptz NOT NULL, "updated_at" timestamptz NOT NULL, "source" character varying NOT NULL, "load_balancer_id" character varying NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "load_balancer_status_load_balancers_load_balancer" FOREIGN KEY ("load_balancer_id") REFERENCES "load_balancers" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION); | ||
-- create index "loadbalancerstatus_created_at" to table: "load_balancer_status" | ||
CREATE INDEX "loadbalancerstatus_created_at" ON "load_balancer_status" ("created_at"); | ||
-- create index "loadbalancerstatus_load_balancer_id" to table: "load_balancer_status" | ||
CREATE INDEX "loadbalancerstatus_load_balancer_id" ON "load_balancer_status" ("load_balancer_id"); | ||
-- create index "loadbalancerstatus_load_balancer_id_namespace_source" to table: "load_balancer_status" | ||
CREATE INDEX "loadbalancerstatus_load_balancer_id_namespace_source" ON "load_balancer_status" ("load_balancer_id", "namespace", "source"); | ||
-- create index "loadbalancerstatus_namespace_data" to table: "load_balancer_status" | ||
CREATE INDEX "loadbalancerstatus_namespace_data" ON "load_balancer_status" USING gin ("namespace", "data"); | ||
-- create index "loadbalancerstatus_updated_at" to table: "load_balancer_status" | ||
CREATE INDEX "loadbalancerstatus_updated_at" ON "load_balancer_status" ("updated_at"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
h1:VqR1OSr9cOmG9cPyGgjEbDiQxwCpFRLGNlYKzYjpMZc= | ||
h1:c+ziReSuevRk7RBOpYWo0gncdcwco4V61ROlPMPe5EE= | ||
20230503185445_initial-migration.sql h1:4pqNp2MDBBRdGxU/H5mmZui9oi1SyjIiMVGatajrBeY= | ||
20230615194819_drop_tenant_add_owner.sql h1:KGCsItU0NYhxYEkhZOaMQjfIrBMnek5rxC6D/LhnyCk= | ||
20230629085916_drop_status_and_annotations.sql h1:kvDMoaMEjyoj/aRi6rw4XvCLxGH09vGGLbL0/p5tpPo= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.