Refactor GitHub Actions Workflows for Improved CI/CD Performance #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-range.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 |