mirror of
https://gh.wpcy.net/https://github.com/WeblateOrg/language-data.git
synced 2026-04-21 09:42:22 +08:00
87 lines
2.6 KiB
YAML
87 lines
2.6 KiB
YAML
# Copyright © Michal Čihař <michal@weblate.org>
|
|
#
|
|
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
# This file is maintained in https://github.com/WeblateOrg/meta/
|
|
name: Pre-commit check
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- renovate/**
|
|
- weblate
|
|
- dependabot/**
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
pre-commit:
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: |
|
|
~/.cache/prek
|
|
~/.cache/kingfisher
|
|
key: ${{ runner.os }}-prek-${{ hashFiles('.pre-commit-config.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-prek-
|
|
- name: Setup Python
|
|
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
with:
|
|
python-version: '3.14'
|
|
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
|
|
with:
|
|
version: 0.11.7
|
|
enable-cache: false
|
|
- name: detect method
|
|
id: detect
|
|
run: |
|
|
if test -f requirements-lint.txt ; then
|
|
echo "method=requirements" >> "$GITHUB_OUTPUT"
|
|
elif test -f pyproject.toml && grep -q dependency-groups pyproject.toml ; then
|
|
echo "method=pep735" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "method=uvx" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
- name: pre-commit (PEP 735)
|
|
if: steps.detect.outputs.method == 'pep735'
|
|
run: |
|
|
uv run --only-group pre-commit prek run --all-files --show-diff-on-failure
|
|
uv run --only-group pre-commit prek cache gc
|
|
env:
|
|
RUFF_OUTPUT_FORMAT: github
|
|
REUSE_OUTPUT_FORMAT: github
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: pre-commit (uvx)
|
|
if: steps.detect.outputs.method == 'uvx'
|
|
run: |
|
|
uvx prek run --all-files --show-diff-on-failure
|
|
uvx prek cache gc
|
|
env:
|
|
RUFF_OUTPUT_FORMAT: github
|
|
REUSE_OUTPUT_FORMAT: github
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: pre-commit (requirements)
|
|
if: steps.detect.outputs.method == 'requirements'
|
|
run: |
|
|
uv pip install --system -r requirements-lint.txt
|
|
prek run --all-files --show-diff-on-failure
|
|
prek cache gc
|
|
env:
|
|
RUFF_OUTPUT_FORMAT: github
|
|
REUSE_OUTPUT_FORMAT: github
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: diff
|
|
run: git diff
|
|
if: always()
|
|
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
|
|
if: always()
|
|
with:
|
|
msg: 'chore(pre-commit): apply code formatting'
|