From 4257d2848cda9032212059575c09e2652c47e0bf Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 10 Apr 2022 12:27:52 -0400 Subject: [PATCH] Document parallel builds for GitHub Actions --- docs/recipes/splitting-tests-ci.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/recipes/splitting-tests-ci.md b/docs/recipes/splitting-tests-ci.md index 95849d3dd..354a72762 100644 --- a/docs/recipes/splitting-tests-ci.md +++ b/docs/recipes/splitting-tests-ci.md @@ -20,3 +20,33 @@ export default { sortTestFiles: (file1, file2) => testData[file1].order - testData[file2].order, }; ``` + +## Splitting tests on GitHub Actions + +Although GitHub Actions doesn't support parallel builds out-of-the-box with AVA, you can configure it manually by using a matrix: + +**`.github/workflows/test.yml`:** + +```yml +on: push +jobs: + test: + strategy: + # Don't cancel test runs if one fails + fail-fast: false + # Run 4 jobs in parallel, each executing a subset of all tests + matrix: + node_index: [0, 1, 2, 3] + total_nodes: [4] + + runs-on: ubuntu-latest + steps: + # Check out code and perform setup steps + # ... + + - name: Test + run: npx ava + env: + CI_NODE_INDEX: ${{ matrix.node_index }} + CI_NODE_TOTAL: ${{ matrix.total_nodes }} +```