-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (73 loc) · 2.4 KB
/
code_quality_checks.yml
File metadata and controls
88 lines (73 loc) · 2.4 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
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
name: Code Quality Checks
on:
workflow_dispatch: # Activate this workflow manually
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
paths:
- "evaluations"
- "pyproject.toml"
env:
PYTHON_VERSION: "3.8"
HATCH_VERSION: "1.9.3"
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Check file format
run: hatch run format-check
- name: Check linting
run: hatch run check
- name: Check presence of license header
run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
# With the default value of 1, there are corner cases where tj-actions/changed-files
# fails with a `no merge base` error
fetch-depth: 0
- name: Get changed files
id: files
uses: tj-actions/changed-files@2d756ea4c53f7f6b397767d8723b3a10a9f35bf2 # v44.0.0
with:
files: |
**/*.py
files_ignore: |
test/**
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Install Hatch
id: hatch
run: |
pip install hatch==${{ env.HATCH_VERSION }}
echo "env=$(hatch env find test)" >> "$GITHUB_OUTPUT"
- uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
id: cache
with:
path: ${{ steps.hatch.outputs.env }}
key: ${{ runner.os }}-${{ github.sha }}
- name: Mypy
if: steps.files.outputs.any_changed == 'true'
run: |
mkdir .mypy_cache
hatch run test:types ${{ steps.files.outputs.all_changed_files }}
- name: Pylint
if: steps.files.outputs.any_changed == 'true'
run: |
hatch run test:lint ${{ steps.files.outputs.all_changed_files }}