diff --git a/.github/workflows/test-workflow.yml b/.github/workflows/test-workflow.yml new file mode 100644 index 0000000..773fef1 --- /dev/null +++ b/.github/workflows/test-workflow.yml @@ -0,0 +1,41 @@ +name: Test workflow + +on: + workflow_call: + inputs: + node-version: + required: true + type: number + +jobs: + define-matrix: + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.packages.outputs.packages }} + steps: + - uses: actions/checkout@v4 + - name: Define packages + id: packages + run: | + echo "packages=$(ls -d packages/* | xargs -n 1 basename | jq -R . | jq -s -c .)" >> "$GITHUB_OUTPUT" + + test: + name: '${{ matrix.package }} - Node.js v${{ inputs.node-version }}' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: ${{ fromJSON(needs.define-matrix.outputs.packages) }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: '${{ inputs.node-version }}' + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + cd packages/${{ matrix.package }} + npm install + - name: Run tests + run: | + cd packages/${{ matrix.package }} + npm run test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8d8e23d..ebc8332 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,30 +10,17 @@ on: - reopened jobs: - test: - name: 'Node.js v${{ matrix.node }}' - runs-on: ubuntu-latest - strategy: - matrix: - node: - - 18 - - 20 - - 22 - steps: - - uses: actions/setup-node@v1 - with: - node-version: '${{ matrix.node }}' - - uses: actions/checkout@v2 - - name: 'Cache node_modules' - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-node-v${{ matrix.node }}- - - name: Install Dependencies - run: npm install - - name: Install Playwright - run: npx playwright install - - name: Run All Node.js Tests - run: npm run test + test-node-v14: + uses: ./.github/workflows/test-workflow.yml + with: + node-version: 18 + + test-node-v16: + uses: ./.github/workflows/test-workflow.yml + with: + node-version: 20 + + test-node-v18: + uses: ./.github/workflows/test-workflow.yml + with: + node-version: 22 diff --git a/lerna.json b/lerna.json index 694fb54..2f89687 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "packages": ["packages/*"], "version": "1.0.0" -} +} \ No newline at end of file diff --git a/package.json b/package.json index e017696..1765eb9 100644 --- a/package.json +++ b/package.json @@ -24,4 +24,4 @@ "lerna": "^5.0.0", "rimraf": "^3.0.2" } -} +} \ No newline at end of file