Skip to content

Commit

Permalink
build: add CI, update repo layout and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
0xble committed Jun 2, 2022
1 parent f6ae394 commit 1328735
Show file tree
Hide file tree
Showing 68 changed files with 40,700 additions and 11,053 deletions.
21 changes: 0 additions & 21 deletions .eslintignore

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lints

on: [push]

jobs:
lints:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly

- name: Install Dependencies
run: npm install
- name: Update Modules
run: npm run update
- name: Run linter
run: npm run lint
65 changes: 65 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Tests

on:
push:
branches:
- main
pull_request:

env:
FOUNDRY_PROFILE: ci

jobs:
foundry:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge test -vvv
id: forge-test

hardhat:
strategy:
fail-fast: true

name: Hardhat project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: "16.x"
cache: "npm"

- name: Install Node dependencies
run: |
npm ci
- name: Run Hardhat tests
run: |
npx hardhat compile
npx hardhat test
id: hardhat-test
59 changes: 21 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
# directories
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
**/artifacts
**/build
**/cache
**/coverage
**/.coverage_artifacts
**/.coverage_cache
**/.coverage_contracts
**/dist
**/node_modules
**/out
# Foundry
cache/
out/

# files
*.env
*.log
.pnp.*
coverage.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
gas-report
.DS_Store
# Environment variables!
.env
.env.prod

# JS
node_modules/

# types
src/types/*
!src/types/common.ts
!src/types/Greeter.ts
# Hardhat files
cache_hardhat/
artifacts/

# factories
!src/types/factories
src/types/factories/*
!src/types/factories/Greeter__factory.ts
# Hardhat plugin files
typechain-types/

package-lock.json
secrets.json
contracts-exposed
# Flattened files
flattened.txt

# Package Manager files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
3 changes: 0 additions & 3 deletions .npmignore

This file was deleted.

29 changes: 8 additions & 21 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
# directories
.yarn/
**/.coverage_artifacts
**/.coverage_cache
**/.coverage_contracts
**/artifacts
**/build
**/cache
**/coverage
**/dist
**/node_modules
**/types

# files
*.env
*.log
.pnp.*
coverage.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
build
coverage
out
lib
node_modules
artifacts
typechain-types
.next
5 changes: 0 additions & 5 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ singleQuote: false
tabWidth: 2
trailingComma: all

importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"]
importOrderParserPlugins: ["typescript"]
importOrderSeparation: true
importOrderSortSpecifiers: true

overrides:
- files: "*.sol"
options:
Expand Down
3 changes: 0 additions & 3 deletions .solcover.js

This file was deleted.

13 changes: 10 additions & 3 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 15],
"compiler-version": ["error", "^0.8.0"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"func-visibility": ["error", { "ignoreConstructors": true }],
"no-empty-blocks": "off",
"not-rely-on-time": "off",
"avoid-low-level-calls": "off",
Expand All @@ -11,7 +13,12 @@
"func-param-name-mixedcase": "off",
"var-name-mixedcase": "off",
"private-vars-leading-underscore": "off",
"code-complexity": "off",
"const-name-snakecase": "off"
"const-name-snakecase": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
}
1 change: 0 additions & 1 deletion .solhintignore

This file was deleted.

12 changes: 10 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"solidity.compileUsingRemoteVersion": "v0.8.11+commit.fc410830"
}
"solidity.packageDefaultDependenciesContractsDirectory": "src",
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.compileUsingRemoteVersion": "v0.8.11",
"search.exclude": { "lib": true },
"editor.formatOnSave": true,
"solidity.formatter": "prettier",
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
}
}
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
# cellar-contracts
# Sommelier Cellar Contracts • [![tests](https://github.com/PeggyJV/cellar-contracts/actions/workflows/tests.yml/badge.svg)](https://github.com/PeggyJV/cellar-contracts/actions/workflows/tests.yml) [![lints](https://github.com/PeggyJV/cellar-contracts/actions/workflows/lints.yml/badge.svg)](https://github.com/PeggyJV/cellar-contracts/actions/workflows/lints.yml) ![license](https://img.shields.io/github/license/PeggyJV/cellar-contracts)

Cellar contracts for Sommelier Network

## Getting Started
### Getting Started

Run:
- Use Foundry:

```bash
yarn install && yarn compile
forge install
forge test
```

## Testing

Run tests:
- Use Hardhat:

```bash
yarn test
npm install
npx hardhat test
```

Run to see test coverage (only for Hardhat test currently):
### Development

- Run tests with either Hardhat or Foundry:

```bash
yarn coverage
forge test
# or
npx hardhat test
```

## Clearing Caches
- Use Hardhat's task framework:

Run:
```bash
npx hardhat example
```

- Install libraries with Foundry which work with Hardhat:

```bash
yarn clean
forge install rari-capital/solmate # Already in this repo, just an example
```

### Notes

Whenever you install new libraries using Foundry, make sure to update your `remappings.txt` file by running `forge remappings > remappings.txt`. This is required because we use `hardhat-preprocessor` and the `remappings.txt` file to allow Hardhat to resolve libraries you install with Foundry.
17 changes: 12 additions & 5 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[default]
src = 'contracts'
libs = ['lib']
out = 'out'
solc_version = "0.8.11"
# Sets the concrete solc version to use
# This overrides the `auto_detect_solc` value
solc_version = '0.8.11'
auto_detect_solc = false
# Increase optimizer_runs
optimizer = true
optimizer_runs = 1_000
# Fuzz more than the default 256
fuzz_runs = 1_000

# See more config options https://github.com/gakonst/foundry/tree/master/config
# Perform extreme fuzzing on CI runs
[ci]
fuzz_runs = 100_000
Loading

0 comments on commit 1328735

Please sign in to comment.