Skip to content

Commit

Permalink
chore: ci test and cov prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-something committed May 17, 2024
1 parent fcadbe4 commit fdc7473
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 1 deletion.
70 changes: 70 additions & 0 deletions .github/workflows/check_coverage_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Upload coverage on merge

on:
push:
branches:
- main

jobs:
upload-coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1
- name: Precompile using 0.8.14 and via-ir=false
run: yarn build
- name: Run coverage
shell: bash
run: forge coverage --report summary --report lcov
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Filter directories
run: lcov --remove lcov.info 'test/*' 'script/*' --output-file lcovNew.info --rc lcov_branch_coverage=1

- name: Retrieve previous coverage
uses: actions/download-artifact@v2
with:
name: coverage
path: lcov.info

- name: Verify previous coverage
uses: zgosalvez/github-actions-report-lcov@v4
with:
coverage-files: ./lcov.info

- name: Verify new coverage
uses: zgosalvez/github-actions-report-lcov@v4
with:
coverage-files: ./lcovNew.info

- name: Check if new >= old
run: |
old=$(awk -F" " '/lines/ {print $3}' lcov.info)
new=$(awk -F" " '/lines/ {print $3}' lcovNew.info)
if [ "$new" -lt "$old" ]; then
echo "Coverage decreased from $old to $new"
exit 1
fi
- name: Cleanup
run: |
rm lcov.info
mv lcovNew.info lcov.info
- name: Upload new coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: lcovNew.info
52 changes: 51 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,57 @@ jobs:
- name: Run tests
run: yarn test:integration


echidna-tests:
name: Echidna Test
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

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

- name: Compile contracts
run: |
forge build --build-info
- name: Run Echidna
uses: crytic/echidna-action@v2
with:
files: .
contract: GreeterInvariant
crytic-args: --ignore-compile

halmos-tests:
name: Run symbolic execution tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'

- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- name: Precompile using 0.8.14 and via-ir=false
run: yarn build

- name: Run tests
run: yarn test:integration

lint:
name: Lint Commit Messages
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/upload_coverage_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Upload coverage on merge

on:
push:
branches:
- main

jobs:
upload-coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1
- name: Precompile using 0.8.14 and via-ir=false
run: yarn build
- name: Run coverage
shell: bash
run: forge coverage --report summary --report lcov
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Filter directories
run: lcov --remove lcov.info 'test/*' 'script/*' --output-file lcov.info --rc lcov_branch_coverage=1
- name: Upload coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: lcov.info

0 comments on commit fdc7473

Please sign in to comment.