Skip to content

Commit

Permalink
Reformat everything with Prettier. (#222)
Browse files Browse the repository at this point in the history
### What

We seem to be going back and forth on formatting, especially for
JavaScript. Let's stop doing that and just use an auto-formatter for
JavaScript, JSON, YAML, and Markdown.

This replaces the `jq`-based formatting for the goldenfiles; the results
seem to be identical.

We ignore `flake.lock` because it is machine-generated and
auto-formatting it differently from `nix flake update` will cause
unnecessary grief.

### How

`just format` now runs `prettier --write .`, which reformats JavaScript,
JSON, YAML, and Markdown, ignoring all files in `.gitignore` or
`.prettierignore`. I have added `flake.lock` to `.prettierignore` to
ensure we don't thrash between two formats.

`just format-check` will now run `prettier --check .`.

I have run `just format` to ensure that everything is formatted
consistently. We can change this by configuring Prettier with a
`.prettierrc` file if we don't like the current formatting.
  • Loading branch information
SamirTalwar authored Sep 4, 2023
1 parent 20dfcdf commit 92cd94c
Show file tree
Hide file tree
Showing 33 changed files with 335 additions and 580 deletions.
2 changes: 1 addition & 1 deletion .buildkite/release-config-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ steps:
- url: [email protected]:hasura/ddn-cloud.git
ref: staging
delete_checkout: true
interpolate_checkout_path: "$BUILDKITE_BUILD_CHECKOUT_PATH/$BUILDKITE_BUILD_ID/$BUILDKITE_JOB_ID"
interpolate_checkout_path: "$BUILDKITE_BUILD_CHECKOUT_PATH/$BUILDKITE_BUILD_ID/$BUILDKITE_JOB_ID"
4 changes: 2 additions & 2 deletions .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
with:
status: ${{ job.status }}
notify_when: failure
notification_title: '😧 Error on <{repo_url}|{repo}>'
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
4 changes: 2 additions & 2 deletions .github/workflows/cargo-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
status: ${{ job.status }}
notify_when: failure
notification_title: '😧 Error on <{repo_url}|{repo}>'
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
20 changes: 10 additions & 10 deletions .github/workflows/cargo-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
with:
status: ${{ job.status }}
notify_when: failure
notification_title: '😧 Error on <{repo_url}|{repo}>'
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

Expand Down Expand Up @@ -78,8 +78,8 @@ jobs:
with:
status: ${{ job.status }}
notify_when: failure
notification_title: '😧 Error on <{repo_url}|{repo}>'
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

Expand Down Expand Up @@ -125,8 +125,8 @@ jobs:
with:
status: ${{ job.status }}
notify_when: failure
notification_title: '😧 Error on <{repo_url}|{repo}>'
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

Expand Down Expand Up @@ -172,8 +172,8 @@ jobs:
with:
status: ${{ job.status }}
notify_when: failure
notification_title: '😧 Error on <{repo_url}|{repo}>'
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

Expand Down Expand Up @@ -220,7 +220,7 @@ jobs:
with:
status: ${{ job.status }}
notify_when: failure
notification_title: '😧 Error on <{repo_url}|{repo}>'
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
62 changes: 62 additions & 0 deletions .github/workflows/check-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Postgres NDC format

on:
push:

jobs:
cargo-fmt:
name: check formatting with cargo fmt
runs-on: ubuntu-latest
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
RUSTFLAGS: "-D warnings" # fail on warnings
steps:
- uses: actions/checkout@v3

- name: install tools
run: |
rustup show
- uses: Swatinem/rust-cache@v2

- name: check Rust formatting
run: |
cargo fmt --all
# scream into Slack if something goes wrong
- name: Report Status
if: github.ref == 'refs/heads/main'
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: failure
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

prettier:
name: check formatting with prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: DeterminateSystems/nix-installer-action@v4

- uses: DeterminateSystems/magic-nix-cache-action@v2

- name: check other formatting
run: |
nix develop --command prettier --check .
# scream into Slack if something goes wrong
- name: Report Status
if: github.ref == 'refs/heads/main'
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: failure
notification_title: "😧 Error on <{repo_url}|{repo}>"
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
4 changes: 2 additions & 2 deletions .github/workflows/configuration-docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Test
uses: cygnetdigital/[email protected]
with:
url: 'http://localhost:9100/'
responseCode: '200'
url: "http://localhost:9100/"
responseCode: "200"
timeout: 2000
interval: 1000
21 changes: 10 additions & 11 deletions .github/workflows/nix-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
build_and_deploy:
name: build and deploy
name: build and deploy
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -19,31 +19,30 @@ jobs:
"build_command": "postgres-agent-x86_64-linux",
"binary_artifact_name": "hasura-postgres-agent-rs",
"artifact_path": "result/bin/ndc-postgres",
"docker_build_command":"docker-postgres-x86_64-linux",
"docker_image_name": "ghcr.io/hasura/postgres-agent-rs"
"docker_build_command": "docker-postgres-x86_64-linux",
"docker_image_name": "ghcr.io/hasura/postgres-agent-rs",
},
{
"build_command": "cockroach-agent-x86_64-linux",
"binary_artifact_name": "hasura-cockroach-agent-rs",
"artifact_path": "result/bin/ndc-cockroach",
"docker_build_command":"docker-cockroach-x86_64-linux",
"docker_image_name": "ghcr.io/hasura/cockroach-agent-rs"
"docker_build_command": "docker-cockroach-x86_64-linux",
"docker_image_name": "ghcr.io/hasura/cockroach-agent-rs",
},
{
"build_command": "citus-agent-x86_64-linux",
"binary_artifact_name": "hasura-citus-agent-rs",
"artifact_path": "result/bin/ndc-citus",
"docker_build_command":"docker-citus-x86_64-linux",
"docker_image_name": "ghcr.io/hasura/citus-agent-rs"
"docker_build_command": "docker-citus-x86_64-linux",
"docker_image_name": "ghcr.io/hasura/citus-agent-rs",
},
{
"build_command": "aurora-agent-x86_64-linux",
"binary_artifact_name": "hasura-aurora-agent-rs",
"artifact_path": "result/bin/ndc-aurora",
"docker_build_command":"docker-aurora-x86_64-linux",
"docker_image_name": "ghcr.io/hasura/aurora-agent-rs"
}

