Skip to content

Commit dae72c1

Browse files
authored
chore: add CI for formatting (#249)
1 parent 9f26001 commit dae72c1

File tree

6 files changed

+56
-30
lines changed

6 files changed

+56
-30
lines changed

.github/workflows/main.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
build:
16+
test:
1717
runs-on: ${{ matrix.runner }}
1818

1919
strategy:
@@ -71,6 +71,10 @@ jobs:
7171
- name: Remove grit modules
7272
run: rm -rf .grit/.gritmodules
7373

74+
- name: check formatting
75+
run: |
76+
grit format
77+
7478
- name: Run grit patterns test
7579
run: |
7680
if [ -n "${{ secrets.API_CLIENT_ID }}" ] && [ -n "${{ secrets.API_CLIENT_SECRET }}" ]; then

.grit/grit.yaml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,2 @@
11
version: 0.0.1
2-
patterns:
3-
- name: grit_snake_case
4-
description: Markdown files committed to stdlib's patterns directory must have names conforming to GritQL's pattern name convention.
5-
body: |
6-
engine marzano(0.1)
7-
language markdown
8-
9-
file($name, $body) where {
10-
$name <: r".*?/?([^/]+)\.[a-zA-Z]*"($base_name),
11-
! $base_name <: r"^[a-zA-Z_][a-zA-Z0-9_]*$"
12-
}
13-
samples:
14-
- input: |
15-
<!-- @filename: .grit/patterns/kebab-case.md -->
16-
17-
# This is a markdown file
18-
output: |
19-
<!-- @filename: .grit/patterns/kebab-case.md -->
20-
21-
# This is a markdown file
22-
- input: |
23-
<!-- @filename: .grit/patterns/snake_case.md -->
24-
25-
# This is a markdown file
2+
patterns: []

.grit/patterns/go/mux_go_v5.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ pattern rename_params() {
4343
4444
pattern final_mux_renames() {
4545
or {
46-
`[]$muxgo.InputSettings{$params}` where {}
47-
// $video = require_import(source=`github.com/muxinc/mux-go/video`),
48-
=> `[]video.AssetNewParamsInput{$params}`
46+
`[]$muxgo.InputSettings{$params}` => `[]video.AssetNewParamsInput{$params}`
47+
// $video = require_import(source=`github.com/muxinc/mux-go/video`),
4948
}
5049
}
5150

.grit/patterns/grit_snake_case.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Use snake case for pattern names
2+
3+
Markdown files committed to stdlib's patterns directory must have names conforming to GritQL's pattern name convention.
4+
5+
```grit
6+
engine marzano(0.1)
7+
language markdown
8+
9+
file($name, $body) where {
10+
$name <: r".*?/?([^/]+)\.[a-zA-Z]*"($base_name),
11+
! $base_name <: r"^[a-zA-Z_][a-zA-Z0-9_]*$"
12+
}
13+
```
14+
15+
## Examples
16+
17+
### Invalid
18+
19+
```md
20+
<!-- @filename: .grit/patterns/kebab-case.md -->
21+
22+
# This is a markdown file
23+
```
24+
25+
Still bad:
26+
27+
```md
28+
<!-- @filename: .grit/patterns/kebab-case.md -->
29+
30+
# This is a markdown file
31+
```
32+
33+
### Valid
34+
35+
```md
36+
<!-- @filename: .grit/patterns/snake_case.md -->
37+
38+
# This is a markdown file
39+
```

.grit/patterns/js/replace_wildcard_imports.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ pattern replace_wildcard_import() {
2929
$refs = distinct($refs),
3030
$joined_refs = join($refs, `, `),
3131
// Try the different scenarios
32-
if ($refs <: []) {}
32+
if ($refs <: []) {} else if (and {
3333
// Found nothing, leave the wildcard
34-
else if (and { ! $refs <: [], $kept_refs <: [] }) {
34+
! $refs <: [],
35+
$kept_refs <: []
36+
}) {
3537
// Found just refs we can replace, replace them
3638
$import => `import { $joined_refs } from $src`
3739
} else {

.grit/patterns/python/_test_replace_import_list.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,33 @@ language python
77
find_replace_imports(list=[
88
[
99
`langchain_community.chat_models`, `ChatOpenAI`, `langchain_openai`,
10+
1011
`ChatOpenAI`
1112
],
1213
1314
[`anthropic_place`, `EpicLinguist`, `new_anthropic_place`, `SauceLinguist`],
1415
1516
[
1617
`langchain_community.chat_models`, `MyLittleModel`, `extra_lc_models`,
18+
1719
`MyBigModel`
1820
],
1921
2022
[
2123
`langchain.chains.ernie_functions.base`, `convert_to_ernie_function`,
24+
2225
`langchain_community.chains`, `convert_to_ernie_function`
2326
],
2427
2528
[
2629
`langchain.chains.ernie_functions.base`, `create_ernie_fn_chain`,
30+
2731
`langchain_community.chains`, `create_ernie_fn_chain`
2832
],
2933
3034
[
3135
`langchain.chains.graph_qa.cypher_utils`, `CypherQueryCorrector`, `lc_new`,
36+
3237
`CypherQueryCorrector`
3338
],
3439

0 commit comments

Comments
 (0)