Skip to content

Commit

Permalink
Merge pull request #183 from PaulRBerg/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 Dec 31, 2023
2 parents 2c104d1 + dd3603e commit d81f678
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 6,527 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ types
*.log
.DS_Store
.pnp.*
bun.lockb
coverage.json
package-lock.json
pnpm-lock.yaml
Expand Down
38 changes: 18 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ name: "CI"
env:
HARDHAT_VAR_MNEMONIC: "test test test test test test test test test test test junk"
HARDHAT_VAR_INFURA_API_KEY: "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# Uncomment the following lines to set your configuration variables using
# GitHub secrets (https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions)
# HARDHAT_VAR_MNEMONIC: ${{ secrets.Mnemonic }}
# HARDHAT_VAR_INFURA_API_KEY: ${{ secrets.InfuraApiKey }}
# HARDHAT_VAR_ARBISCAN_API_KEY: ${{ secrets.ArbiscanApiKey }}
# HARDHAT_VAR_BSCSCAN_API_KEY: ${{ secrets.BscscanApiKey }}
# HARDHAT_VAR_ETHERSCAN_API_KEY: ${{ secrets.EtherscanApiKey }}
# HARDHAT_VAR_OPTIMISM_API_KEY: ${{ secrets.OptimismApiKey }}
# HARDHAT_VAR_POLYGONSCAN_API_KEY: ${{ secrets.PolygonscanApiKey }}
# HARDHAT_VAR_SNOWTRACE_API_KEY: ${{ secrets.SnowtraceApiKey }}
# Uncomment the following lines to set your configuration variables using
# GitHub secrets (https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions)
#
# HARDHAT_VAR_MNEMONIC: ${{ secrets.Mnemonic }}
# HARDHAT_VAR_INFURA_API_KEY: ${{ secrets.InfuraApiKey }}
# HARDHAT_VAR_ARBISCAN_API_KEY: ${{ secrets.ArbiscanApiKey }}
# HARDHAT_VAR_BSCSCAN_API_KEY: ${{ secrets.BscscanApiKey }}
# HARDHAT_VAR_ETHERSCAN_API_KEY: ${{ secrets.EtherscanApiKey }}
# HARDHAT_VAR_OPTIMISM_API_KEY: ${{ secrets.OptimismApiKey }}
# HARDHAT_VAR_POLYGONSCAN_API_KEY: ${{ secrets.PolygonscanApiKey }}
# HARDHAT_VAR_SNOWTRACE_API_KEY: ${{ secrets.SnowtraceApiKey }}

on:
workflow_dispatch:
Expand All @@ -28,33 +29,30 @@ jobs:
- name: "Check out the repo"
uses: "actions/checkout@v3"

- 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 dependencies"
run: "pnpm install"
run: "bun install"

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

- name: "Add lint summary"
run: |
echo "## Lint results" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: "Compile the contracts and generate the TypeChain bindings"
run: "pnpm typechain"
run: "bun run typechain"

- name: "Test the contracts and generate the coverage report"
run: "pnpm coverage"
run: "bun run coverage"

- name: "Add test summary"
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ deployments
.pnp.*
coverage.json
package-lock.json
pnpm-lock.yaml
yarn.lock
4 changes: 2 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image: "gitpod/workspace-node:latest"
image: "gitpod/workspace-bun:latest"

tasks:
- init: "pnpm install"
- init: "bun install"

vscode:
extensions:
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ types
*.log
.DS_Store
.pnp.*
bun.lockb
coverage.json
package-lock.json
pnpm-lock.yaml
Expand Down
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ You can edit the CI script in [.github/workflows/ci.yml](./.github/workflows/ci.
First, you need to install the dependencies:

```sh
$ pnpm install
$ bun install
```

Then, you need to set up all the required
[Hardhat Configuration Variables](https://hardhat.org/hardhat-runner/docs/guides/configuration-variables). You might
also want to install some that are optional.

To assist with the setup process, run `pnpm dlx hardhat vars setup`. To set a particular value, such as a BIP-39
mnemonic variable, execute this:
To assist with the setup process, run `bunx hardhat vars setup`. To set a particular value, such as a BIP-39 mnemonic
variable, execute this:

```sh
$ pnpm dlx hardhat vars set MNEMONIC
$ bunx hardhat vars set MNEMONIC
? Enter value: ‣ here is where your twelve words mnemonic should be put my friend
```

Expand All @@ -94,71 +94,71 @@ If you do not already have a mnemonic, you can generate one using this [website]
Compile the smart contracts with Hardhat:

```sh
$ pnpm compile
$ bun run compile
```

### TypeChain

Compile the smart contracts and generate TypeChain bindings:

```sh
$ pnpm typechain
$ bun run typechain
```

### Test

Run the tests with Hardhat:

```sh
$ pnpm test
$ bun run test
```

### Lint Solidity

Lint the Solidity code:

```sh
$ pnpm lint:sol
$ bun run lint:sol
```

### Lint TypeScript

Lint the TypeScript code:

```sh
$ pnpm lint:ts
$ bun run lint:ts
```

### Coverage

Generate the code coverage report:

```sh
$ pnpm coverage
$ bun run coverage
```

### Report Gas

See the gas usage per unit test and average gas per method call:

```sh
$ REPORT_GAS=true pnpm test
$ REPORT_GAS=true bun run test
```

### Clean

Delete the smart contract artifacts, the coverage reports and the Hardhat cache:

```sh
$ pnpm clean
$ bun run clean
```

### Deploy

Deploy the contracts to Hardhat Network:

```sh
$ pnpm deploy:contracts
$ bun run deploy:contracts
```

### Tasks
Expand All @@ -168,11 +168,9 @@ $ pnpm deploy:contracts
Deploy a new instance of the Lock contract via a task:

```sh
$ pnpm task:deployLock --unlock 100 --value 0.1
$ bun run task:deployLock --unlock 100 --value 0.1
```

## Tips

### Syntax Highlighting

If you use VSCode, you can get Solidity syntax highlighting with the
Expand All @@ -182,7 +180,7 @@ If you use VSCode, you can get Solidity syntax highlighting with the

[GitPod](https://www.gitpod.io/) is an open-source developer platform for remote development.

To view the coverage report generated by `pnpm coverage`, just click `Go Live` from the status bar to turn the server
To view the coverage report generated by `bun run coverage`, just click `Go Live` from the status bar to turn the server
on/off.

## Local development with Ganache
Expand Down
Binary file added bun.lockb
Binary file not shown.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
"access": "public"
},
"scripts": {
"clean": "rimraf ./artifacts ./cache ./coverage ./types ./coverage.json && pnpm typechain",
"clean": "rimraf ./artifacts ./cache ./coverage ./types ./coverage.json && bun run typechain",
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
"coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && pnpm typechain",
"coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && bun run typechain",
"deploy:contracts": "hardhat deploy",
"lint": "pnpm lint:sol && pnpm lint:ts && pnpm prettier:check",
"lint": "bun run lint:sol && bun run lint:ts && bun run prettier:check",
"lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
"lint:ts": "eslint --ignore-path ./.eslintignore --ext .js,.ts .",
"postcompile": "pnpm typechain",
"postcompile": "bun run typechain",
"prettier:check": "prettier --check \"**/*.{js,json,md,sol,ts,yml}\"",
"prettier:write": "prettier --write \"**/*.{js,json,md,sol,ts,yml}\"",
"task:deployLock": "hardhat task:deployLock",
Expand Down
Loading

0 comments on commit d81f678

Please sign in to comment.