feat(medusa-payment-paypal,medusa-payment-stripe): speed up unit tests in CI (#6806)
* chore: shard unit tests * chore: move paypal and stripe to swc * chore: update actions * chore: refactor http paypal client * chore: added changeset * chore: remove medusa changes
This commit is contained in:
189
.github/workflows/action.yml
vendored
189
.github/workflows/action.yml
vendored
@@ -13,54 +13,8 @@ jobs:
|
||||
module-chunks: ${{ steps.set-module-chunks.outputs.chunks }}
|
||||
api-matrix: ${{ steps.set-api-matrix.outputs.matrix }}
|
||||
api-chunks: ${{ steps.set-api-chunks.outputs.chunks }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16.10.0"
|
||||
cache: "yarn"
|
||||
|
||||
- name: Assert changed
|
||||
run: ./scripts/assert-changed-files-actions.sh "packages"
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/cache-deps
|
||||
with:
|
||||
extension: pipeline
|
||||
|
||||
- id: set-module-chunks
|
||||
name: Set Module Chunks
|
||||
working-directory: integration-tests/modules
|
||||
run: echo "chunks=$(yarn run jest --listTests --json | jq -cM '[_nwise(length / 3 | ceil)]')" >> $GITHUB_OUTPUT
|
||||
|
||||
- id: set-module-matrix
|
||||
name: Set Module Matrix
|
||||
run: echo "matrix=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
|
||||
env:
|
||||
CHUNKS: ${{ steps.set-module-chunks.outputs.chunks }}
|
||||
|
||||
- id: set-api-chunks
|
||||
name: Set API Chunks
|
||||
working-directory: integration-tests/api
|
||||
run: echo "chunks=$(yarn run jest --listTests --json | jq -cM '[_nwise(length / 3 | ceil)]')" >> $GITHUB_OUTPUT
|
||||
|
||||
- id: set-api-matrix
|
||||
name: Set API Matrix
|
||||
run: echo "matrix=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
|
||||
env:
|
||||
CHUNKS: ${{ steps.set-api-chunks.outputs.chunks }}
|
||||
|
||||
unit-tests:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
unit-tests-matrix: ${{ steps.set-unit-tests-matrix.outputs.matrix }}
|
||||
unit-tests-chunks: ${{ steps.set-unit-tests-chunks.outputs.chunks }}
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
@@ -86,11 +40,68 @@ jobs:
|
||||
with:
|
||||
extension: pipeline
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn build
|
||||
- id: set-module-chunks
|
||||
name: Set Module Chunks
|
||||
working-directory: integration-tests/modules
|
||||
run: echo "chunks=$(yarn run jest --listTests --json | jq -cM '[_nwise(length / 2 | ceil)]')" >> $GITHUB_OUTPUT
|
||||
|
||||
- id: set-module-matrix
|
||||
name: Set Module Matrix
|
||||
run: echo "matrix=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
|
||||
env:
|
||||
CHUNKS: ${{ steps.set-module-chunks.outputs.chunks }}
|
||||
|
||||
- id: set-api-chunks
|
||||
name: Set API Chunks
|
||||
working-directory: integration-tests/api
|
||||
run: echo "chunks=$(yarn run jest --listTests --json | jq -cM '[_nwise(length / 2 | ceil)]')" >> $GITHUB_OUTPUT
|
||||
|
||||
- id: set-api-matrix
|
||||
name: Set API Matrix
|
||||
run: echo "matrix=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
|
||||
env:
|
||||
CHUNKS: ${{ steps.set-api-chunks.outputs.chunks }}
|
||||
|
||||
- id: set-unit-tests-chunks
|
||||
name: Set Unit Tests Chunks
|
||||
run: echo "chunks=$(yarn workspaces list --json | jq -j '[inputs | .name]' | jq -r | jq -cM '[_nwise(length / 2 | ceil)]')" >> $GITHUB_OUTPUT
|
||||
|
||||
- id: set-unit-tests-matrix
|
||||
name: Set Unit Tests Matrix
|
||||
run: echo "matrix=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
|
||||
env:
|
||||
CHUNKS: ${{ steps.set-unit-tests-chunks.outputs.chunks }}
|
||||
|
||||
unit-tests-matrix:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
name: Shard (${{ matrix.chunk }}) Unit Tests
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
chunk: ${{ fromJSON(needs.setup.outputs.unit-tests-matrix) }}
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Assert changed
|
||||
run: ./scripts/assert-changed-files-actions.sh "packages"
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/cache-deps
|
||||
with:
|
||||
extension: pipeline
|
||||
|
||||
- name: Run unit tests
|
||||
run: yarn test
|
||||
run: yarn test:chunk
|
||||
env:
|
||||
CHUNK: ${{ matrix.chunk }}
|
||||
CHUNKS: ${{ needs.setup.outputs.unit-tests-chunks }}
|
||||
|
||||
integration-tests-packages:
|
||||
needs: setup
|
||||
@@ -123,30 +134,16 @@ jobs:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
cache: "yarn"
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/cache-deps
|
||||
with:
|
||||
extension: pipeline
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn build
|
||||
|
||||
- name: Run integration tests
|
||||
run: yarn test:integration:packages
|
||||
env:
|
||||
@@ -189,30 +186,16 @@ jobs:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16.10.0"
|
||||
cache: "yarn"
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/cache-deps
|
||||
with:
|
||||
extension: pipeline
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn build
|
||||
|
||||
- name: Run API integration tests
|
||||
run: yarn test:integration:api
|
||||
env:
|
||||
@@ -237,6 +220,21 @@ jobs:
|
||||
- run: exit 0
|
||||
if: ${{ contains(needs.integration-tests-api-matrix.result, 'success') }}
|
||||
|
||||
unit-tests:
|
||||
if: ${{ always() }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: unit-tests-matrix
|
||||
steps:
|
||||
- run: exit 1
|
||||
if: >-
|
||||
${{
|
||||
contains(needs.unit-tests-matrix.result, 'failure')
|
||||
|| contains(needs.unit-tests-matrix.result, 'cancelled')
|
||||
|| contains(needs.unit-tests-matrix.result, 'skipped')
|
||||
}}
|
||||
- run: exit 0
|
||||
if: ${{ contains(needs.unit-tests-matrix.result, 'success') }}
|
||||
|
||||
integration-tests-plugins:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
@@ -259,11 +257,6 @@ jobs:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
@@ -280,9 +273,6 @@ jobs:
|
||||
with:
|
||||
extension: pipeline
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn build
|
||||
|
||||
- name: Run plugin integration tests
|
||||
run: yarn test:integration:plugins
|
||||
env:
|
||||
@@ -316,30 +306,16 @@ jobs:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16.10.0"
|
||||
cache: "yarn"
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/cache-deps
|
||||
with:
|
||||
extension: pipeline
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn build
|
||||
|
||||
- name: Run Modules integration tests
|
||||
run: yarn test:integration:modules
|
||||
env:
|
||||
@@ -386,22 +362,11 @@ jobs:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16.10.0"
|
||||
cache: "yarn"
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/cache-deps
|
||||
with:
|
||||
|
||||
Reference in New Issue
Block a user