-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (47 loc) · 1.73 KB
/
pre-commit.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
name: Pre-commits
on: [push]
jobs:
checks:
name: Run pre-commit
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup Environment
run: |
echo "NODE_VERSION=18.18.0" >> $GITHUB_ENV
echo "PYTHON_VERSION=$(cat .tool-versions | grep -Po '(?<=python ).*')" >> $GITHUB_ENV
echo "RUBY_VERSION=$(cat .tool-versions | grep -Po '(?<=ruby ).*')" >> $GITHUB_ENV
if [ $GITHUB_REF == 'refs/heads/master' ]; then echo "ENV=prod"; else echo "ENV=staging"; fi >> $GITHUB_ENV
echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*\/}" >> $GITHUB_ENV
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- name: Install Ruby dependencies
run: bundle install
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Store python version details for cache
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV"
- name: Pre-commit installation cache
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit|${{ env.PY }}|
- name: Install pre-commit
run: |
python -m pip install pre-commit
pre-commit install --install-hooks
- name: Run pre-commit checks
run: |
pre-commit run --all-files
- name: Run license checks
run: |
pre-commit run license_checks --files doc/dependency_decisions.yml
- name: Run specs
run: |
rspec