forked from xJonathanLEI/starknet-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (80 loc) · 2.48 KB
/
lint.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
on:
push:
branches:
- "master"
pull_request:
name: "Linting"
jobs:
format:
name: "Check code format"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout source code"
uses: "actions/checkout@v3"
- name: "Use Rust cache"
uses: "Swatinem/rust-cache@v2"
with:
cache-on-failure: true
- name: "Install prettier"
run: |
yarn global add prettier
- name: "Install black"
run: |
pip install git+https://github.com/psf/black
- name: "Check Markdown format"
run: |
prettier --check "**/*.md"
- name: "Check Yaml format"
run: |
prettier --check "**/*.{yaml,yml}"
- name: "Check JSON format"
run: |
EXIT_CODE="0";
readarray -d '' FILES < <(find -type f -name "*.json" -not -path "./target/*");
for FILE in ${FILES[@]}; do
cat $FILE | jq > /tmp/formatted_json.json;
if cmp --silent "$FILE" /tmp/formatted_json.json; then
printf "\033[1;30m$FILE\033[0m OK\n";
else
printf "\033[1;33m$FILE\033[0m FAILED\n";
EXIT_CODE="1";
fi
done
exit $EXIT_CODE;
- name: "Check Python format"
run: |
black --check .
- name: "Check Rust format"
run: |
cargo fmt --all -- --check
clippy:
name: "Run Clippy"
runs-on: "ubuntu-latest"
strategy:
matrix:
toolchain:
- "stable"
- "nightly"
steps:
- name: "Checkout source code"
uses: "actions/checkout@v3"
- name: "Setup toolchain"
uses: "actions-rs/toolchain@v1"
with:
toolchain: "${{ matrix.toolchain }}"
components: "clippy"
override: true
- name: "Set allowed lints"
run: |
if [ "${{ matrix.toolchain }}" == "nightly" ]; then
echo "ALLOWED=-A non_local_definitions -A clippy::too_long_first_doc_paragraph" >> $GITHUB_ENV
else
echo "ALLOWED=" >> $GITHUB_ENV
fi
- name: "Run Clippy (default)"
run: |
cargo clippy --all --all-targets -- -D warnings $ALLOWED
- name: "Run Clippy (no_std)"
run: |
cargo clippy --package starknet-crypto --no-default-features -- -D warnings $ALLOWED
cargo clippy --package starknet-crypto --no-default-features --features alloc -- -D warnings $ALLOWED