-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (90 loc) · 2.73 KB
/
linter.yml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Lint codebase
"on":
push:
branches: [main, development]
tags-ignore: ["**"]
pull_request:
jobs:
lint:
name: Run pre-commit
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Checkout code (PR)
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v3
with:
# Infite depth (without retrieving unrelated branches) – search
# <https://git-scm.com/docs/shallow> for this magic number...
fetch-depth: 2147483647
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout code
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@v3
- name: Restore cached dependencies
id: cache-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cache/pre-commit
~/.cache/pip
~/.npm
~/.local/bin
~/.cache/go-build
~/go/pkg/mod
~/go/bin
# yamllint disable rule:line-length
# yamllint disable rule:quoted-strings
# prettier-ignore
key: "pre-commit-cache-\
${{ hashFiles('.pre-commit-config.yaml', '.github/scripts/setup-pre-commit.sh') }}"
# yamllint enable rule:quoted-strings
# yamllint enable rule:line-length
- name: Setup PATH
run: |
mkdir -p "$HOME/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: false
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
env:
USE_PIPX: "false"
run: .github/scripts/setup-pre-commit.sh
- name: Run pre-commit (PR)
if: ${{ github.event_name == 'pull_request' }}
run: |
pre-commit run --color=always \
--from-ref ${{ github.event.pull_request.base.sha }} \
--to-ref HEAD
env:
GH_ACTION_OUTPUT: true
- name: Run pre-commit
if: ${{ github.event_name == 'push' }}
run: pre-commit run --color=always --all-files
env:
GH_ACTION_OUTPUT: true
- name: Cache dependencies
uses: actions/cache/save@v3
if: always()
with:
path: |
~/.cache/pre-commit
~/.cache/pip
~/.npm
~/.local/bin
~/.cache/go-build
~/go/pkg/mod
~/go/bin
key: ${{ steps.cache-restore.outputs.cache-primary-key }}