|
1 |
| -name: CI |
| 1 | +name: "TEST" |
2 | 2 |
|
3 | 3 | on:
|
4 |
| - push: |
5 | 4 | pull_request:
|
6 |
| - workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "main" |
7 | 8 |
|
8 | 9 | env:
|
9 |
| - FOUNDRY_PROFILE: ci |
| 10 | + API_KEY_INFURA: ${{secrets.API_KEY_INFURA}} |
| 11 | + API_KEY_OPTIMISTIC_ETHERSCAN: ${{secrets.API_KEY_OPTIMISTIC_ETHERSCAN}} |
| 12 | + API_KEY_ETHERSCAN: ${{secrets.API_KEY_ETHERSCAN}} |
| 13 | + API_KEY_ALCHEMY: ${{secrets.API_KEY_ALCHEMY}} |
10 | 14 |
|
11 | 15 | jobs:
|
12 |
| - check: |
13 |
| - strategy: |
14 |
| - fail-fast: true |
15 |
| - |
16 |
| - name: Foundry project |
17 |
| - runs-on: ubuntu-latest |
| 16 | + build: |
| 17 | + runs-on: "ubuntu-latest" |
18 | 18 | steps:
|
19 |
| - - uses: actions/checkout@v4 |
| 19 | + - name: "Check out the repo" |
| 20 | + uses: "actions/checkout@v4" |
| 21 | + |
| 22 | + - name: "Install Foundry" |
| 23 | + uses: "foundry-rs/foundry-toolchain@v1" |
20 | 24 | with:
|
21 |
| - submodules: recursive |
| 25 | + version: nightly |
22 | 26 |
|
23 |
| - - name: Install Foundry |
24 |
| - uses: foundry-rs/foundry-toolchain@v1 |
| 27 | + - name: "Install foundry libs" |
| 28 | + run: "forge install" |
25 | 29 |
|
26 |
| - - name: Show Forge version |
27 |
| - run: | |
28 |
| - forge --version |
| 30 | + - name: "Build the contracts" |
| 31 | + run: "forge build" |
29 | 32 |
|
30 |
| - - name: Run Forge fmt |
| 33 | + - name: "Add build summary" |
31 | 34 | run: |
|
32 |
| - forge fmt --check |
33 |
| - id: fmt |
| 35 | + echo "## Build result" >> $GITHUB_STEP_SUMMARY |
| 36 | + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY |
| 37 | +
|
| 38 | + test: |
| 39 | + needs: ["build"] |
| 40 | + runs-on: "ubuntu-latest" |
| 41 | + steps: |
| 42 | + - name: "Check out the repo" |
| 43 | + uses: "actions/checkout@v4" |
| 44 | + |
| 45 | + - name: "Install Foundry" |
| 46 | + uses: "foundry-rs/foundry-toolchain@v1" |
| 47 | + with: |
| 48 | + version: nightly |
| 49 | + |
| 50 | + - name: "Install pnpm" |
| 51 | + uses: "pnpm/action-setup@v4" |
| 52 | + with: |
| 53 | + version: 9.5.0 |
| 54 | + run_install: true |
| 55 | + |
| 56 | + - name: "Install pnpm dependencies" |
| 57 | + run: "pnpm install" |
| 58 | + |
| 59 | + - name: "Install foundry libs" |
| 60 | + run: "forge install" |
| 61 | + |
| 62 | + - name: "Build the contracts" |
| 63 | + run: "pnpm build" |
| 64 | + |
| 65 | + - name: "Show the Foundry config" |
| 66 | + run: "forge config" |
34 | 67 |
|
35 |
| - - name: Run Forge build |
| 68 | + - name: "Run the fork tests for Optimism" |
| 69 | + run: "pnpm test:op -vvv" |
| 70 | + |
| 71 | + - name: "Add test summary" |
36 | 72 | run: |
|
37 |
| - forge build --sizes |
38 |
| - id: build |
| 73 | + echo "## Tests result" >> $GITHUB_STEP_SUMMARY |
| 74 | + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY |
| 75 | +
|
| 76 | + coverage: |
| 77 | + needs: ["test"] |
| 78 | + runs-on: "ubuntu-latest" |
| 79 | + steps: |
| 80 | + - name: "Check out the repo" |
| 81 | + uses: "actions/checkout@v4" |
| 82 | + |
| 83 | + - name: "Install Foundry" |
| 84 | + uses: "foundry-rs/foundry-toolchain@v1" |
| 85 | + with: |
| 86 | + version: nightly |
| 87 | + |
| 88 | + - name: "Install pnpm" |
| 89 | + uses: "pnpm/action-setup@v4" |
| 90 | + with: |
| 91 | + version: 9.5.0 |
| 92 | + run_install: true |
| 93 | + |
| 94 | + - name: "Install pnpm dependencies" |
| 95 | + run: "pnpm install" |
39 | 96 |
|
40 |
| - - name: Run Forge tests |
| 97 | + - name: "Install foundry libs" |
| 98 | + run: "forge install" |
| 99 | + |
| 100 | + - name: "Build the contracts" |
| 101 | + run: "pnpm build" |
| 102 | + |
| 103 | + # Generate coverage report |
| 104 | + - name: Run coverage |
| 105 | + run: pnpm test:coverage --report summary --report lcov |
| 106 | + |
| 107 | + # Adjust the paths in this step to exclude specific directories from coverage analysis. |
| 108 | + - name: Filter directories |
41 | 109 | run: |
|
42 |
| - forge test -vvv |
43 |
| - id: test |
| 110 | + sudo apt update && sudo apt install -y lcov |
| 111 | + lcov --ignore-errors unused --remove lcov.info 'test/*' 'script/*' --output-file lcov.info --rc branch_coverage=1 |
| 112 | +
|
| 113 | + # This step automatically publishes a comprehensive coverage report as a comment on each push and |
| 114 | + # removes any previous comments. |
| 115 | + - name: Post coverage report |
| 116 | + if: github.event_name == 'pull_request' |
| 117 | + |
| 118 | + with: |
| 119 | + delete-old-comments: true |
| 120 | + lcov-file: ./lcov.info |
| 121 | + github-token: ${{ secrets.GITHUB_TOKEN }} # Adds a coverage summary comment to the PR. |
| 122 | + |
| 123 | + # This step verifies that the minimum coverage threshold is met and fails if it is not. |
| 124 | + - name: Verify minimum coverage |
| 125 | + uses: zgosalvez/github-actions-report-lcov@v4 |
| 126 | + with: |
| 127 | + coverage-files: ./lcov.info |
| 128 | + minimum-coverage: 80 # Set coverage threshold. |
0 commit comments