Skip to content

Commit 92cd94c

Browse files
authored
Reformat everything with Prettier. (#222)
### 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.
1 parent 20dfcdf commit 92cd94c

33 files changed

+335
-580
lines changed

.buildkite/release-config-server.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ steps:
6262
- url: git@github.com:hasura/ddn-cloud.git
6363
ref: staging
6464
delete_checkout: true
65-
interpolate_checkout_path: "$BUILDKITE_BUILD_CHECKOUT_PATH/$BUILDKITE_BUILD_ID/$BUILDKITE_JOB_ID"
65+
interpolate_checkout_path: "$BUILDKITE_BUILD_CHECKOUT_PATH/$BUILDKITE_BUILD_ID/$BUILDKITE_JOB_ID"

.github/workflows/benchmarks.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
with:
8484
status: ${{ job.status }}
8585
notify_when: failure
86-
notification_title: '😧 Error on <{repo_url}|{repo}>'
87-
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
86+
notification_title: "😧 Error on <{repo_url}|{repo}>"
87+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
8888
env:
8989
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

.github/workflows/cargo-build.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
with:
3939
status: ${{ job.status }}
4040
notify_when: failure
41-
notification_title: '😧 Error on <{repo_url}|{repo}>'
42-
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
41+
notification_title: "😧 Error on <{repo_url}|{repo}>"
42+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
4343
env:
4444
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

.github/workflows/cargo-test.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
with:
3232
status: ${{ job.status }}
3333
notify_when: failure
34-
notification_title: '😧 Error on <{repo_url}|{repo}>'
35-
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
34+
notification_title: "😧 Error on <{repo_url}|{repo}>"
35+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
3636
env:
3737
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
3838

@@ -78,8 +78,8 @@ jobs:
7878
with:
7979
status: ${{ job.status }}
8080
notify_when: failure
81-
notification_title: '😧 Error on <{repo_url}|{repo}>'
82-
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
81+
notification_title: "😧 Error on <{repo_url}|{repo}>"
82+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
8383
env:
8484
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
8585

@@ -125,8 +125,8 @@ jobs:
125125
with:
126126
status: ${{ job.status }}
127127
notify_when: failure
128-
notification_title: '😧 Error on <{repo_url}|{repo}>'
129-
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
128+
notification_title: "😧 Error on <{repo_url}|{repo}>"
129+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
130130
env:
131131
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
132132

@@ -172,8 +172,8 @@ jobs:
172172
with:
173173
status: ${{ job.status }}
174174
notify_when: failure
175-
notification_title: '😧 Error on <{repo_url}|{repo}>'
176-
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
175+
notification_title: "😧 Error on <{repo_url}|{repo}>"
176+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
177177
env:
178178
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
179179

@@ -220,7 +220,7 @@ jobs:
220220
with:
221221
status: ${{ job.status }}
222222
notify_when: failure
223-
notification_title: '😧 Error on <{repo_url}|{repo}>'
224-
message_format: '🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>'
223+
notification_title: "😧 Error on <{repo_url}|{repo}>"
224+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
225225
env:
226226
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

.github/workflows/check-format.yaml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Postgres NDC format
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
cargo-fmt:
8+
name: check formatting with cargo fmt
9+
runs-on: ubuntu-latest
10+
env:
11+
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
12+
RUSTFLAGS: "-D warnings" # fail on warnings
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: install tools
17+
run: |
18+
rustup show
19+
20+
- uses: Swatinem/rust-cache@v2
21+
22+
- name: check Rust formatting
23+
run: |
24+
cargo fmt --all
25+
26+
# scream into Slack if something goes wrong
27+
- name: Report Status
28+
if: github.ref == 'refs/heads/main'
29+
uses: ravsamhq/notify-slack-action@v2
30+
with:
31+
status: ${{ job.status }}
32+
notify_when: failure
33+
notification_title: "😧 Error on <{repo_url}|{repo}>"
34+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
35+
env:
36+
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}
37+
38+
prettier:
39+
name: check formatting with prettier
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v3
43+
44+
- uses: DeterminateSystems/nix-installer-action@v4
45+
46+
- uses: DeterminateSystems/magic-nix-cache-action@v2
47+
48+
- name: check other formatting
49+
run: |
50+
nix develop --command prettier --check .
51+
52+
# scream into Slack if something goes wrong
53+
- name: Report Status
54+
if: github.ref == 'refs/heads/main'
55+
uses: ravsamhq/notify-slack-action@v2
56+
with:
57+
status: ${{ job.status }}
58+
notify_when: failure
59+
notification_title: "😧 Error on <{repo_url}|{repo}>"
60+
message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>"
61+
env:
62+
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }}

