Skip to content

Commit d6e25d9

Browse files
authored
Add pre-commit globally (#393)
* Add pre-commit globally * Fix CI errors
1 parent 275c7b8 commit d6e25d9

File tree

228 files changed

+8691
-7812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+8691
-7812
lines changed

.github/workflows/pre-commit.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Pre-commit checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: nightly
18+
components: rustfmt, clippy
19+
- uses: pre-commit/[email protected]

.github/workflows/pyth-cosmwasm-contract.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
run:
1717
working-directory: ./cosmwasm/contracts/pyth
1818
steps:
19-
- uses: actions/checkout@v2
20-
- name: Build
21-
run: cargo build --verbose
22-
- name: Run tests
23-
run: cargo test --verbose
19+
- uses: actions/checkout@v2
20+
- name: Build
21+
run: cargo build --verbose
22+
- name: Run tests
23+
run: cargo test --verbose

.github/workflows/remote-executor.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Check Remote Executor
22

33
on:
44
pull_request:
5-
paths: [ pythnet/remote-executor/** ]
5+
paths: [pythnet/remote-executor/**]
66
push:
77
branches: [main]
8-
paths: [ pythnet/remote-executor/** ]
8+
paths: [pythnet/remote-executor/**]
99
jobs:
1010
pre-commit:
1111
runs-on: ubuntu-latest
@@ -24,4 +24,3 @@ jobs:
2424
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
2525
- name: Run executor tests
2626
run: cargo test-bpf --manifest-path ./pythnet/remote-executor/Cargo.toml
27-

.pre-commit-config.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,36 @@ repos:
33
rev: v3.2.0
44
hooks:
55
- id: trailing-whitespace
6-
files: pythnet/
76
- id: end-of-file-fixer
8-
files: pythnet/
97
- id: check-added-large-files
8+
# Hook to format many type of files in the repo
9+
# including solidity contracts.
10+
- repo: https://github.com/pre-commit/mirrors-prettier
11+
rev: "v2.7.1"
12+
hooks:
13+
- id: prettier
14+
additional_dependencies:
15+
16+
1017
- repo: local
1118
hooks:
19+
# Hooks for the remote executor
1220
- id: cargo-fmt-executor
1321
name: Cargo format executor
1422
language: "rust"
1523
entry: cargo +nightly fmt --manifest-path ./pythnet/remote-executor/Cargo.toml --all
1624
pass_filenames: false
25+
files: pythnet/remote-executor/
1726
- id: cargo-clippy-executor
1827
name: Cargo clippy executor
1928
language: "rust"
2029
entry: cargo +nightly clippy --manifest-path ./pythnet/remote-executor/Cargo.toml -- -D warnings
2130
pass_filenames: false
31+
files: pythnet/remote-executor/
32+
# Hooks for the attester
33+
- id: cargo-fmt-executor
34+
name: Cargo format executor
35+
language: "rust"
36+
entry: cargo +nightly fmt --manifest-path ./solana/pyth2wormhole/Cargo.toml --all
37+
pass_filenames: false
38+
files: solana/pyth2wormhole/

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ and code reviews are our most important tools to accomplish that.
1010
complex features, it can be useful to submit a [formal design document](design/template.md).
1111

1212
- Development happens on a long-lived development branch (`dev.v2` and `dev.v1`).
13-
Every change going into a development branch is reviewed individually (see below). Release branches may be used
13+
Every change going into a development branch is reviewed individually (see below). Release branches may be used
1414
to support in-the-wild releases of Wormhole. We aim to support at most two release
1515
branches at the same time. Changes can be cherry-picked from the development branch to release branches, but
1616
never from release branches to a development branch.
17-
17+
1818
- Releases are first tested on a testnet.
1919

2020
- Commits should be small and have a meaningful commit message. One commit should, roughly, be "one idea" and
2121
be as atomic as possible. A feature can consist of many such commits.
22-
22+
2323
- Feature flags and interface evolution are better than breaking changes and long-lived feature branches.
24-
24+
2525
- We optimize for reading, not for writing - over its lifetime, code is read much more often than written.
2626
Small commits, meaningful commit messages and useful comments make it easier to review code and improve the
2727
quality of code review as well as review turnaround times. It's much easier to spot mistakes in small,
@@ -42,12 +42,12 @@ The answer is... maybe? The following things are needed in order to fully suppor
4242
a node or light client for every chain supported by Wormhole. This adds up, and the barrier to support new
4343
chains is pretty high. Your proposal should clearly outline the value proposition of supporting the new chain.
4444
**Convincing the DAO to run nodes for your chain is the first step in supporting a new chain.**
45-
45+
4646
- The chain needs to support smart contracts capable of verifying 19 individual secp256k1 signatures.
4747

4848
- The smart contract needs to be built and audited. In some cases, existing contracts can be used, like with
4949
EVM-compatible chains.
50-
50+
5151
- Support for observing the chain needs to be added to guardiand.
5252

5353
- Web wallet integration needs to be built to actually interact with Wormhole.

DEVELOP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The following dependencies are required for local development:
77
- [Go](https://golang.org/dl/) >= 1.17.5
88
- [Tilt](http://tilt.dev/) >= 0.20.8
99
- Any of the local Kubernetes clusters supported by Tilt.
10-
We strongly recommend [minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) >=
10+
We strongly recommend [minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) >=
1111
v1.21.0 with the kvm2 driver.
1212
- Tilt will use Minikube's embedded Docker server. If Minikube is not used, a local instance of
1313
[Docker](https://docs.docker.com/engine/install/) / moby-engine >= 19.03 is required.

Dockerfile.client

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ARG WORMHOLE_TAG=v2.8.9
88
RUN apt-get update && apt-get install -yq libudev-dev ncat
99
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
1010

11-
COPY solana /usr/src/solana
11+
COPY solana /usr/src/solana
1212
WORKDIR /usr/src/solana/pyth2wormhole
1313

1414
RUN --mount=type=cache,target=/root/.cache \

Dockerfile.cosmwasm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FROM cosmwasm/workspace-optimizer:0.12.6@sha256:e6565a5e87c830ef3e8775a9035006b3
2020
COPY cosmwasm/Cargo.lock /code/
2121
COPY cosmwasm/Cargo.toml /code/
2222
COPY cosmwasm/contracts /code/contracts
23-
COPY third_party/pyth/p2w-sdk/rust /third_party/pyth/p2w-sdk/rust
23+
COPY third_party/pyth/p2w-sdk/rust /third_party/pyth/p2w-sdk/rust
2424
RUN --mount=type=cache,target=/code/target,id=cosmwasm_pyth_target --mount=type=cache,target=/usr/local/cargo/registry optimize_workspace.sh
2525

2626
# Contract deployment stage

Dockerfile.solana

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN sh -c "$(curl -sSfL https://release.solana.com/v1.10.31/install)"
2020
ENV PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
2121

2222

23-
ADD solana/rust-toolchain /rust-toolchain
23+
ADD solana/pyth2wormhole/rust-toolchain /rust-toolchain
2424
# Solana does a questionable download at the beginning of a *first* build-bpf call. Trigger and layer-cache it explicitly.
2525
RUN cargo init --lib /tmp/decoy-crate && \
2626
cd /tmp/decoy-crate && cargo build-bpf && \

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Pyth2Wormhole. The base repository is a fork from Certus One's reference
66
for building projects based on Wormhole's various SDKs. Much of the existing
77
documentation from there will also apply to this repository.
88

9-
[Wormhole]: https://github.com/wormhole-foundation/wormhole
9+
[wormhole]: https://github.com/wormhole-foundation/wormhole
1010

1111
Within this monorepo you will find the following subprojects:
1212

1313
## Pyth2Wormhole Solana
14-
> solana/pyth2wormhole
1514

15+
> solana/pyth2wormhole
1616
1717
The main Pyth implementation currently exists as an [on-chain contract][] on
1818
Solana. In order to expose these prices cross-chain, the Pyth2Wormhole Solana
@@ -24,7 +24,8 @@ various P2W receiver contracts.
2424
[on-chain contract]: https://github.com/pyth-network/pyth-client
2525

2626
## Pyth2Wormhole Ethereum
27-
> ethereum/contracts/pyth
27+
28+
> ethereum/contracts/pyth
2829
2930
The Ethereum P2W contract acts as a receiver for Pyth prices relayed from the
3031
P2W Solana contract. It also provides a public API for other Ethereum contracts
@@ -35,7 +36,8 @@ examples.
3536
[pyth-evm-sdk]: https://github.com/pyth-network/pyth-sdk-solidity
3637

3738
## Pyth2Wormhole Price Service
38-
> third_party/pyth
39+
40+
> third_party/pyth
3941
4042
The P2W Price Service is an off-chain service which constantly observes the
4143
Wormhole network watching for price attestations emitted from the Pyth Solana
@@ -48,7 +50,7 @@ the [pyth-js][] repository.
4850

4951
[pyth-js]: https://github.com/pyth-network/pyth-js
5052

51-
--------------------------------------------------------------------------------
53+
---
5254

5355
See [DEVELOP.md](DEVELOP.md) for instructions on how to set up a local devnet, and
5456
[CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute to this project.
@@ -60,3 +62,15 @@ implied. See the License for the specific language governing permissions and lim
6062
spoken - this is a very complex piece of software which targets a bleeding-edge, experimental smart contract runtime.
6163
Mistakes happen, and no matter how hard you try and whether you pay someone to audit it, it may eat your tokens, set
6264
your printer on fire or startle your cat. Cryptocurrencies are a high-risk investment, no matter how fancy.
65+
66+
## Development
67+
68+
### Releases
69+
70+
We use [Semantic Versioning](https://semver.org/) for our releases.
71+
72+
### pre-commit hooks
73+
74+
pre-commit is a tool that checks and fixes simple issues (formatting, ...) before each commit. You can install it by following [their website](https://pre-commit.com/). In order to enable checks for this repo run `pre-commit install` from command-line in the root of this repo.
75+
76+
The checks are also performed in the CI to ensure the code follows consistent formatting.

0 commit comments

Comments
 (0)