mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-23 08:15:09 +00:00
ci: remove lint job
moving lint job to separate workflow
This commit is contained in:
parent
6cbfe06691
commit
075f353328
1 changed files with 14 additions and 48 deletions
62
.github/workflows/pre-commit.yml
vendored
62
.github/workflows/pre-commit.yml
vendored
|
|
@ -14,21 +14,16 @@ on:
|
|||
branches:
|
||||
- main
|
||||
- develop
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- 'scripts/**'
|
||||
- 'images/**'
|
||||
- 'apps.json'
|
||||
workflow_dispatch: {}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
autofix:
|
||||
if: ${{ !contains(github.event.pull_request.title, '[pre-commit-fix]') && !contains(github.event.pull_request.body, '[pre-commit-fix]') }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -36,14 +31,16 @@ jobs:
|
|||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
python-version: '3.10.6'
|
||||
|
||||
- name: Install pre-commit
|
||||
run: pip install pre-commit
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install pre-commit
|
||||
sudo apt-get install -y jq
|
||||
|
||||
- name: Cache pre-commit hooks
|
||||
- name: Cache pre-commit
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
|
|
@ -51,32 +48,25 @@ jobs:
|
|||
restore-keys: |
|
||||
pre-commit-${{ runner.os }}-
|
||||
|
||||
- name: Run pre-commit (autofix on changed files)
|
||||
- name: Run pre-commit autofix
|
||||
id: precommit
|
||||
continue-on-error: true
|
||||
run: |
|
||||
pre-commit run --from-ref origin/main --to-ref HEAD
|
||||
|
||||
- name: Install jq
|
||||
run: sudo apt-get install -y jq
|
||||
|
||||
- name: Push fixes back to PR
|
||||
- name: Push auto-fixes back to PR
|
||||
if: steps.precommit.outcome == 'failure'
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add .
|
||||
|
||||
# Read the mapping file
|
||||
map_file="msg-map.json"
|
||||
default_message="chore: [pre-commit-fix] Apply pre-commit auto-fixes"
|
||||
message="$default_message"
|
||||
|
||||
# Dynamically determine the commit message based on changed files
|
||||
changed_files=$(git diff --cached --name-only)
|
||||
for file in $changed_files; do
|
||||
ext="${file##*.}"
|
||||
ext=".$ext"
|
||||
ext=".$(echo "$file" | awk -F. '{print $NF}')"
|
||||
mapped_message=$(jq -r --arg ext "$ext" '.[$ext] // empty' "$map_file")
|
||||
if [ -n "$mapped_message" ]; then
|
||||
message="$mapped_message"
|
||||
|
|
@ -86,27 +76,3 @@ jobs:
|
|||
|
||||
git commit -m "$message"
|
||||
git push
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.10.6"
|
||||
|
||||
- name: Setup Go (for shfmt)
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "^1.14"
|
||||
|
||||
- name: Install pre-commit
|
||||
run: pip install -U pre-commit
|
||||
|
||||
- name: Lint
|
||||
run: pre-commit run --color=always --all-files
|
||||
env:
|
||||
GO111MODULE: on
|
||||
|
|
|
|||
Loading…
Reference in a new issue