Skip to content

Commit

Permalink
Add formatters, pre-commit checks, ci, etc. (#6)
Browse files Browse the repository at this point in the history
* Cleanup multicall-status

* Setup formatting and pre-commit

* Cleanup solidity formatting

* Format python files

* fixed formatting issue

---------

Co-authored-by: Anirudh Suresh <[email protected]>
  • Loading branch information
m30m and Anirudh Suresh authored Jan 11, 2024
1 parent c9544f5 commit 81712a1
Show file tree
Hide file tree
Showing 38 changed files with 1,132 additions and 565 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci-pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Pre-commit checks

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Need to grab the history of the PR
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-03-01
components: rustfmt, clippy
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-07-23
components: rustfmt, clippy
- uses: pre-commit/[email protected]
if: ${{ github.event_name == 'pull_request' }}
with:
# Run only on files changed in the PR
extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
- uses: pre-commit/[email protected]
if: ${{ github.event_name != 'pull_request' }}
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
exclude: package-lock.json
# Hook to format many type of files in the repo
# including solidity contracts.
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
hooks:
- id: prettier
additional_dependencies:
- "[email protected]"
- "[email protected]"
- repo: local
hooks:
# Hooks for auction server
- id: cargo-fmt-auction-server
name: Cargo format for auction server
language: "rust"
entry: cargo +nightly-2023-07-23 fmt --manifest-path ./auction-server/Cargo.toml --all -- --config-path rustfmt.toml
pass_filenames: false
files: auction-server

# for python files
- repo: https://github.com/hhatto/autopep8
rev: "v2.0.4"
hooks:
- id: autopep8
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ $ source .env
$ set +a
```

The updated enviornment variables can then be seen via `env`. We can then run the appropriate forge tests which will pull the relevant bundle information from the environment variables. To do this, run `forge test -vvv --via-ir --match-test {TestToBeRun}`. Note that you need to `source` the `.env` file in the same session as the one in which you run the forge tests.
The updated enviornment variables can then be seen via `env`. We can then run the appropriate forge tests which will pull the relevant bundle information from the environment variables. To do this, run `forge test -vvv --via-ir --match-test {TestToBeRun}`. Note that you need to `source` the `.env` file in the same session as the one in which you run the forge tests.

### pre-commit hooks

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.

The checks are also performed in the CI to ensure the code follows consistent formatting.
1 change: 0 additions & 1 deletion auction-server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
target

1 change: 0 additions & 1 deletion auction-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Each blockchain is configured in `config.yaml`.
This package uses Cargo for building and dependency management.
Simply run `cargo build` and `cargo test` to build and test the project.


## Local Development

To start an instance of the webserver for local testing, you first need to perform a few setup steps:
Expand Down
Loading

0 comments on commit 81712a1

Please sign in to comment.