Skip to content

Commit

Permalink
Merge pull request #1 from ava-labs/ci
Browse files Browse the repository at this point in the history
Add CI workflows
  • Loading branch information
michaelkaplan13 authored Feb 13, 2024
2 parents 37dd3f8 + 7aac240 commit a5fcbe5
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Soldity Linter

on:
push:
branches:
- main
pull_request:
branches:
- "*"

jobs:
solhint:
runs-on: ubuntu-20.04
timeout-minutes: 2
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install solhint
run: |
npm install solhint -g
solhint --version
- name: Run Linter
run: ./scripts/lint.sh --sol-lint

format-solidity:
runs-on: ubuntu-20.04
timeout-minutes: 2
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
run: ./scripts/install_foundry.sh

- name: Check Solidity Formatting
run: |
export PATH=$PATH:$HOME/.foundry/bin
./scripts/lint.sh --sol-format-check
46 changes: 46 additions & 0 deletions .github/workflows/slither.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Slither Analyze

on:
push:
branches:
- main
pull_request:
branches:
- "*"

jobs:
slither-analyze:
name: Slither Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Install Slither
run: |
pip install slither-analyzer
- name: Install Foundry
run: ./scripts/install_foundry.sh

- name: Run Slither
run: |
export PATH=$PATH:$HOME/.foundry/bin
cd contracts
slither ./ --fail-none --sarif ./results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: contracts/results.sarif
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Solidity Unit Tests

on:
push:
branches:
- "*"

jobs:
solidity-unit-tests:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
run: ./scripts/install_foundry.sh

- name: Run unit tests
run: |
export PATH=$PATH:$HOME/.foundry/bin
cd contracts/
forge test -vvv
3 changes: 3 additions & 0 deletions contracts/slither.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"filter_paths": "lib"
}
20 changes: 20 additions & 0 deletions scripts/install_foundry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

set -e

# The foundry install script uses XDG_CONFIG_HOME as the root of the install.
# This can vary for different environments, so it is set to $HOME for consistency.
export XDG_CONFIG_HOME=$HOME

# This installs from ava-labs fork of the foundry repo.
FOUNDRY_VERSION=v0.1.0
curl -L https://raw.githubusercontent.com/ava-labs/foundry/${FOUNDRY_VERSION}/foundryup/install > /tmp/foundry-install-script
# Set the foundry version in the install script
# Avoid using sed -i due to macos m1 incompatibility
sed "s/\/ava-labs\/foundry\/master\/foundryup/\/ava-labs\/foundry\/${FOUNDRY_VERSION}\/foundryup/g" /tmp/foundry-install-script
cat /tmp/foundry-install-script | bash

export PATH=$PATH:$HOME/.foundry/bin:$HOME/.foundry:$HOME/.cargo/bin
foundryup --version ${FOUNDRY_VERSION}

0 comments on commit a5fcbe5

Please sign in to comment.