diff --git a/.github/workflows/ci-reusable.yml b/.github/workflows/ci-reusable.yml new file mode 100644 index 00000000..401ef161 --- /dev/null +++ b/.github/workflows/ci-reusable.yml @@ -0,0 +1,79 @@ +name: Reusable - CI + +on: + workflow_call: + inputs: + matrix: + type: string + cache_nonce: + default: '0' + description: Allows for easily busting actions/cache caches + required: false + type: string + +env: + cache_nonce: ${{ inputs.cache_nonce }} + +jobs: + build: + strategy: + matrix: + include: ${{ fromJson(inputs.matrix) }} + + defaults: + run: + shell: ${{ matrix.shell }} {0} + + name: '${{ matrix.os }}-${{ matrix.cpu }}-${{ matrix.nim_version }}-${{ matrix.tests }}' + runs-on: ${{ matrix.builder }} + timeout-minutes: 80 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Nimbus Build System + uses: ./.github/actions/nimbus-build-system + with: + os: ${{ matrix.os }} + shell: ${{ matrix.shell }} + nim_version: ${{ matrix.nim_version }} + + ## Part 1 Tests ## + - name: Unit tests + if: matrix.tests == 'unittest' || matrix.tests == 'all' + run: make -j${ncpu} test + + # workaround for https://github.com/NomicFoundation/hardhat/issues/3877 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18.15 + + - name: Start Ethereum node with Codex contracts + if: matrix.tests == 'contract' || matrix.tests == 'integration' || matrix.tests == 'all' + working-directory: vendor/codex-contracts-eth + env: + MSYS2_PATH_TYPE: inherit + run: | + npm install + npm start & + + ## Part 2 Tests ## + - name: Contract tests + if: matrix.tests == 'contract' || matrix.tests == 'all' + run: make -j${ncpu} testContracts + + ## Part 3 Tests ## + - name: Integration tests + if: matrix.tests == 'integration' || matrix.tests == 'all' + run: make -j${ncpu} testIntegration + + status: + if: always() + needs: [build] + runs-on: ubuntu-latest + steps: + - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }} + run: exit 1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e09b9f9..905f6505 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,93 +1,45 @@ name: CI + on: push: branches: - master pull_request: workflow_dispatch: + env: cache_nonce: 0 # Allows for easily busting actions/cache caches nim_version: v1.6.14 + + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true + jobs: - build: - strategy: - matrix: - include: - - os: linux - cpu: amd64 - builder: ubuntu-latest - shell: bash --noprofile --norc -e -o pipefail - tests: all - - os: macos - cpu: amd64 - builder: macos-latest - shell: bash --noprofile --norc -e -o pipefail - tests: all - - os: windows - cpu: amd64 - builder: windows-latest - shell: msys2 - tests: unittest - - os: windows - cpu: amd64 - builder: windows-latest - shell: msys2 - tests: contract - - os: windows - cpu: amd64 - builder: windows-latest - shell: msys2 - tests: integration - - defaults: - run: - shell: ${{ matrix.shell }} {0} - - name: '${{ matrix.os }}-${{ matrix.cpu }}-tests-${{ matrix.tests }}' - runs-on: ${{ matrix.builder }} - timeout-minutes: 80 + matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.matrix.outputs.matrix }} + cache_nonce: ${{ env.cache_nonce }} steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - submodules: recursive + - name: Compute matrix + id: matrix + uses: fabiocaccamo/create-matrix-action@v4 + with: + matrix: | + os {linux}, cpu {amd64}, builder {ubuntu-latest}, tests {all}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} + os {macos}, cpu {amd64}, builder {macos-latest}, tests {all}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} + os {windows}, cpu {amd64}, builder {windows-latest}, tests {unittest}, nim_version {${{ env.nim_version }}}, shell {msys2} + os {windows}, cpu {amd64}, builder {windows-latest}, tests {contract}, nim_version {${{ env.nim_version }}}, shell {msys2} + os {windows}, cpu {amd64}, builder {windows-latest}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {msys2} - - name: Setup Nimbus Build System - uses: ./.github/actions/nimbus-build-system - with: - os: ${{ matrix.os }} - shell: ${{ matrix.shell }} - nim_version: ${{ env.nim_version }} - - ## Part 1 Tests ## - - name: Unit tests - if: matrix.tests == 'unittest' || matrix.tests == 'all' - run: make -j${ncpu} test - - # workaround for https://github.com/NomicFoundation/hardhat/issues/3877 - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 18.15 - - - name: Start Ethereum node with Codex contracts - if: matrix.tests == 'contract' || matrix.tests == 'integration' || matrix.tests == 'all' - working-directory: vendor/codex-contracts-eth - env: - MSYS2_PATH_TYPE: inherit - run: | - npm install - npm start & - - ## Part 2 Tests ## - - name: Contract tests - if: matrix.tests == 'contract' || matrix.tests == 'all' - run: make -j${ncpu} testContracts - - ## Part 3 Tests ## - - name: Integration tests - if: matrix.tests == 'integration' || matrix.tests == 'all' - run: make -j${ncpu} testIntegration + build: + needs: matrix + uses: ./.github/workflows/ci-reusable.yml + with: + matrix: ${{ needs.matrix.outputs.matrix }} + cache_nonce: ${{ needs.matrix.outputs.cache_nonce }} coverage: continue-on-error: true diff --git a/.github/workflows/docker-reusable.yml b/.github/workflows/docker-reusable.yml index 816b0791..ebd37ae8 100644 --- a/.github/workflows/docker-reusable.yml +++ b/.github/workflows/docker-reusable.yml @@ -1,4 +1,4 @@ -name: Docker - Reusable +name: Reusable - Docker on: diff --git a/.github/workflows/nim-matrix.yml b/.github/workflows/nim-matrix.yml new file mode 100644 index 00000000..87306ad8 --- /dev/null +++ b/.github/workflows/nim-matrix.yml @@ -0,0 +1,30 @@ +name: Nim matrix + +on: + merge_group: + workflow_dispatch: + +env: + cache_nonce: 0 # Allows for easily busting actions/cache caches + nim_version: v1.6.14, v1.6.16, v1.6.18, v2.0.0, v2.0.2 + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.matrix.outputs.matrix }} + cache_nonce: ${{ env.cache_nonce }} + steps: + - name: Compute matrix + id: matrix + uses: fabiocaccamo/create-matrix-action@v4 + with: + matrix: | + os {linux}, cpu {amd64}, builder {ubuntu-latest}, tests {all}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} + + build: + needs: matrix + uses: ./.github/workflows/ci-reusable.yml + with: + matrix: ${{ needs.matrix.outputs.matrix }} + cache_nonce: ${{ needs.matrix.outputs.cache_nonce }}