diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 58f539a..980be48 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -12,21 +12,5 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - - name: Install pre-commit - run: sudo apt-get install pre-commit - shell: bash - - - name: Cache pre-commit environment - uses: actions/cache@v3 - with: - path: ~/.cache/pre-commit - key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - - - name: Run pre-commit - run: pre-commit run --show-diff-on-failure --color=always --all-files - shell: bash + - name: Run pre-commit checks + uses: ccao-data/actions/pre-commit@create-composite-pre-commit-action diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 862e135..2fdbc56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,3 +8,8 @@ repos: rev: v0.0.18 hooks: - id: shellcheck + - repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black + language_version: 3.10.12 diff --git a/pre-commit/action.yaml b/pre-commit/action.yaml new file mode 100644 index 0000000..568e705 --- /dev/null +++ b/pre-commit/action.yaml @@ -0,0 +1,22 @@ +name: pre-commit +description: Runs pre-commit hooks + +runs: + using: composite + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install pre-commit + run: sudo apt-get install pre-commit + shell: bash + + - name: Cache pre-commit environment + uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('/.pre-commit-config.yaml') }} + + - name: Run pre-commit + run: pre-commit run --show-diff-on-failure --color=always --all-files + shell: bash