name: Docstring Parameters Sync
on:
  pull_request:
  push:
    branches:
      - nightly
  workflow_dispatch:
jobs:
  check-docstring-sync:
    name: "Check whether the docstring parameters are in-sync"
    runs-on: ubuntu-latest
    container:
      image: pytorch/conda-builder:cpu
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Setup Minconda
        uses: conda-incubator/setup-miniconda@v2
        with:
          miniconda-version: "latest"
          python-version: 3.8
      - name: Create Conda Env
        shell: bash -l {0}
        run: |
          conda clean --all --quiet --yes
          CONDA_ENV="${RUNNER_TEMP}/conda_environment_${GITHUB_RUN_ID}"
          conda create \
            --yes \
            --prefix "${CONDA_ENV}" \
            "python=3.8"
          echo "CONDA_ENV=${CONDA_ENV}" >> "${GITHUB_ENV}"
          echo "CONDA_RUN=conda run -p ${CONDA_ENV}" >> "${GITHUB_ENV}"
      - name: Run pydocstyle
        shell: bash -l {0}
        run: |
          ${CONDA_RUN} pip install pydocstyle
          ${CONDA_RUN} pydocstyle torchaudio
