# This is a composite to allow sharing these steps into other workflows.
# It isn't a shared workflow, because then it isn't convenient to add
# additional package specific steps.
name: Shared CI Workflow
inputs:
  # Some commands work on the package name (yarn commands), other require the path (typedoc),
  # so we supply both.
  workspace_name:
    description: 'Name, from the package.json, of the package to build/test.'
    required: true
  workspace_path:
    description: 'Path to the package to release.'
    required: true

runs:
  using: composite
  steps:
    - name: Setup Yarn
      shell: bash
      run: yarn set version 3.4.1

    - name: Install Dependencies
      shell: bash
      # Install only the dependencies requires for the specific workspace.
      run: yarn workspaces focus ${{ inputs.workspace_name }}

    - name: Build
      shell: bash
      # This will build the package and its dependencies.
      run: yarn workspaces foreach -ptR --from '${{ inputs.workspace_name }}' run build

    - name: Lint
      shell: bash
      run: yarn workspace ${{ inputs.workspace_name }} lint

    - name: Test
      shell: bash
      # Run just the tests for the targeted package.
      run: yarn workspace ${{ inputs.workspace_name }} test

    - name: Build Docs
      shell: bash
      run: ./scripts/build-doc.sh ${{ inputs.workspace_path }}
