diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index a87cdd8f..87717166 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -22,8 +22,43 @@ jobs: PACKAGES=$(find . -name package.json -not -path "*/node_modules/*" -exec dirname {} \; | sed 's/^\.\///' | jq -R -s -c 'split("\n")[:-1]') echo "packages=$PACKAGES" >> $GITHUB_OUTPUT - build: + test: needs: [detect-packages] + strategy: + matrix: + package: ${{ fromJson(needs.detect-packages.outputs.packages) }} + name: Test ${{ matrix.package }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + working-directory: src/${{ matrix.package }} + run: npm ci + + - name: Check if tests exist + id: check-tests + working-directory: src/${{ matrix.package }} + run: | + if npm run test --silent 2>/dev/null; then + echo "has-tests=true" >> $GITHUB_OUTPUT + else + echo "has-tests=false" >> $GITHUB_OUTPUT + fi + continue-on-error: true + + - name: Run tests + if: steps.check-tests.outputs.has-tests == 'true' + working-directory: src/${{ matrix.package }} + run: npm test + + build: + needs: [detect-packages, test] strategy: matrix: package: ${{ fromJson(needs.detect-packages.outputs.packages) }}