fix: Prevent Slither-action from reinstalling Foundry #296
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code coverage evaluation | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
pull_request: | |
types: [opened, synchronize, reopened, edited, ready_for_review] | |
env: | |
FOUNDRY_PROFILE: ci | |
jobs: | |
test-coverage: | |
name: Code coverage evaluation | |
runs-on: ubuntu-latest-m-16 | |
steps: | |
- name: Install LCOV and its dependencies on Linux | |
if: runner.os == 'Linux' | |
# Install LCOV so we can leverage lcov and genhtml commands | |
# uses: hrishikesh-kadam/setup-lcov@v1 # This only brings an older incompatible version so we're manually installing | |
working-directory: ${{github.workspace}} | |
run: | | |
VERSION="2.0" | |
mkdir lcov | |
cd lcov | |
sudo apt install alien -y | |
sudo apt install libcapture-tiny-perl -y | |
sudo apt install libdatetime-perl -y | |
wget https://github.com/linux-test-project/lcov/releases/download/v$VERSION/lcov-$VERSION-1.noarch.rpm | |
sudo alien lcov-$VERSION-1.noarch.rpm | |
sudo dpkg -i lcov_$VERSION-2_all.deb | |
lcov --version | |
- name: Install LCOV and its dependencies on MacOs | |
if: runner.os == 'macOS' | |
run: brew install lcov | |
shell: bash | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Clone repository dependencies | |
shell: bash | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "CloudOps Thrackle" | |
sudo apt-get update | |
sudo apt-get install -y python3-pip | |
pip3 install -r requirements.txt | |
- name: Install Foundry | |
run: | | |
curl -sSL https://raw.githubusercontent.com/thrackle-io/foundry/refs/heads/master/foundryup/foundryup -o $HOME/foundryup | |
FOUNDRY_DIR=$HOME/foundry bash $HOME/foundryup --version $(awk '$1~/^[^#]/' script/foundryScripts/foundry.lock) | |
echo "$HOME/foundry/bin" >> $GITHUB_PATH | |
- name: Build the repository | |
shell: bash | |
run: | | |
forge clean && forge build --optimize | |
- name: Run tests with coverage option | |
shell: bash | |
run: | | |
forge coverage --ffi --report lcov --no-match-path "*invariant*" --fuzz-runs 1 | |
- name: Filter the coverage reports and reformat them | |
shell: bash | |
run: | | |
lcov --extract lcov.info 'src/*' --rc lcov_branch_coverage=1 --rc derive_function_end_line=0 -o lcov.info | |
lcov -r lcov.info 'example' --rc lcov_branch_coverage=1 --rc derive_function_end_line=0 -o lcov.info | |
- name: Report the code coverage if pull request | |
if: ${{github.event_name}} == 'pull_request' | |
uses: zgosalvez/github-actions-report-lcov@v3 | |
with: | |
coverage-files: lcov.info | |
minimum-coverage: 0 | |
artifact-name: code-coverage-report | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
update-comment: false |