-
Notifications
You must be signed in to change notification settings - Fork 5
74 lines (62 loc) · 2 KB
/
ci.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
---
name: Pi-Bot CI
# yamllint disable-line rule:truthy
on:
[push, workflow_dispatch]
env:
# Cache version to control pre-commit caches
CACHE_VERSION: 0
# 3.9 is recent enough
DEFAULT_PYTHON: 3.10.11
# Location of the pre-commit cache. This is set by pre-commit, not us!
PRE_COMMIT_CACHE: ~/.cache/pre-commit
# Cancels previous runs targeting the same hash
concurrency:
group: >
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Setup Python
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON}}
cache: "pip"
- name: Generate pre-commit cache key
id: pre-commit_cache_key
run: >
echo "::set-output
name=key::${{ env.CACHE_VERSION }}-${{ env.DEFAULT_PYTHON }}-${{
hashFiles('.pre-commit-config.yaml') }}"
- name: Install pre-commit
run: |
pip install --upgrade pip
pip install "$(cat requirements_test.txt | grep pre-commit)"
- name: Restore base pre-commit environment
id: cache-pre-commmit
uses: actions/[email protected]
with:
path: ${{ env.PRE_COMMIT_CACHE }}
key: >
${{ runner.os
}}-pre-commit-${{
steps.pre-commit_cache_key.outputs.key }}
- name: Install pre-commit dependencies if no cache
if: steps.cache-pre-commit.outputs.cache-hit != 'true'
run: |
pre-commit install-hooks
- name: Install hadolint
run: >
sudo wget -O
/bin/hadolint
https://github.com/hadolint/hadolint/releases/download/v2.10.0/hadolint-Linux-x86_64
sudo chmod +x /bin/hadolint
- name: Run hooks
run: >
SKIP=no-commit-to-branch
pre-commit run --all-files --show-diff-on-failure