mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-25 16:55:08 +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
64
.github/workflows/pre-commit.yml
vendored
64
.github/workflows/pre-commit.yml
vendored
|
|
@ -14,21 +14,16 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- develop
|
- develop
|
||||||
paths:
|
|
||||||
- '.github/workflows/**'
|
|
||||||
- 'scripts/**'
|
|
||||||
- 'images/**'
|
|
||||||
- 'apps.json'
|
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
|
||||||
pre-commit:
|
|
||||||
if: ${{ !contains(github.event.pull_request.title, '[pre-commit-fix]') && !contains(github.event.pull_request.body, '[pre-commit-fix]') }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
autofix:
|
||||||
|
if: ${{ !contains(github.event.pull_request.title, '[pre-commit-fix]') && !contains(github.event.pull_request.body, '[pre-commit-fix]') }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
@ -36,14 +31,16 @@ jobs:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: '3.10.6'
|
||||||
|
|
||||||
- name: Install pre-commit
|
- name: Install dependencies
|
||||||
run: pip install pre-commit
|
run: |
|
||||||
|
pip install pre-commit
|
||||||
|
sudo apt-get install -y jq
|
||||||
|
|
||||||
- name: Cache pre-commit hooks
|
- name: Cache pre-commit
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pre-commit
|
path: ~/.cache/pre-commit
|
||||||
|
|
@ -51,32 +48,25 @@ jobs:
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
pre-commit-${{ runner.os }}-
|
pre-commit-${{ runner.os }}-
|
||||||
|
|
||||||
- name: Run pre-commit (autofix on changed files)
|
- name: Run pre-commit autofix
|
||||||
id: precommit
|
id: precommit
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
run: |
|
||||||
pre-commit run --from-ref origin/main --to-ref HEAD
|
pre-commit run --from-ref origin/main --to-ref HEAD
|
||||||
|
|
||||||
- name: Install jq
|
- name: Push auto-fixes back to PR
|
||||||
run: sudo apt-get install -y jq
|
|
||||||
|
|
||||||
- name: Push fixes back to PR
|
|
||||||
if: steps.precommit.outcome == 'failure'
|
if: steps.precommit.outcome == 'failure'
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git add .
|
git add .
|
||||||
|
|
||||||
# Read the mapping file
|
|
||||||
map_file="msg-map.json"
|
map_file="msg-map.json"
|
||||||
default_message="chore: [pre-commit-fix] Apply pre-commit auto-fixes"
|
default_message="chore: [pre-commit-fix] Apply pre-commit auto-fixes"
|
||||||
message="$default_message"
|
message="$default_message"
|
||||||
|
|
||||||
# Dynamically determine the commit message based on changed files
|
|
||||||
changed_files=$(git diff --cached --name-only)
|
changed_files=$(git diff --cached --name-only)
|
||||||
for file in $changed_files; do
|
for file in $changed_files; do
|
||||||
ext="${file##*.}"
|
ext=".$(echo "$file" | awk -F. '{print $NF}')"
|
||||||
ext=".$ext"
|
|
||||||
mapped_message=$(jq -r --arg ext "$ext" '.[$ext] // empty' "$map_file")
|
mapped_message=$(jq -r --arg ext "$ext" '.[$ext] // empty' "$map_file")
|
||||||
if [ -n "$mapped_message" ]; then
|
if [ -n "$mapped_message" ]; then
|
||||||
message="$mapped_message"
|
message="$mapped_message"
|
||||||
|
|
@ -86,27 +76,3 @@ jobs:
|
||||||
|
|
||||||
git commit -m "$message"
|
git commit -m "$message"
|
||||||
git push
|
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