Skip to content

Commit

Permalink
use composite actions instead of re-usable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
rootminus0x1 committed Dec 31, 2024
1 parent d3816b5 commit 2c0ef13
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 108 deletions.
98 changes: 98 additions & 0 deletions .github/actions/test-foundry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Test Foundry
description: "runs all the tests for a Foundry solidity project"

# secrets:
# DEFAULT_MAINNET_RPC_URL:
# description: "default API URL for accessing blockchain service"
# required: false
inputs:
# os:
# description: "Operating system to test"
# required: true
# type: string
foundry:
description: "Foundry version to test"
required: true

runs:
using: "composite"
steps:
- name: Check Environment
shell: bash
run: |
echo "runner.os=${{ runner.os }}"
python3 -c "import platform; info = f'{platform.system()} {platform.release()} {platform.version()} {platform.machine()}'; print('-' * len(info)); print(info); print('-' * len(info))"
- name: Install recent python
uses: actions/setup-python@v4
with:
python-version: "3.13"
- shell: bash
run: |
python3 --version
- name: Install Poetry (python package manager)
uses: snok/install-poetry@v1

# - name: Checkout repo
# uses: actions/checkout@v4
# with:
# submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ inputs.FOUNDRY }}
- shell: bash
run: |
forge --version
- name: Install project dependencies
shell: bash
run: |
yarn
- name: Run Prettier
# TODO: doesn't run on windows
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
yarn fmt:check
id: fmt

- name: Run Solhint
# TODO: doesn't run on windows
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
yarn lint
id: lint

- name: Run Slither
# TODO: doesn't run on windows
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
yarn slither
id: slither

- name: Run Forge build
shell: bash
run: |
yarn sizes
id: build

- name: Run Forge tests
shell: bash
run: |
echo MAINNET_RPC_URL: $MAINNET_RPC_URL
echo DEFAULT_MAINNET_RPC_URL: $DEFAULT_MAINNET_RPC_URL
yarn test
yarn coverage
yarn gas
id: test

- name: Check for changed repo files
shell: bash
run: |
yarn git-diffs
20 changes: 14 additions & 6 deletions .github/workflows/CI-test-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
description: "API KEY for accessing the ALchemy blockchain service"
required: false

env:
MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_KEY }}

jobs:
test_foundry_matrix:
strategy:
Expand All @@ -33,9 +36,14 @@ jobs:
foundry: v0.3.0
fail-fast: false # ensure all jobs run even if one fails

uses: ./.github/workflows/test-foundry.yml
secrets:
DEFAULT_MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_KEY }}
with:
os: ${{ matrix.os }}
foundry: ${{ matrix.foundry }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v3
with:
submodules: recursive

- name: Run Bao-base CI actions
uses: ./.github/actions/test-foundry
with:
foundry: ${{ matrix.foundry }}
98 changes: 0 additions & 98 deletions .github/workflows/test-foundry.yml

This file was deleted.

18 changes: 14 additions & 4 deletions bin-modules/CI/local-test-foundry.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Local CI

env:
FOUNDRY_PROFILE: ci

on:
workflow_dispatch:
inputs:
Expand All @@ -14,7 +17,14 @@ on:

jobs:
test_foundry:
uses: ./.github/workflows/test-foundry.yml
with:
os: ${{ inputs.os }}
foundry: ${{ inputs.foundry }}
runs-on: ${{ inputs.os }}
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v3
with:
submodules: recursive

- name: Run Bao-base CI actions
uses: ./.github/actions/test-foundry
with:
foundry: ${{ inputs.foundry }}

0 comments on commit 2c0ef13

Please sign in to comment.