This repository contains Reusable GitHub Actions Workflows for Solidity projects. Each workflow automates specific tasks to ensure code quality, performance, and maintainability.
- Build and Test Solidity Contracts
- Build Setup
- Coverage Tests
- Gas Tests
- Slither Tests
- Publish on Release
- License
This workflow is designed to set up the environment, run tests, perform static analysis, and generate coverage reports for Solidity contracts. It consists of the following sub-workflows:
- Setup: Checks out the code, sets up Node.js, caches node modules, and installs dependencies.
- Gas Test: Runs tests to check gas usage and comments on the pull request with a gas report if applicable.
- Slither Test: Performs static analysis using Slither and comments on the pull request with a checklist report.
- Coverage Test: Runs tests to generate coverage reports and uploads them to Codecov.
To use these workflows in your repository, you can call them from your GitHub Actions workflow files. For example:
name: Example Workflow
on:
push:
branches:
- main
jobs:
build-and-test:
uses: The-Poolz/solidity-workflows/.github/workflows/build.yml@master
Sets up the environment for other workflows by checking out code, setting up Node.js, caching node modules, and installing dependencies.
Steps:
- Checkout code.
- Setup Node.js environment.
- Cache node modules.
- Install dependencies if the cache is not hit.
name: "Setup | The-Poolz"
on:
workflow_call:
jobs:
setup:
uses: The-Poolz/solidity-workflows/.github/workflows/setup.yml
Runs on demand to generate and upload code coverage reports for Solidity projects.
Steps:
- Checkout code.
- Setup Node.js environment.
- Restore node modules cache.
- Run tests and generate coverage using
hardhat coverage
. - Upload coverage reports to Codecov.
name: "Coverage Test | The-Poolz"
on:
workflow_call:
jobs:
setup:
uses: The-Poolz/solidity-workflows/.github/workflows/setup.yml
coverage-test:
needs: setup
uses: The-Poolz/solidity-workflows/.github/workflows/coverage-test.yml
Runs on demand to test and report gas usage in Solidity contracts.
Steps:
- Checkout code.
- Setup Node.js environment.
- Restore node modules cache.
- Run tests with Hardhat and check for gas usage.
- If a gas report is generated, comment on the pull request with the report.
name: "Gas Tests | The-Poolz"
on:
workflow_call:
jobs:
setup:
uses: .The-Poolz/solidity-workflows/.github/workflows/setup.yml
test:
needs: setup
uses: The-Poolz/solidity-workflows/.github/workflows/gas-test.yml
Runs static analysis using Slither on Solidity contracts to identify potential issues and vulnerabilities.
Steps:
- Checkout code from the caller repository.
- Checkout the
solidity-workflows
repository. - Setup Node.js environment.
- Restore node modules cache.
- Install dependencies if the cache is not hit.
- Run Slither with specified arguments.
- Create or update a checklist as a pull request comment with the Slither report.
name: "Slither Test | The-Poolz"
on:
workflow_call:
jobs:
setup:
uses: The-Poolz/solidity-workflows/.github/workflows/setup.yml
slither:
needs: setup
uses: The-Poolz/solidity-workflows/.github/workflows/slither-test.yml
Automatically publishes the package to npm when a new release is tagged.
Steps:
- Checkout code from the
master
branch. - Setup Node.js environment.
- Get the release tag from the GitHub ref.
- Configure git user for commits.
- Set the version based on the release tag and push changes.
- Publish the package to npm.
name: "Publish on Release | The-Poolz"
on:
workflow_call:
jobs:
release:
uses: The-Poolz/solidity-workflows/.github/workflows/release.yml
This project is licensed under the MIT License.