Skip to content

Commit 5a66e7e

Browse files
chore: add pre-commit
1 parent ca11c5a commit 5a66e7e

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

.github/workflows/on-pull-request.yaml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@ on:
66
- main
77

88
jobs:
9-
verify_flows:
9+
pre-commit:
1010
runs-on: ubuntu-latest
11-
1211
steps:
1312
- uses: actions/checkout@v4
14-
15-
- name: Set up Python
16-
uses: actions/setup-python@v5
13+
- uses: foundry-rs/setup-snfoundry@v3
1714
with:
18-
python-version: '3.x'
19-
20-
- name: Check all flows have tests
21-
run: |
22-
python scripts/check_all_flows_have_test.py --allow-duplicate-tests
15+
starknet-foundry-version: "0.49.0"
16+
- uses: software-mansion/setup-scarb@v1
17+
with:
18+
scarb-version: "2.12.2"
19+
- uses: pre-commit/[email protected]
20+
with:
21+
extra_args: cairo-scarb-fmt
22+
- uses: pre-commit/[email protected]
23+
with:
24+
extra_args: ensure-flow-struct-tests
2325

2426
test:
2527
runs-on: ubuntu-latest
@@ -45,7 +47,3 @@ jobs:
4547
token: ${{ secrets.CODECOV_TOKEN }}
4648
files: coverage/coverage.lcov
4749
fail_ci_if_error: true
48-
49-
- name: Check formatting
50-
run: |
51-
scarb fmt -w --check

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: cairo-scarb-fmt
5+
name: check cairo code is formatted
6+
entry: scarb fmt -w --check
7+
language: system
8+
pass_filenames: false
9+
stages: [commit]
10+
- id: ensure-flow-struct-tests
11+
name: ensure flow structs have tests
12+
entry: scripts/check_all_flows_have_test.py --allow-duplicate-tests
13+
language: system
14+
pass_filenames: false
15+
stages: [commit]

scripts/check_all_flows_have_test.py

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/env python3
2+
13
from io import BufferedReader
24
from re import search
35
from argparse import ArgumentParser, Namespace

0 commit comments

Comments
 (0)