-
Notifications
You must be signed in to change notification settings - Fork 8
52 lines (44 loc) · 1.59 KB
/
linters.yml
File metadata and controls
52 lines (44 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Linters
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
name: "Frappe Linter"
runs-on: ubuntu-latest
container:
image: alpine:latest # latest used here for simplicity, not recommended
defaults:
run:
shell: sh
steps:
- name: fix tar dependency in alpine container image
run: |
apk --no-cache add tar nodejs npm python3 git bash py3-pip
npm install -g prettier
# check python modules installed versions
python3 -m pip freeze --local
pip install pre-commit --break-system-packages
- uses: actions/checkout@v6
- run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: Get changed files
id: file_changes
run: |
export DIFF=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }})
echo "Diff between ${{ github.base_ref }} and ${{ github.sha }}"
echo "files=$( echo "$DIFF" | xargs echo )" >> $GITHUB_OUTPUT
- name: Cache pre-commit since we use pre-commit from container
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Execute pre-commit
run: |
pre-commit run --color=always --show-diff-on-failure --files ${{ steps.file_changes.outputs.files }}