Skip to content
play

GitHub Action

CPU Core Count

v2.0.0 Latest version

CPU Core Count

play

CPU Core Count

Get the number of available cores on the runner

Installation

Copy and paste the following snippet into your .yml file.

              

- name: CPU Core Count

uses: SimenB/[email protected]

Learn more about this action in SimenB/github-actions-cpu-cores

Choose a version

github-actions-cpu-cores

Uses os.availableParallelism (or os.cpus if availableParallelism is unavailable) to figure out how many logical cores are available on the runner.

name: Node CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - "**"

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]
    runs-on: ${{ matrix.os }}

    steps:
      - name: Get number of CPU cores
        uses: SimenB/github-actions-cpu-cores@v2
        id: cpu-cores
      - name: run tests
        run: npx jest --max-workers ${{ steps.cpu-cores.outputs.count }}