Skip to content

Commit fa1ffe9

Browse files
authoredJan 6, 2025
chore/tooling ci (supabase-community#165)
1 parent aa5c8f9 commit fa1ffe9

File tree

15 files changed

+243
-124
lines changed

15 files changed

+243
-124
lines changed
 

Diff for: ‎.github/actions/free-disk-space/action.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Free Disk Space
2+
description: Free up disk space on the runner
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Free Disk Space (Ubuntu)
7+
if: runner.os == 'Linux'
8+
uses: jlumbroso/free-disk-space@main
9+
with:
10+
# We need to reclaim some space, but uninstalling everyting takes
11+
# too long. So we'll just remove some of the larger packages.
12+
# https://github.com/jlumbroso/free-disk-space/pull/26
13+
android: true
14+
dotnet: true
15+
haskell: true
16+
large-packages: false

Diff for: ‎.github/actions/setup-monorepo/action.yml

-21
This file was deleted.

Diff for: ‎.github/workflows/ci.yml

-57
This file was deleted.

Diff for: ‎.github/workflows/pull_request.yml

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
name: Pull Request
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths: # Only run when changes are made to rust code or root Cargo
7+
- "crates/**"
8+
- "lib/**"
9+
- "fuzz/**"
10+
- "xtask/**"
11+
- "Cargo.toml"
12+
- "Cargo.lock"
13+
- "rust-toolchain.toml"
14+
- "rustfmt.toml"
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
env:
21+
RUSTFLAGS: -A dead_code
22+
RUST_LOG: info
23+
RUST_BACKTRACE: 1
24+
RUSTUP_WINDOWS_PATH_ADD_BIN: 1
25+
26+
jobs:
27+
format:
28+
name: Format
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout PR branch
32+
uses: actions/checkout@v4
33+
- name: Free Disk Space
34+
uses: ./.github/actions/free-disk-space
35+
- name: Install toolchain
36+
uses: moonrepo/setup-rust@v1
37+
with:
38+
components: rustfmt
39+
bins: taplo-cli
40+
cache-base: main
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
- name: Run format
44+
run: |
45+
cargo fmt --all --check
46+
taplo format --check
47+
48+
actionlint:
49+
name: Lint GitHub Actions
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
- name: Download actionlint
54+
id: get_actionlint
55+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
56+
shell: bash
57+
- name: Check workflow files
58+
run: ${{ steps.get_actionlint.outputs.executable }} -color
59+
shell: bash
60+
61+
lint:
62+
name: Lint Project
63+
runs-on: ubuntu-latest
64+
services:
65+
postgres:
66+
image: postgres:latest
67+
env:
68+
POSTGRES_USER: postgres
69+
POSTGRES_PASSWORD: postgres
70+
POSTGRES_DB: postgres
71+
ports:
72+
- 5432:5432
73+
steps:
74+
- name: Checkout PR Branch
75+
uses: actions/checkout@v4
76+
with:
77+
submodules: true
78+
- name: Free Disk Space
79+
uses: ./.github/actions/free-disk-space
80+
- name: Install toolchain
81+
uses: moonrepo/setup-rust@v1
82+
with:
83+
components: clippy
84+
cache-base: main
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
- name: Run clippy
88+
run: |
89+
cargo clippy
90+
cargo run -p rules_check
91+
92+
# check-dependencies:
93+
# name: Check Dependencies
94+
# runs-on: ubuntu-latest
95+
# services:
96+
# postgres:
97+
# image: postgres:latest
98+
# env:
99+
# POSTGRES_USER: postgres
100+
# POSTGRES_PASSWORD: postgres
101+
# POSTGRES_DB: postgres
102+
# ports:
103+
# - 5432:5432
104+
# steps:
105+
# - name: Checkout PR Branch
106+
# uses: actions/checkout@v4
107+
# with:
108+
# submodules: true
109+
# - name: Free Disk Space
110+
# uses: ./.github/actions/free-disk-space
111+
# - name: Install toolchain
112+
# run: rustup toolchain install nightly
113+
# - name: Install udeps
114+
# run: cargo install cargo-udeps --locked
115+
# - name: Detect unused dependencies using udeps
116+
# run: cargo +nightly udeps --all-targets
117+
118+
test:
119+
name: Test
120+
runs-on: ${{ matrix.os }}
121+
strategy:
122+
matrix:
123+
include:
124+
# reactive once we upgrade to the latest version of pg_query that is windows-compatible
125+
# - os: windows-latest
126+
- os: ubuntu-latest
127+
steps:
128+
- name: Checkout PR branch
129+
uses: actions/checkout@v4
130+
with:
131+
submodules: true
132+
- name: Free Disk Space
133+
uses: ./.github/actions/free-disk-space
134+
- name: Install toolchain
135+
uses: moonrepo/setup-rust@v1
136+
with:
137+
cache-base: main
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
141+
# running containers via `services` only works on linux
142+
# https://github.com/actions/runner/issues/1866
143+
- name: Setup postgres
144+
uses: ikalnytskyi/action-setup-postgres@v7
145+
- name: Run tests
146+
run: cargo test --workspace
147+
148+
codegen:
149+
name: Check Codegen
150+
runs-on: ubuntu-latest
151+
services:
152+
postgres:
153+
image: postgres:latest
154+
env:
155+
POSTGRES_USER: postgres
156+
POSTGRES_PASSWORD: postgres
157+
POSTGRES_DB: postgres
158+
ports:
159+
- 5432:5432
160+
steps:
161+
- name: Checkout PR branch
162+
uses: actions/checkout@v4
163+
with:
164+
submodules: true
165+
- name: Free Disk Space
166+
uses: ./.github/actions/free-disk-space
167+
- name: Install toolchain
168+
uses: moonrepo/setup-rust@v1
169+
with:
170+
cache-base: main
171+
env:
172+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
173+
- name: Run the analyser codegen
174+
run: cargo run -p xtask_codegen -- analyser
175+
- name: Run the configuration codegen
176+
run: cargo run -p xtask_codegen -- configuration
177+
- name: Check for git diff
178+
run: |
179+
if [[ $(git status --porcelain) ]]; then
180+
git status
181+
git diff
182+
exit 1
183+
fi

Diff for: ‎crates/pg_completions/src/context.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl TryFrom<&str> for ClauseType {
2929
panic!("{}", message);
3030
}
3131

32-
return Err(message);
32+
Err(message)
3333
}
3434
}
3535
}
@@ -215,7 +215,7 @@ mod tests {
215215

216216
let params = crate::CompletionParams {
217217
position: (position as u32).into(),
218-
text: text,
218+
text,
219219
tree: Some(&tree),
220220
schema: &pg_schema_cache::SchemaCache::new(),
221221
};
@@ -247,7 +247,7 @@ mod tests {
247247
let tree = get_tree(text.as_str());
248248
let params = crate::CompletionParams {
249249
position: (position as u32).into(),
250-
text: text,
250+
text,
251251
tree: Some(&tree),
252252
schema: &pg_schema_cache::SchemaCache::new(),
253253
};
@@ -281,7 +281,7 @@ mod tests {
281281
let tree = get_tree(text.as_str());
282282
let params = crate::CompletionParams {
283283
position: (position as u32).into(),
284-
text: text,
284+
text,
285285
tree: Some(&tree),
286286
schema: &pg_schema_cache::SchemaCache::new(),
287287
};
@@ -306,14 +306,14 @@ mod tests {
306306

307307
let params = crate::CompletionParams {
308308
position: (position as u32).into(),
309-
text: text,
309+
text,
310310
tree: Some(&tree),
311311
schema: &pg_schema_cache::SchemaCache::new(),
312312
};
313313

314314
let ctx = CompletionContext::new(&params);
315315

316-
let node = ctx.ts_node.map(|n| n.clone()).unwrap();
316+
let node = ctx.ts_node.unwrap();
317317

318318
assert_eq!(ctx.get_ts_node_content(node), Some("select"));
319319

@@ -334,14 +334,14 @@ mod tests {
334334

335335
let params = crate::CompletionParams {
336336
position: (position as u32).into(),
337-
text: text,
337+
text,
338338
tree: Some(&tree),
339339
schema: &pg_schema_cache::SchemaCache::new(),
340340
};
341341

342342
let ctx = CompletionContext::new(&params);
343343

344-
let node = ctx.ts_node.map(|n| n.clone()).unwrap();
344+
let node = ctx.ts_node.unwrap();
345345

346346
assert_eq!(ctx.get_ts_node_content(node), Some("from"));
347347
assert_eq!(
@@ -360,14 +360,14 @@ mod tests {
360360

361361
let params = crate::CompletionParams {
362362
position: (position as u32).into(),
363-
text: text,
363+
text,
364364
tree: Some(&tree),
365365
schema: &pg_schema_cache::SchemaCache::new(),
366366
};
367367

368368
let ctx = CompletionContext::new(&params);
369369

370-
let node = ctx.ts_node.map(|n| n.clone()).unwrap();
370+
let node = ctx.ts_node.unwrap();
371371

372372
assert_eq!(ctx.get_ts_node_content(node), Some(""));
373373
assert_eq!(ctx.wrapping_clause_type, None);
@@ -385,14 +385,14 @@ mod tests {
385385

386386
let params = crate::CompletionParams {
387387
position: (position as u32).into(),
388-
text: text,
388+
text,
389389
tree: Some(&tree),
390390
schema: &pg_schema_cache::SchemaCache::new(),
391391
};
392392

393393
let ctx = CompletionContext::new(&params);
394394

395-
let node = ctx.ts_node.map(|n| n.clone()).unwrap();
395+
let node = ctx.ts_node.unwrap();
396396

397397
assert_eq!(ctx.get_ts_node_content(node), Some("fro"));
398398
assert_eq!(ctx.wrapping_clause_type, Some(ClauseType::Select));

Diff for: ‎crates/pg_completions/src/test_helper.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ pub(crate) async fn get_test_deps(
3434
pub(crate) fn get_text_and_position(sql: &str) -> (usize, String) {
3535
// the cursor is to the left of the `CURSOR_POS`
3636
let position = sql
37-
.find(|c| c == CURSOR_POS)
37+
.find(CURSOR_POS)
3838
.expect("Please insert the CURSOR_POS into your query.")
39-
.checked_sub(1)
40-
.unwrap_or(0);
39+
.saturating_sub(1);
4140

4241
let text = sql.replace(CURSOR_POS, "");
4342

0 commit comments

Comments
 (0)
Please sign in to comment.