Skip to content

Commit

Permalink
ci(test): parallelise test suite using gh actions (#3271)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardobridge authored Jul 22, 2024
1 parent c3be075 commit 80c93e7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,30 @@ on:
workflow_dispatch:

jobs:
generate-matrix-with-packages:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
- id: generate-matrix
run: |
RESULT=$(node .github/workflows/scripts/get-all-packages-by-name.js)
echo "matrix=$RESULT" >> $GITHUB_OUTPUT
test:
timeout-minutes: 30
runs-on: ubuntu-latest
needs: generate-matrix-with-packages
permissions:
contents: read
strategy:
matrix:
node-version: [18.x, 20.x]
package: ${{fromJson(needs.generate-matrix-with-packages.outputs.matrix)}}
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -24,7 +40,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build
- run: npm run test
- run: npm run test --workspace ${{ matrix.package }}
env:
FORCE_COLOR: 1
- name: Notify about failures
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/scripts/get-all-packages-by-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fs = require('fs');

const packageNames = [];
fs.readdirSync('packages').forEach((pkg) => {
if (fs.statSync(`packages/${pkg}`).isDirectory()) {
const pkgJson = fs.readFileSync(`packages/${pkg}/package.json`, 'utf8');
packageNames.push(JSON.parse(pkgJson).name);
}
});

console.log(JSON.stringify(packageNames));
3 changes: 2 additions & 1 deletion packages/commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"scripts": {
"lint": "eslint --ext \".js,.ts,.tsx\" .",
"lint-fix": "npm run lint -- --fix"
"lint-fix": "npm run lint -- --fix",
"test": "echo \"No test specified\" && exit 0"
}
}

0 comments on commit 80c93e7

Please sign in to comment.