|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: main |
| 6 | + paths: |
| 7 | + - ".github/workflows/hardhat-ci.yml" |
| 8 | + - "packages/**" |
| 9 | + - "config/**" |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - ".github/workflows/hardhat-ci.yml" |
| 13 | + - "packages/**" |
| 14 | + - "config/**" |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{github.workflow}}-${{github.ref}} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + list-packages: |
| 23 | + name: List packages |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + packages: ${{ steps.filter.outputs.changes }} |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + - uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: 18 |
| 32 | + - run: yq -p yaml -o json pnpm-lock.yaml | tee pnpm-lock.json |
| 33 | + - id: generate |
| 34 | + env: |
| 35 | + PACKAGE_IGNORE: | |
| 36 | + [ |
| 37 | + ".", |
| 38 | + "v-next/", |
| 39 | + "packages/common", |
| 40 | + "packages/eslint-plugin-hardhat-internal-rules", |
| 41 | + "packages/eslint-plugin-slow-imports", |
| 42 | + "packages/hardhat-core" |
| 43 | + ] |
| 44 | + COMMON_FILTERS: | |
| 45 | + [ |
| 46 | + ".github/workflows/hardhat-ci.yml", |
| 47 | + "config/**", |
| 48 | + "packages/common/**" |
| 49 | + ] |
| 50 | + run: | |
| 51 | + echo "filters<<EOF" >> $GITHUB_OUTPUT |
| 52 | + node scripts/generate-filters.js | |
| 53 | + yq -Po yaml 'with_entries(.key |= sub("^packages/", ""))' | |
| 54 | + tee -a $GITHUB_OUTPUT |
| 55 | + echo "EOF" >> $GITHUB_OUTPUT |
| 56 | + - id: filter |
| 57 | + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 |
| 58 | + with: |
| 59 | + filters: ${{ steps.generate.outputs.filters }} |
| 60 | + |
| 61 | + ci: |
| 62 | + needs: list-packages |
| 63 | + |
| 64 | + if: needs.list-packages.outputs.packages != '[]' |
| 65 | + |
| 66 | + strategy: |
| 67 | + fail-fast: false |
| 68 | + matrix: |
| 69 | + package: ${{ fromJson(needs.list-packages.outputs.packages) }} |
| 70 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 71 | + node: [18, 20, 22] |
| 72 | + exclude: |
| 73 | + - package: hardhat-vyper |
| 74 | + os: windows-latest |
| 75 | + - package: hardhat-vyper |
| 76 | + os: macos-latest |
| 77 | + - os: windows-latest |
| 78 | + node: 20 |
| 79 | + - os: macos-latest |
| 80 | + node: 20 |
| 81 | + - os: windows-latest |
| 82 | + node: 22 |
| 83 | + - os: macos-latest |
| 84 | + node: 22 |
| 85 | + |
| 86 | + name: "[${{ matrix.package }}] ci on ${{ matrix.os }} (Node ${{ matrix.node }})" |
| 87 | + runs-on: ${{ matrix.os }} |
| 88 | + defaults: |
| 89 | + run: |
| 90 | + working-directory: packages/${{ matrix.package }} |
| 91 | + |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v4 |
| 94 | + - name: Install pnpm |
| 95 | + uses: pnpm/action-setup@v3 |
| 96 | + with: |
| 97 | + version: 9 |
| 98 | + - uses: actions/setup-node@v4 |
| 99 | + with: |
| 100 | + node-version: ${{ matrix.node }} |
| 101 | + cache: "pnpm" |
| 102 | + - name: Install dependencies |
| 103 | + run: pnpm install --frozen-lockfile --prefer-offline |
| 104 | + - name: Build |
| 105 | + run: pnpm build |
| 106 | + - name: Run tests |
| 107 | + run: pnpm run ${{ matrix.package == 'hardhat-chai-matchers' && 'test:ci' || 'test' }} |
0 commit comments