Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Run tests on Github Actions (#119)
Browse files Browse the repository at this point in the history
* Run tests

* add info

* triage findings

* rename private vars

* fix if statements
  • Loading branch information
dnkolegov authored Jun 26, 2023
1 parent 7ccc729 commit 4d69d40
Show file tree
Hide file tree
Showing 24 changed files with 723 additions and 411 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/sast.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Static analysis

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
slither:
name: Slither check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Run Slither
uses: crytic/slither-action@v0.3.0
with:
fail-on: low

solhint:
name: Solhint check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: 'npm'
- name: Install Node dependencies
run: npm i --unsafe-perm
- name: Install solidity plugin
run: npm i --unsafe-perm prettier prettier-plugin-solidity
- name: Prettier check
run: npx prettier --check 'src/**/*.sol' 'test/*.sol'
- name: Solhint check
run: npx solhint 'src/**/*.sol'
10 changes: 2 additions & 8 deletions .github/workflows/blank.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Slither Analysis
name: Tests

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [ main ]

jobs:
analyze:
tests:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -24,9 +24,3 @@ jobs:

- name: Run tests
run: forge test -vvv

- name: Run Slither
uses: crytic/slither-action@dev-git-safe-workspace
with:
fail-on: low
target: 'src/'
21 changes: 21 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
semi: false,
singleQuote: true,
printWidth: 80,
endOfLine: 'auto',
tabWidth: 4,
trailingComma: 'all',
overrides: [
{
files: '*.sol',
options: {
parser: 'solidity-parse',
printWidth: 120,
tabWidth: 4,
useTabs: false,
singleQuote: false,
bracketSpacing: false,
},
},
],
}
21 changes: 19 additions & 2 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@
"rules": {
"compiler-version": ["error", "0.8.18"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"prettier/prettier": "error",
"no-global-import": "off"
"no-global-import": "off",
"no-unused-vars": "error",
"const-name-snakecase": "error",
"contract-name-camelcase": "error",
"event-name-camelcase": "error",
"func-name-mixedcase": "error",
"func-param-name-mixedcase": "error",
"modifier-name-mixedcase": "error",
"private-vars-leading-underscore": "error",
"var-name-mixedcase": "error",
"imports-on-top": "error",
"no-empty-blocks": "error",
"reason-string": "error",
"quotes": "error",
"use-forbidden-name": "error",
"visibility-modifier-order": "error",
"avoid-tx-origin": "error",
"reentrancy": "error",
"state-visibility": "error"
}
}
30 changes: 23 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
# ==============================================================================
# Deployment

NETWORK ?= localnet

check:
slither . --config-file ./slither.config.json
deploy-ipc:
./ops/deploy.sh $(NETWORK)

lint:
solhint 'src/**/*.sol'
# ==============================================================================
# Running security checks within the local computer

slither:
slither . --config-file ./slither.config.json

check-gateway:
docker run --rm -v $(shell pwd):/app -w /app mythril/myth:latest -v4 analyze --solc-json remappings.json ./src/Gateway.sol --solv 0.8.19

check-subnet:
docker run --rm -v $(shell pwd):/app -w /app mythril/myth:latest -v4 analyze --solc-json remappings.json ./src/SubnetActor.sol --solv 0.8.19

deploy-ipc:
./ops/deploy.sh $(NETWORK)
# ==============================================================================
# Development support

lint:
solhint 'src/**/*.sol'

format:
npx prettier --check -w 'src/**/*.sol' 'test/*.sol'

test:
forge test

.PHONY: deploy-ipc check lint check-subnet check-gateway
# ==============================================================================
.PHONY: deploy-ipc lint format check-subnet slither check-gateway format
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,13 @@ And to generate coverage report run
```bash
forge coverage
```

# Development

Before committing:

```bash
make format
make
make check
```
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4d69d40

Please sign in to comment.