diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index c05ad30dcda5..e72e92e76d6f 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -13,35 +13,23 @@ concurrency: cancel-in-progress: true jobs: - prepare-yarn-cache: - name: Prepare yarn cache - strategy: - fail-fast: false - matrix: - # for some reason the Windows cache doesn't work - os: [ubuntu-latest, macOS-latest] - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: lts/* - cache: yarn - - - name: Validate cache - env: - # Use PnP and disable postinstall scripts as this just needs to - # populate the cache for the other jobs - YARN_NODE_LINKER: pnp - YARN_ENABLE_SCRIPTS: false - run: yarn --immutable + prepare-yarn-cache-ubuntu: + uses: ./.github/workflows/prepare-cache.yml + with: + os: ubuntu-latest + prepare-yarn-cache-macos: + uses: ./.github/workflows/prepare-cache.yml + with: + os: macos-latest + prepare-yarn-cache-windows: + uses: ./.github/workflows/prepare-cache.yml + with: + os: windows-latest ts-compatibility: name: TypeScript Compatibility runs-on: ubuntu-latest - needs: prepare-yarn-cache + needs: prepare-yarn-cache-ubuntu steps: - uses: actions/checkout@v3 @@ -63,7 +51,7 @@ jobs: lint: name: Lint runs-on: ubuntu-latest - needs: prepare-yarn-cache + needs: prepare-yarn-cache-ubuntu steps: - uses: actions/checkout@v3 @@ -87,7 +75,7 @@ jobs: yarn-validate: name: Validate Yarn dependencies and constraints runs-on: ubuntu-latest - needs: prepare-yarn-cache + needs: prepare-yarn-cache-ubuntu steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 @@ -99,68 +87,21 @@ jobs: - name: 'Check for duplicate dependencies (fix w/ "yarn dedupe")' run: yarn dedupe --check - test: - name: Node v${{ matrix.node-version }} on ${{ matrix.os }} (${{ matrix.shard }}) - strategy: - fail-fast: false - matrix: - node-version: [12.x, 14.x, 16.x, 17.x, 18.x] - os: [ubuntu-latest, macOS-latest, windows-latest] - shard: ['1/4', '2/4', '3/4', '4/4'] - runs-on: ${{ matrix.os }} - needs: prepare-yarn-cache - - steps: - - name: Set git config - shell: bash - run: git config --global core.symlinks true - if: runner.os == 'Windows' - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: yarn - - name: install - run: yarn --immutable - - name: build - run: yarn build:js - - name: Get number of CPU cores - id: cpu-cores - uses: SimenB/github-actions-cpu-cores@v1 - - name: run tests - run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }} - - test-jasmine: - name: Node LTS on ${{ matrix.os }} using jest-jasmine2 (${{ matrix.shard }}) - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - shard: ['1/4', '2/4', '3/4', '4/4'] - runs-on: ${{ matrix.os }} - needs: prepare-yarn-cache - - steps: - - name: Set git config - shell: bash - run: git config --global core.symlinks true - if: runner.os == 'Windows' - - uses: actions/checkout@v3 - - name: Use Node.js LTS - uses: actions/setup-node@v3 - with: - node-version: lts/* - cache: yarn - - name: install - run: yarn --immutable - - name: build - run: yarn build:js - - name: Get number of CPU cores - id: cpu-cores - uses: SimenB/github-actions-cpu-cores@v1 - - name: run tests using jest-jasmine - run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }} + test-ubuntu: + uses: ./.github/workflows/test.yml + needs: prepare-yarn-cache-ubuntu + with: + os: ubuntu-latest + test-macos: + uses: ./.github/workflows/test.yml + needs: prepare-yarn-cache-macos + with: + os: macos-latest + test-windows: + uses: ./.github/workflows/test.yml + needs: prepare-yarn-cache-windows + with: + os: windows-latest test-coverage: name: Node LTS on Ubuntu with coverage (${{ matrix.shard }}) @@ -169,7 +110,7 @@ jobs: matrix: shard: ['1/4', '2/4', '3/4', '4/4'] runs-on: ubuntu-latest - needs: prepare-yarn-cache + needs: prepare-yarn-cache-ubuntu steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/prepare-cache.yml b/.github/workflows/prepare-cache.yml new file mode 100644 index 000000000000..0ba407b5e519 --- /dev/null +++ b/.github/workflows/prepare-cache.yml @@ -0,0 +1,29 @@ +name: Prepare CI cache + +on: + workflow_call: + inputs: + os: + required: true + type: string + +jobs: + prepare-yarn-cache: + name: Prepare yarn cache for ${{ inputs.os }} + runs-on: ${{ inputs.os }} + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + + - name: Validate cache + env: + # Use PnP and disable postinstall scripts as this just needs to + # populate the cache for the other jobs + YARN_NODE_LINKER: pnp + YARN_ENABLE_SCRIPTS: false + run: yarn --immutable diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000000..0133043a6624 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,60 @@ +name: Test + +on: + workflow_call: + inputs: + os: + required: true + type: string + +jobs: + test: + strategy: + fail-fast: false + matrix: + node-version: [12.x, 14.x, 16.x, 17.x, 18.x] + shard: ['1/4', '2/4', '3/4', '4/4'] + name: Node v${{ matrix.node-version }} on ${{ inputs.os }} (${{ matrix.shard }}) + runs-on: ${{ inputs.os }} + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build:js + - name: Get number of CPU cores + id: cpu-cores + uses: SimenB/github-actions-cpu-cores@v1 + - name: run tests + run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }} + + test-jasmine: + strategy: + fail-fast: false + matrix: + shard: ['1/4', '2/4', '3/4', '4/4'] + name: Node LTS on ${{ inputs.os }} using jest-jasmine2 (${{ matrix.shard }}) + runs-on: ${{ inputs.os }} + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js LTS + uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build:js + - name: Get number of CPU cores + id: cpu-cores + uses: SimenB/github-actions-cpu-cores@v1 + - name: run tests using jest-jasmine + run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}