diff --git a/.github/workflows/run-unit-tests-parallel.yml b/.github/workflows/run-unit-tests-parallel.yml new file mode 100644 index 0000000000..a197b4d24a --- /dev/null +++ b/.github/workflows/run-unit-tests-parallel.yml @@ -0,0 +1,57 @@ +name: Run unit tests parallel +on: + push: + branches: + - main + pull_request: + workflow_dispatch: {} + +jobs: + Build-And-Test-Server: + timeout-minutes: 210 + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + chunk: [1, 2, 3, 4] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Build o1js and prepare for tests + id: prepare + run: | + git submodule update --init --recursive + npm ci + npm run build + echo "test_count=$(find ./dist/node -name "*.unit-test.js" | wc -l)" >> $GITHUB_OUTPUT + touch profiling.md + + - name: Run unit tests + env: + TOTAL_TESTS: ${{ steps.prepare.outputs.test_count }} + CHUNK: ${{ matrix.chunk }} + CHUNKS: 4 # This should match the number of chunks in the matrix + run: | + start_index=$(( (TOTAL_TESTS * (CHUNK - 1) / CHUNKS) )) + end_index=$(( (TOTAL_TESTS * CHUNK / CHUNKS) )) + START_INDEX=$start_index END_INDEX=$end_index ./run-unit-tests.sh + continue-on-error: false + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v2 + with: + name: test-results-${{ matrix.chunk }} + path: profiling.md + + - name: Add to job summary + if: always() + run: | + echo "### Test Results for Chunk ${{ matrix.chunk }}" >> $GITHUB_STEP_SUMMARY + cat profiling.md >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml new file mode 100644 index 0000000000..0cf74e570d --- /dev/null +++ b/.github/workflows/run-unit-tests.yml @@ -0,0 +1,32 @@ +name: Run unit tests +on: + push: + branches: + - main + pull_request: + workflow_dispatch: {} + +jobs: + Build-And-Test-Server: + timeout-minutes: 210 + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '18' + - name: Build o1js and execute tests + env: + TEST_TYPE: ${{ matrix.test_type }} + continue-on-error: false + run: | + git submodule update --init --recursive + npm ci + npm run build + npm run test:unit + touch profiling.md + cat profiling.md >> $GITHUB_STEP_SUMMARY diff --git a/run-unit-tests-range.sh b/run-unit-tests-range.sh new file mode 100755 index 0000000000..ef7156fbf6 --- /dev/null +++ b/run-unit-tests-range.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -e +shopt -s globstar # to expand '**' into nested directories + +npm run build + +# Get all test files +test_files=(./dist/node/**/*.unit-test.js) +total_tests=${#test_files[@]} + +# If START_INDEX and END_INDEX are provided, use them +start=${START_INDEX:-0} +end=${END_INDEX:-$total_tests} + +# Run the specified range of tests +for ((i=start; i