"docker_build_command": "docker-aurora-x86_64-linux",
"docker_image_name": "ghcr.io/hasura/aurora-agent-rs",
},
]

steps:
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/rustfmt.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake.lock
1 change: 0 additions & 1 deletion architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ The query execution receives a pool and a plan and executes it against postgres.
back to the caller of the function.
The code can be found in [phases/execution.rs](/crates/query-engine/src/phases/execution.rs)


```rs
pub async fn execute(
pool: sqlx::PgPool,
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/component/benchmarks/select-by-pk.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const options = {
},
},
thresholds: {
"checks": [
checks: [
{
threshold: "rate == 1",
abortOnFail: true,
Expand Down
72 changes: 36 additions & 36 deletions benchmarks/component/benchmarks/select-where.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
import {check} from "k6";
import { check } from "k6";
import http from "k6/http";
import {newSummaryHandler} from "../common.js";
import { newSummaryHandler } from "../common.js";

const testid = "select-where";
const agentSocket = __ENV.AGENT_SOCKET || "localhost:8100";
const url = `http://${agentSocket}/query`;
const data = {
collection : "Album",
query : {
fields : {
id : {type : "column", column : "AlbumId", arguments : {}},
title : {type : "column", column : "Title", arguments : {}},
artist_id : {type : "column", column : "ArtistId", arguments : {}},
collection: "Album",
query: {
fields: {
id: { type: "column", column: "AlbumId", arguments: {} },
title: { type: "column", column: "Title", arguments: {} },
artist_id: { type: "column", column: "ArtistId", arguments: {} },
},
where : {
type : "binary_comparison_operator",
column : {
type : "column",
name : "Title",
path : [],
where: {
type: "binary_comparison_operator",
column: {
type: "column",
name: "Title",
path: [],
},
operator : {
type : "other",
name : "_ilike",
operator: {
type: "other",
name: "_ilike",
},
value : {
type : "scalar",
value : "%a%",
value: {
type: "scalar",
value: "%a%",
},
},
},
arguments : {},
collection_relationships : {},
arguments: {},
collection_relationships: {},
};

export default function() {
export default function () {
const response = http.post(url, JSON.stringify(data), {
headers : {
"Content-Type" : "application/json",
headers: {
"Content-Type": "application/json",
},
});

check(response, {
"status is 200" : (r) => r.status == 200,
"status is 200": (r) => r.status == 200,
});
}

export const handleSummary = newSummaryHandler(testid);

export const options = {
tags : {
tags: {
testid,
},
scenarios : {
short_sustained : {
executor : "constant-vus",
vus : 100,
duration : "10s",
scenarios: {
short_sustained: {
executor: "constant-vus",
vus: 100,
duration: "10s",
},
},
thresholds : {
"checks" : [
thresholds: {
checks: [
{
threshold : "rate == 1",
abortOnFail : true,
threshold: "rate == 1",
abortOnFail: true,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/component/benchmarks/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const options = {
},
},
thresholds: {
"checks": [
checks: [
{
threshold: "rate == 1",
abortOnFail: true,
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/component/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: postgres-ndc-component-benchmarks

services:
benchmark:
image: grafana/k6
image: grafana/k6
environment:
AGENT_SOCKET: "agent:8100"
OUTPUT_DIRECTORY: "/home/k6/output"
Expand Down Expand Up @@ -32,7 +32,7 @@ services:
condition: service_completed_successfully

benchmark-output-init:
image: grafana/k6
image: grafana/k6
entrypoint:
- sh
- -c
Expand Down
Loading

0 comments on commit 92cd94c

Please sign in to comment.