Skip to content

Commit

Permalink
Merge pull request #249 from sablier-labs/build/bun
Browse files Browse the repository at this point in the history
build: switch to bun for dep management
  • Loading branch information
PaulRBerg authored Jan 1, 2024
2 parents a5aaee2 + 44c82ee commit 362e785
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 63 deletions.
32 changes: 8 additions & 24 deletions .github/workflows/ci-deep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,14 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "pnpm install"
run: "bun install"

- name: "Lint the contracts"
run: "pnpm lint"
- name: "Lint the code"
run: "bun run lint"

- name: "Add lint summary"
run: |
Expand All @@ -57,19 +49,11 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "pnpm install"
run: "bun install"

- name: "Produce an optimized build with --via-ir"
run: "FOUNDRY_PROFILE=optimized forge build"
Expand Down
36 changes: 10 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,14 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "pnpm install"
run: "bun install"

- name: "Lint the contracts"
run: "pnpm lint"
- name: "Lint the code"
run: "bun run lint"

- name: "Add lint summary"
run: |
Expand All @@ -55,19 +47,11 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "pnpm install"
run: "bun install"

- name: "Show the Foundry config"
run: "forge config"
Expand All @@ -76,7 +60,7 @@ jobs:
run: "./shell/prepare-artifacts.sh"

- name: "Build the test contracts"
run: "FOUNDRY_PROFILE=test-optimized forge build"
run: "FOUNDRY_PROFILE=test-optimized forge build"

- name: "Cache the build and the node modules so that they can be re-used by the other jobs"
uses: "actions/cache/save@v3"
Expand Down Expand Up @@ -195,7 +179,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
uses: "actions/checkout@v3"

- name: "Restore the cached build and the node modules"
uses: "actions/cache/restore@v3"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ out
.pnp.*
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test
*.log
.DS_Store
.pnp.*
bun.lockb
lcov.info
package-lock.json
pnpm-lock.yaml
Expand Down
14 changes: 10 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You will need the following software on your machine:
- [Git](https://git-scm.com/downloads)
- [Foundry](https://github.com/foundry-rs/foundry)
- [Node.Js](https://nodejs.org/en/download/)
- [Pnpm](https://pnpm.io/)
- [Bun](https://bun.sh)

In addition, familiarity with [Solidity](https://soliditylang.org/) is requisite.

Expand All @@ -26,14 +26,21 @@ Clone this repository including submodules:
$ git clone --recurse-submodules -j8 [email protected]:sablier-labs/v2-periphery.git
```

Then, inside the project's directory, run this to install the Node.js dependencies:
Then, inside the project's directory, run this to install the Node.js dependencies and build the contracts:

```shell
$ pnpm install
$ bun install
$ bun run build
```

Now you can start making changes.

To see a list of all available scripts:

```shell
$ bun run
```

## Pull Requests

When making a pull request, ensure that:
Expand All @@ -48,7 +55,6 @@ When making a pull request, ensure that:
- Gas snapshots are provided and demonstrate an improvement (or an acceptable deficit given other improvements).
- Reference contracts are modified correspondingly if relevant.
- New tests are included for all new features or code paths.
- If making a modification to third-party Node.js dependencies, `pnpm audit` passes.
- A descriptive summary of the PR has been provided.

## Environment Variables
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ In-depth documentation is available at [docs.sablier.com](https://docs.sablier.c

This is the recommended approach.

Install Sablier V2 Periphery as a Node.js package:
Install Sablier V2 Periphery using your favorite package manager, e.g., with Bun:

```shell
yarn add @sablier/v2-periphery
bun add @sablier/v2-periphery
```

Then, if you are using Foundry, add these to your `remappings.txt` file:
Expand All @@ -36,6 +36,8 @@ Then, if you are using Foundry, add these to your `remappings.txt` file:

### Git Submodules

This installation method is not recommended, but it is available for those who prefer it.

First, install the submodule using Forge:

```sh
Expand Down
Binary file added bun.lockb
Binary file not shown.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
"clean": "rm -rf artifacts broadcast cache docs out-optimized out",
"gas:report": "forge test --gas-report --no-match-test \"test(Fuzz)?_RevertWhen_\\w{1,}?\"",
"gas:snapshot": "forge snapshot --no-match-test \"test(Fuzz)?_RevertWhen_\\w{1,}?\"",
"gas:snapshot:optimized": "pnpm build:optimized && FOUNDRY_PROFILE=test-optimized forge snapshot --no-match-test \"test(Fork)?(Fuzz)?_RevertWhen_\\w{1,}?\"",
"lint": "pnpm lint:sol && pnpm prettier:check",
"lint:sol": "forge fmt --check && pnpm solhint \"{script,src,test}/**/*.sol\"",
"prepack": "pnpm install && bash ./shell/prepare-artifacts.sh",
"gas:snapshot:optimized": "bun run build:optimized && FOUNDRY_PROFILE=test-optimized forge snapshot --no-match-test \"test(Fork)?(Fuzz)?_RevertWhen_\\w{1,}?\"",
"lint": "bun run lint:sol && bun run prettier:check",
"lint:sol": "forge fmt --check && bun solhint \"{script,src,test}/**/*.sol\"",
"prepack": "bun install && bash ./shell/prepare-artifacts.sh",
"prettier:check": "prettier --check \"**/*.{json,md,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,yml}\"",
"test": "forge test",
"test:lite": "FOUNDRY_PROFILE=lite forge test",
"test:optimized": "pnpm build:optimized && FOUNDRY_PROFILE=test-optimized forge test"
"test:optimized": "bun run build:optimized && FOUNDRY_PROFILE=test-optimized forge test"
}
}
4 changes: 2 additions & 2 deletions shell/prepare-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Pre-requisites:
# - foundry (https://getfoundry.sh)
# - pnpm (https://pnpm.io)
# - bun (https://bun.sh)

# Strict mode: https://gist.github.com/vncsna/64825d5609c146e80de8b1fd623011ca
set -euo pipefail
Expand Down Expand Up @@ -40,4 +40,4 @@ libraries=./artifacts/libraries
cp out-optimized/Errors.sol/Errors.json $libraries

# Format the artifacts with Prettier
pnpm prettier --write ./artifacts
bun prettier --write ./artifacts

0 comments on commit 362e785

Please sign in to comment.