salt/.github/workflows/pre-commit-action.yml
Pedro Algarvio 788fcd954c
Start running pre-commit under Python 3.10
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-01-30 21:04:38 +00:00

60 lines
2 KiB
YAML

name: Pre-Commit
on:
workflow_call:
inputs:
changed-files:
required: true
type: string
description: JSON string containing information about changed files
env:
PRE_COMMIT_VERSION: "2.21.0"
jobs:
Pre-Commit:
name: Run Pre-Commit Against Salt
runs-on: ubuntu-latest
container:
image: python:3.10-slim-buster
steps:
- name: Install System Deps
run: |
echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
apt-get update
apt-get install -y enchant git gcc make zlib1g-dev libc-dev libffi-dev g++ libxml2 libxml2-dev libxslt-dev libcurl4-openssl-dev libssl-dev libgnutls28-dev
apt-get install -y git/buster-backports
- uses: actions/checkout@v3
- name: Install Pre-Commit
env:
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
run: |
pip install wheel pre-commit==${PRE_COMMIT_VERSION}
pre-commit install --install-hooks
- name: Check ALL Files On Branch
if: github.event_name != 'pull_request'
env:
SKIP: lint-salt,lint-tests,remove-import-headers,rstcheck
run: |
pre-commit run --show-diff-on-failure --color=always --all-files
- name: Check Changed Files On PR
if: github.event_name == 'pull_request' && fromJSON(inputs.changed-files)['repo']
env:
SKIP: lint-salt,lint-tests
GH_ACTIONS_ANNOTATE: "1"
run: |
pre-commit run --show-diff-on-failure --color=always --files ${{ join(fromJSON(inputs.changed-files)['repo_files'], ' ') }}
- name: Check Docs On Deleted Files
if: github.event_name == 'pull_request' && fromJSON(inputs.changed-files)['deleted']
run: |
pre-commit run --show-diff-on-failure --color=always check-docs --files ${{ join(fromJSON(inputs.changed-files)['deleted_files'], ' ') }}