Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI Workflows #67

Merged
merged 43 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a374197
Add lerna linting
trajan0x Jul 19, 2022
1b187eb
js check rename
trajan0x Jul 19, 2022
b07547a
yarn cache dir path
trajan0x Jul 19, 2022
f9c03e9
resolve merge conflicts
trajan0x Jul 19, 2022
dc555d6
lint:fix
trajan0x Jul 19, 2022
fbaa864
remove package-lock.json
trajan0x Jul 19, 2022
687a8b3
add solhint
trajan0x Jul 19, 2022
7c50050
add slither action
trajan0x Jul 19, 2022
5ae5029
build contracts
trajan0x Jul 19, 2022
7e6e565
install foundry
trajan0x Jul 19, 2022
4f167d7
profile fix
trajan0x Jul 19, 2022
9cb0aae
submodules recursive
trajan0x Jul 19, 2022
106d2e7
rebuild
trajan0x Jul 19, 2022
65fddd6
remove excess lint jobs
trajan0x Jul 19, 2022
895e841
foundry setup
trajan0x Jul 19, 2022
f44e90a
pr
trajan0x Jul 19, 2022
a0f4540
add filter
trajan0x Jul 19, 2022
a06ab41
new target
trajan0x Jul 19, 2022
9b9b2d5
imrpvoed filtering
trajan0x Jul 19, 2022
2874f3e
even better filtering
trajan0x Jul 19, 2022
a710099
filter fix
trajan0x Jul 19, 2022
0c89658
new sarif path
trajan0x Jul 19, 2022
f48b500
specify dependency for lint
trajan0x Jul 19, 2022
1caec0d
sarif
trajan0x Jul 19, 2022
63bef1c
new
trajan0x Jul 19, 2022
bd47922
slither details
trajan0x Jul 19, 2022
0a1c3a9
changes->lint_changes
trajan0x Jul 19, 2022
0a2f972
reorder
trajan0x Jul 19, 2022
4c34613
kill ci label
trajan0x Jul 19, 2022
6a24623
changes fix
trajan0x Jul 19, 2022
5f337f7
lint_changes
trajan0x Jul 19, 2022
bec20d8
add comment [ci skip]
trajan0x Jul 19, 2022
eb95187
filter length
trajan0x Jul 19, 2022
46bfba7
re-echo
trajan0x Jul 19, 2022
f6903d1
echo
trajan0x Jul 19, 2022
cfca243
jq update
trajan0x Jul 19, 2022
579cb04
escape
trajan0x Jul 19, 2022
ccd2ace
upterm
trajan0x Jul 19, 2022
8ca4011
diff
trajan0x Jul 19, 2022
6bd0698
Revert "diff"
trajan0x Jul 19, 2022
9e88ba8
add filter length
trajan0x Jul 19, 2022
331feb6
use package count for build
trajan0x Jul 19, 2022
adeef27
speedup ci
trajan0x Jul 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# modern version of git and editors capable of LF line endings.

*.go -text diff=golang
*.go text eol=lf


# don't count abigen files in linguist as go
*.abigen.go linguist-vendored
Expand Down
117 changes: 74 additions & 43 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,6 @@ on:


jobs:
# make sure the build works
build:
name: Build
runs-on: ${{ matrix.platform }}
strategy:
matrix:
go-version:
- 1.18.x
platform:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: 'recursive'
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: authenticate with github for private go modules
uses: fusion-engineering/setup-git-credentials@v2
with:
credentials: https://0xnero:${{secrets.GIT_TOKEN }}@github.com/
- name: Go modules cache
uses: actions/cache@v2
with:
# see https://github.com/mvdan/github-actions-golang
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
# go build all workspaces
run: go build $(go work edit -json | jq -c -r '[.Use[].DiskPath] | map_values(. + "/...")[]')

test:
name: Test
runs-on: ${{ matrix.platform }}
Expand Down Expand Up @@ -131,16 +92,86 @@ jobs:
path-to-profile: profile.cov
ignore: ${{ env.IGNORED }}

