From fdc7473a8ed1a7a3f90f9b0a17b37be28cc16153 Mon Sep 17 00:00:00 2001 From: drgorillamd <83670532+drgorillamd@users.noreply.github.com> Date: Fri, 17 May 2024 17:58:41 +0200 Subject: [PATCH] chore: ci test and cov prototype --- .github/workflows/check_coverage_ci.yml | 70 ++++++++++++++++++++++++ .github/workflows/ci.yml | 52 +++++++++++++++++- .github/workflows/upload_coverage_ci.yml | 39 +++++++++++++ 3 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check_coverage_ci.yml create mode 100644 .github/workflows/upload_coverage_ci.yml diff --git a/.github/workflows/check_coverage_ci.yml b/.github/workflows/check_coverage_ci.yml new file mode 100644 index 00000000..3bd93de4 --- /dev/null +++ b/.github/workflows/check_coverage_ci.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78094509..7c848905 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/upload_coverage_ci.yml b/.github/workflows/upload_coverage_ci.yml new file mode 100644 index 00000000..8bde798a --- /dev/null +++ b/.github/workflows/upload_coverage_ci.yml @@ -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 \ No newline at end of file