mirror of
https://github.com/status-im/nim-codex.git
synced 2025-02-23 07:58:39 +00:00
143 lines
4.7 KiB
YAML
143 lines
4.7 KiB
YAML
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:
|
|
fail-fast: false
|
|
matrix:
|
|
include: ${{ fromJson(inputs.matrix) }}
|
|
|
|
defaults:
|
|
run:
|
|
shell: ${{ matrix.shell }} {0}
|
|
|
|
name: ${{ matrix.os }}-${{ matrix.tests }}-${{ matrix.cpu }}-${{ matrix.nim_version }}
|
|
runs-on: ${{ matrix.builder }}
|
|
timeout-minutes: 120
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: Setup Nimbus Build System
|
|
uses: ./.github/actions/nimbus-build-system
|
|
with:
|
|
os: ${{ matrix.os }}
|
|
shell: ${{ matrix.shell }}
|
|
nim_version: ${{ matrix.nim_version }}
|
|
coverage: false
|
|
|
|
- name: Check runner resources for parallel integration tests
|
|
run: |
|
|
echo "Determining runner"
|
|
case "${{ matrix.os }}" in
|
|
linux) CPU=$(nproc --all)
|
|
RAM=$(awk '/MemTotal/ {print int($2 / 1024 / 1024 + 0.5)}' /proc/meminfo)
|
|
;;
|
|
macos) CPU=$(sysctl -n hw.ncpu)
|
|
RAM=$(sysctl -n hw.memsize | awk '{print $0/1073741824}')
|
|
sysctl -n hw.ncpu
|
|
;;
|
|
windows) CPU=$NUMBER_OF_PROCESSORS
|
|
RAM=$(systeminfo | awk '/Total Physical Memory:/ { gsub(/,/,"."); print int($4 + 0.5) }')
|
|
;;
|
|
*) CPU=2
|
|
RAM=8
|
|
echo "Unknown runner"
|
|
;;
|
|
esac
|
|
echo "CPU=${CPU}" >> $GITHUB_ENV
|
|
echo "RAM=${RAM}" >> $GITHUB_ENV
|
|
echo "TYPE=${RUNNER_ENVIRONMENT}" >> $GITHUB_ENV
|
|
|
|
# Set PARALLEL=1 if the runner has enough resources
|
|
if [[ ("${{ matrix.os }}" == "linux" || "${{ matrix.os }}" == "windows") && "${CPU}" -ge 16 ]]; then
|
|
echo "PARALLEL=1" >> $GITHUB_ENV
|
|
elif [[ "${{ matrix.os }}" == "macos" && "${CPU}" -ge 6 ]]; then
|
|
echo "PARALLEL=1" >> $GITHUB_ENV
|
|
else
|
|
echo "PARALLEL=0" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Show runner information
|
|
run: |
|
|
echo "OS: ${{ matrix.os }}"
|
|
echo "CPU: ${{ env.CPU }}"
|
|
echo "RAM: ${{ env.RAM }} GB"
|
|
echo "TYPE: ${{ env.TYPE }}"
|
|
echo "PARALLEL: ${{ env.PARALLEL }}"
|
|
|
|
## 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: Install Ethereum node dependencies
|
|
if: matrix.tests == 'contract' || matrix.tests == 'integration' || matrix.tests == 'tools' || matrix.tests == 'all'
|
|
working-directory: vendor/codex-contracts-eth
|
|
env:
|
|
MSYS2_PATH_TYPE: inherit
|
|
run: |
|
|
npm install
|
|
|
|
- name: Run Ethereum node with Codex contracts
|
|
if: matrix.tests == 'contract' || matrix.tests == 'integration' || matrix.tests == 'tools' || matrix.tests == 'all'
|
|
working-directory: vendor/codex-contracts-eth
|
|
env:
|
|
MSYS2_PATH_TYPE: inherit
|
|
run: |
|
|
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} PARALLEL=${{ env.PARALLEL }} DEBUG=${{ runner.debug }} testIntegration
|
|
|
|
- name: Upload integration tests log files
|
|
uses: actions/upload-artifact@v4
|
|
if: (matrix.tests == 'integration' || matrix.tests == 'all') && always()
|
|
with:
|
|
name: ${{ matrix.os }}-${{ matrix.cpu }}-${{ matrix.nim_version }}-${{ matrix.tests }}-tests-logs
|
|
path: tests/integration/logs/
|
|
retention-days: 1
|
|
|
|
## Part 4 Tools ##
|
|
- name: Tools tests
|
|
if: matrix.tests == 'tools' || matrix.tests == 'all'
|
|
run: make -j${ncpu} testTools
|
|
|
|
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
|