Skip to content

Commit

Permalink
Add foundry coverage (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x authored Aug 10, 2022
1 parent 08594eb commit b2c8b50
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 14 deletions.
14 changes: 14 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
codecov:
require_ci_to_pass: false
# Team Yaml
coverage:
round: down
precision: 5

ignore:
- "*_generated.go" # ignore folders and all its contents
- "*.abigen.go" # wildcards accepted
- "*_string.go" # glob accepted
- "*_string.go" # glob accepted
# solidity test files
- 'packages/contracts/test/*'
30 changes: 27 additions & 3 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
name: Changeset integrity checker
on:
- pull_request_target
pull_request_target:
branches:
- master

jobs:
changesets-integrity-checker:
Expand All @@ -10,8 +12,30 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install Dependencies
run: yarn
- 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: Changeset Status
run: npx changeset status
52 changes: 46 additions & 6 deletions .github/workflows/foundry-tests.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,69 @@
on: [push]
on: [push,pull_request]

name: Foundry Tests

jobs:
check:
name: Packages/contracts
name: Foundry Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
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: Installing dependencies
working-directory: ./packages/contracts
run: yarn install
run: yarn install --frozen-lockfile --check-files

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

- name: Run tests
- name: Run Foundry Tests
working-directory: ./packages/contracts
run: forge test -vvv
run: forge coverage -vvv --report=lcov

- name: Run snapshot
working-directory: ./packages/contracts
run: forge snapshot >> $GITHUB_STEP_SUMMARY
run: forge snapshot >> $GITHUB_STEP_SUMMARY

- uses: codecov/codecov-action@v3
name: Send Coverage (Codecov)
with:
token: ${{ secrets.CODECOV }}
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
working-directory: ./packages/contracts/


- name: Send Coverage (Coveralls)
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: ./packages/contracts/lcov.info
base-path: ./packages/contracts/
flag-name: foundry
19 changes: 16 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
test:
name: Test
name: Go Coverage
runs-on: ${{ matrix.platform }}
strategy:
matrix:
Expand Down Expand Up @@ -66,7 +66,11 @@ jobs:
done
- name: Test
run: go test $(go work edit -json | jq -c -r '[.Use[].DiskPath] | map_values(. + "/...")[]') -coverprofile=profile.cov
uses: nick-fields/retry@v2
with:
command: go test $(go work edit -json | jq -c -r '[.Use[].DiskPath] | map_values(. + "/...")[]') -coverprofile=profile.cov
max_attempts: 4
timeout_minutes: 20
env:
ENABLE_MYSQL_TEST: true
MYSQL_HOST: 0.0.0.0
Expand All @@ -82,15 +86,24 @@ jobs:
run: |
echo "IGNORED=$(find . \( -name "*_generated.go" -o -name "*.abigen.go" -o -name "*_string.go" \) -print0 | xargs -0 ls | sed 's/.\/*//' | tr '\n' ',' | sed 's/,*\r*$//')" >> $GITHUB_ENV
- uses: codecov/codecov-action@v3
name: Send Coverage (Codecov)
with:
token: ${{ secrets.CODECOV }}
files: profile.cov
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)

# We customize the build step because by default
# We can not use ** because goveralls uses filepath.Match
# to match ignore files and it does not support it.
- name: Send coverage
- name: Send coverage (Coveralls)
uses: shogo82148/actions-goveralls@v1
with:
github-token: ${{ secrets.github_token }}
path-to-profile: profile.cov
ignore: ${{ env.IGNORED }}
flag-name: Go-${{ matrix.go-version }}

# changes allows us to only run a job on changed packages
changes:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-requires-reviews.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
ref: develop
ref: master

- name: Require-reviewers
uses: travelperk/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
types
flattened/
build/

# generated foundry coverage info
lcov.info
3 changes: 2 additions & 1 deletion packages/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ libs = ["../../node_modules", "node_modules", "lib"]

[profile.ci]
verbosity = 4
fuzz_runs = 1000

# See more config options https://github.com/gakonst/foundry/tree/master/config
# See more config options https://github.com/gakonst/foundry/tree/master/config

0 comments on commit b2c8b50

Please sign in to comment.