.github/workflows/configuration-docker-build.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Test
2525
uses: cygnetdigital/wait_for_response@v2.0.0
2626
with:
27-
url: 'http://localhost:9100/'
28-
responseCode: '200'
27+
url: "http://localhost:9100/"
28+
responseCode: "200"
2929
timeout: 2000
3030
interval: 1000

.github/workflows/nix-deploy.yaml

+10-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
build_and_deploy:
12-
name: build and deploy
12+
name: build and deploy
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
@@ -19,31 +19,30 @@ jobs:
1919
"build_command": "postgres-agent-x86_64-linux",
2020
"binary_artifact_name": "hasura-postgres-agent-rs",
2121
"artifact_path": "result/bin/ndc-postgres",
22-
"docker_build_command":"docker-postgres-x86_64-linux",
23-
"docker_image_name": "ghcr.io/hasura/postgres-agent-rs"
22+
"docker_build_command": "docker-postgres-x86_64-linux",
23+
"docker_image_name": "ghcr.io/hasura/postgres-agent-rs",
2424
},
2525
{
2626
"build_command": "cockroach-agent-x86_64-linux",
2727
"binary_artifact_name": "hasura-cockroach-agent-rs",
2828
"artifact_path": "result/bin/ndc-cockroach",
29-
"docker_build_command":"docker-cockroach-x86_64-linux",
30-
"docker_image_name": "ghcr.io/hasura/cockroach-agent-rs"
29+
"docker_build_command": "docker-cockroach-x86_64-linux",
30+
"docker_image_name": "ghcr.io/hasura/cockroach-agent-rs",
3131
},
3232
{
3333
"build_command": "citus-agent-x86_64-linux",
3434
"binary_artifact_name": "hasura-citus-agent-rs",
3535
"artifact_path": "result/bin/ndc-citus",
36-
"docker_build_command":"docker-citus-x86_64-linux",
37-
"docker_image_name": "ghcr.io/hasura/citus-agent-rs"
36+
"docker_build_command": "docker-citus-x86_64-linux",
37+
"docker_image_name": "ghcr.io/hasura/citus-agent-rs",
3838
},
3939
{
4040
"build_command": "aurora-agent-x86_64-linux",
4141
"binary_artifact_name": "hasura-aurora-agent-rs",
4242
"artifact_path": "result/bin/ndc-aurora",
43-
"docker_build_command":"docker-aurora-x86_64-linux",
44-
"docker_image_name": "ghcr.io/hasura/aurora-agent-rs"
45-
}
46-
43+
"docker_build_command": "docker-aurora-x86_64-linux",
44+
"docker_image_name": "ghcr.io/hasura/aurora-agent-rs",
45+
},
4746
]
4847

4948
steps:

.github/workflows/rustfmt.yaml

-35
This file was deleted.

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flake.lock

architecture.md

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ The query execution receives a pool and a plan and executes it against postgres.
111111
back to the caller of the function.
112112
The code can be found in [phases/execution.rs](/crates/query-engine/src/phases/execution.rs)
113113