# changes allows us to only run a job on changed packages
changes:
name: Go Changes
runs-on: ubuntu-latest
outputs:
# Expose matched filters as job 'packages' output variable
packages: ${{ steps.filter.outputs.changes }}
package_count: ${{ steps.length.outputs.FILTER_LENGTH }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: 'recursive'

# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
core: 'core/**'
tools: 'tools/**'
ethergo: 'ethergo/**'
- id: length
run: |
export FILTER_LENGTH=$(echo $FILTERED_PATHS | jq '. | length')
echo "##[set-output name=FILTER_LENGTH;]$(echo $FILTER_LENGTH)"
env:
FILTERED_PATHS: ${{ steps.filter.outputs.changes }}

# make sure the build works
build:
name: Build
needs: changes
runs-on: ${{ matrix.platform }}
if: ${{ needs.changes.outputs.package_count > 0 }}
strategy:
matrix:
go-version:
- 1.18.x
platform:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: 'recursive'
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: authenticate with github for private go modules
uses: fusion-engineering/setup-git-credentials@v2
with:
credentials: https://0xnero:${{secrets.GIT_TOKEN }}@github.com/
- name: Go modules cache
uses: actions/cache@v2
with:
# see https://github.com/mvdan/github-actions-golang
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
# go build all workspaces
run: go build $(go work edit -json | jq -c -r '[.Use[].DiskPath] | map_values(. + "/...")[]')

#note: right now this is not run against all work dirs
lint:
name: Lint
runs-on: ubuntu-latest
needs: changes
strategy:
matrix:
package:
- core
- tools
- ethergo
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['package1', 'package2'] if both package folders contains changes
package: ${{ fromJSON(needs.changes.outputs.packages) }}
steps:
- uses: actions/setup-go@v3
with:
Expand Down
120 changes: 120 additions & 0 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Solidity Linting
on:
pull_request:
push:
branches-ignore:
- 'gh-pages'

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: 'recursive'

- name: Read .nvmrc
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvmrc

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: "Use NodeJS by nvmrc"
uses: actions/setup-node@v2
with:
node-version: '${{steps.nvmrc.outputs.NVMRC}}'

- name: Initialize Yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install Node Dependencies
run: yarn install --frozen-lockfile --check-files

- name: Install dependencies
run: |
npx lerna bootstrap

- name: Run tests # Run tests of all packages
run: npx lerna exec npm run ci:lint

slither:
# see https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/setting-up-code-scanning-for-a-repository
if: ${{!github.event.repository.private}}
runs-on: ubuntu-latest
permissions:
# always required
security-events: write
# only required for private repos
actions: read
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: 'recursive'

- name: Read .nvmrc
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvmrc

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: "Use NodeJS by nvmrc"
uses: actions/setup-node@v2
with:
node-version: '${{steps.nvmrc.outputs.NVMRC}}'

- name: Initialize Yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-


- name: Install Node Dependencies
run: yarn install --frozen-lockfile --check-files

- name: Install dependencies
run: |
npx lerna bootstrap

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

- name: Build Contracts
run: |
npx lerna exec npm run build:slither

- name: Run Slither
uses: crytic/[email protected]
continue-on-error: true
id: slither
with:
node-version: '${{steps.nvmrc.outputs.NVMRC}}'
target: ./packages/contracts
ignore-compile: true
sarif: results.sarif

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ./packages/contracts/results.sarif
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ module.exports = {
},
},
],
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
},
"homepage": "https://github.com/synapsecns/sanguine#readme",
"devDependencies": {
"lerna": "^4.0.0"
"lerna": "^4.0.0",
"prettier": "^2.7.1",
"prettier-plugin-solidity": "^1.0.0-dev.23"
},
"dependencies": {
"@changesets/cli": "^2.22.0"
Expand Down
5 changes: 5 additions & 0 deletions packages/contracts/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
artifacts/*
build/*
flattened/*
lib/*

18 changes: 18 additions & 0 deletions packages/contracts/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "warn",
"compiler-version": "off",
"code-complexity": ["warn", 5],
"max-line-length": ["warn", 100],
"func-param-name-mixedcase": "error",
"modifier-name-mixedcase": "error",
"ordering": "warn",
"not-rely-on-time": "off",
"no-complex-fallback": "off",
"not-rely-on-block-hash": "off",
"reentrancy": "off",
"contract-name-camelcase": "off"
}
}
4 changes: 2 additions & 2 deletions packages/contracts/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[default]
[profile.default]
optimizer = true
optimizer_runs = 1000000
auto_detect_solc = true
src = "contracts"
out = "artifacts"
libs = ["../../node_modules", "node_modules", "lib"]

[ci]
[profile.ci]
verbosity = 4

# See more config options https://github.com/gakonst/foundry/tree/master/config
17 changes: 16 additions & 1 deletion packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HardhatUserConfig } from 'hardhat/types'
import 'solidity-coverage'
import * as dotenv from 'dotenv'
import './tasks/flatten'


const config: HardhatUserConfig = {
Expand All @@ -10,4 +9,20 @@ const config: HardhatUserConfig = {

},
},
solidity: {
compilers: [
{
version: "0.8.13",
settings: {
optimizer: {
enabled: true,
runs: 5000000, // see: https://github.com/ethereum/solidity/issues/5394#issue-379536332
},
},
},
]
}
}


module.exports = config;
16 changes: 11 additions & 5 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,32 @@
"build": "yarn build:contracts && yarn build:typescript && yarn build:go",
"build:go": "yarn sol-merger \"./contracts/**.sol\" ./flattened --export-plugin SPDXLicenseRemovePlugin & yarn sol-merger \"./test/harnesses/**.sol\" ./flattened --export-plugin SPDXLicenseRemovePlugin",
"build:contracts": "forge build",
"build:slither": "hardhat compile",
"build:typescript": "typechain --target ethers-v5 'artifacts/**/*json'",
"test": "forge test",
"lint:contracts:fix": "yarn prettier --write 'contracts/**/*.sol'",
"lint:contracts:fix": "yarn prettier --write 'contracts/**/*.sol' && solhint --fix -c .solhint.json --ignore-path .prettierignore contracts/**/*.sol test/**/*.sol",
"lint:fix": "yarn lint:contracts:fix",
"lint": "yarn lint:fix"
"lint": "yarn prettier 'contracts/**/*.sol'",
"ci:lint": "yarn prettier 'contracts/**/*.sol' --check && solhint -c .solhint.json --ignore-path .prettierignore contracts/**/*.sol test/**/*.sol"
},
"license": "MIT",
"devDependencies": {
"@typechain/ethers-v5": "^10.0.0",
"hardhat": "^2.9.6",
"prettier": "^2.6.2",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"prettier": "^2.7.1",
"prettier-plugin-solidity": "^1.0.0-dev.23",
"typechain": "^8.0.0",
"typescript": "^4.6.4"
"typescript": "^4.6.4",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5"
},
"dependencies": {
"@nodelib/fs.walk": "^1.2.8",
"@openzeppelin/contracts": "^4.6.0",
"@openzeppelin/contracts-upgradeable": "^4.6.0",
"dotenv": "^16.0.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^3.4.0",
"sol-merger": "^4.1.1",
"solidity-coverage": "^0.7.21",
"ts-node": "^10.8.0"
Expand Down
Loading