salt/.github/workflows/pr-checks-action.yml
Pedro Algarvio a1f8fe74f1 Move the PR checks workflow to the main CI workflow
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-01-13 16:08:08 +00:00

62 lines
1.9 KiB
YAML

name: PR Checks
on:
workflow_call:
inputs:
changed-files:
required: true
type: string
description: JSON string containing information about changed files
secrets:
github-token:
description: The GitHub token to use to comment on PRs
required: true
permissions:
contents: read
pull-requests: write
jobs:
Check-Changed-Files-Docstrings:
name: Check Docstrings For Changed Files On PR
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && fromJSON(inputs.changed-files)['salt'] }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Dependencies
env:
PIP_EXTRA_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
run: |
python -m pip install --upgrade pip
pip install pre-commit pygithub
- name: Install Pre-Commit Hooks
run: |
pre-commit install --install-hooks
- name: Check Docstrings
id: check-known-missing-docstrings
continue-on-error: true
shell: bash
run: |
set -o pipefail
pre-commit run --hook-stage manual check-known-missing-docstrings \
--show-diff-on-failure --color=never \
--files ${{ join(fromJSON(inputs.changed-files)['salt_files'], ' ') }} | tee output.txt
- name: Comment on PR
# Comment on PRs if pre-commit triggered a failure
if: steps.check-known-missing-docstrings.outcome == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.github-token }}
run: |
python .github/workflows/scripts/pr-docstring-comments.py \
--org ${{ github.repository_owner }} \
--repo ${{ github.event.repository.name }} \
--issue ${{ github.event.number }} output.txt