114-
115114
```rs
116115
pub async fn execute(
117116
pool: sqlx::PgPool,

benchmarks/component/benchmarks/select-by-pk.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const options = {
5757
},
5858
},
5959
thresholds: {
60-
"checks": [
60+
checks: [
6161
{
6262
threshold: "rate == 1",
6363
abortOnFail: true,

benchmarks/component/benchmarks/select-where.js

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
import {check} from "k6";
1+
import { check } from "k6";
22
import http from "k6/http";
3-
import {newSummaryHandler} from "../common.js";
3+
import { newSummaryHandler } from "../common.js";
44

55
const testid = "select-where";
66
const agentSocket = __ENV.AGENT_SOCKET || "localhost:8100";
77
const url = `http://${agentSocket}/query`;
88
const data = {
9-
collection : "Album",
10-
query : {
11-
fields : {
12-
id : {type : "column", column : "AlbumId", arguments : {}},
13-
title : {type : "column", column : "Title", arguments : {}},
14-
artist_id : {type : "column", column : "ArtistId", arguments : {}},
9+
collection: "Album",
10+
query: {
11+
fields: {
12+
id: { type: "column", column: "AlbumId", arguments: {} },
13+
title: { type: "column", column: "Title", arguments: {} },
14+
artist_id: { type: "column", column: "ArtistId", arguments: {} },
1515
},
16-
where : {
17-
type : "binary_comparison_operator",
18-
column : {
19-
type : "column",
20-
name : "Title",
21-
path : [],
16+
where: {
17+
type: "binary_comparison_operator",
18+
column: {
19+
type: "column",
20+
name: "Title",
21+
path: [],
2222
},
23-
operator : {
24-
type : "other",
25-
name : "_ilike",
23+
operator: {
24+
type: "other",
25+
name: "_ilike",
2626
},
27-
value : {
28-
type : "scalar",
29-
value : "%a%",
27+
value: {
28+
type: "scalar",
29+
value: "%a%",
3030
},
3131
},
3232
},
33-
arguments : {},
34-
collection_relationships : {},
33+
arguments: {},
34+
collection_relationships: {},
3535
};
3636

37-
export default function() {
37+
export default function () {
3838
const response = http.post(url, JSON.stringify(data), {
39-
headers : {
40-
"Content-Type" : "application/json",
39+
headers: {
40+
"Content-Type": "application/json",
4141
},
4242
});
4343

4444
check(response, {
45-
"status is 200" : (r) => r.status == 200,
45+
"status is 200": (r) => r.status == 200,
4646
});
4747
}
4848

4949
export const handleSummary = newSummaryHandler(testid);
5050

5151
export const options = {
52-
tags : {
52+
tags: {
5353
testid,
5454
},
55-
scenarios : {
56-
short_sustained : {
57-
executor : "constant-vus",
58-
vus : 100,
59-
duration : "10s",
55+
scenarios: {
56+
short_sustained: {
57+
executor: "constant-vus",
58+
vus: 100,
59+
duration: "10s",
6060
},
6161
},
62-
thresholds : {
63-
"checks" : [
62+
thresholds: {
63+
checks: [
6464
{
65-
threshold : "rate == 1",
66-
abortOnFail : true,
65+
threshold: "rate == 1",
66+
abortOnFail: true,
6767
},
6868
],
6969
},

benchmarks/component/benchmarks/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const options = {
4444
},
4545
},
4646
thresholds: {
47-
"checks": [
47+
checks: [
4848
{
4949
threshold: "rate == 1",
5050
abortOnFail: true,

benchmarks/component/docker-compose.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: postgres-ndc-component-benchmarks
44

55
services:
66
benchmark:
7-
image: grafana/k6
7+
image: grafana/k6
88
environment:
99
AGENT_SOCKET: "agent:8100"
1010
OUTPUT_DIRECTORY: "/home/k6/output"
@@ -32,7 +32,7 @@ services:
3232
condition: service_completed_successfully
3333

3434
benchmark-output-init:
35-
image: grafana/k6
35+
image: grafana/k6
3636
entrypoint:
3737
- sh
3838
- -c

0 commit comments

Comments
 (0)