-
Notifications
You must be signed in to change notification settings - Fork 2
118 lines (99 loc) · 3.36 KB
/
checks.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#schema: https://github.com/softprops/github-actions-schemas/blob/master/workflow.json
name: "Code checks"
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
workflow_dispatch:
permissions:
id-token: write
actions: write
contents: read
packages: write
env:
ANNOY_COMPILER_ARGS: "-DANNOYLIB_MULTITHREADED_BUILD,-mno-avx512f"
jobs:
pre_job:
continue-on-error: true
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
if: ${{ !github.event.act }}
with:
concurrent_skipping: "same_content_newer"
skip_after_successful_duplicate: "true"
do_not_skip: '["workflow_dispatch"]'
paths_filter: |
python:
paths:
- 'pyproject.toml'
- 'poetry.lock'
- 'src/pixelator/**'
- 'tests/**'
paths_ignore:
- 'tests/**/*.md'
lint:
name: "Lint"
runs-on: ubuntu-latest
needs: [pre_job]
if: needs.pre_job.outputs.paths_result == '{}' || !fromJSON(needs.pre_job.outputs.paths_result).python.should_skip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python environment
uses: ./.github/actions/setup-python
with:
python-version: "3.11"
- name: ruff linter
uses: chartboost/ruff-action@v1
format-check:
name: "Check formatting"
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' || !fromJSON(needs.pre_job.outputs.paths_result).python.should_skip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: ruff formatter
uses: chartboost/ruff-action@v1
with:
args: "format --check"
# If the above check failed, post a comment on the PR explaining the failure
- name: Post PR comment
if: failure()
uses: mshick/add-pr-comment@v1
with:
message: |
## Python linting (`ruff format`) is failing
To keep the code consistent with lots of contributors, we run automated code consistency checks.
To fix this CI test, please run:
* `task format`
Once you push these changes the test should pass, and you can hide this comment :+1:
Thanks again for your contribution!
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: false
typecheck:
name: "Typecheck"
needs: [pre_job]
runs-on: ubuntu-latest
if: needs.pre_job.outputs.should_skip != 'true' || !fromJSON(needs.pre_job.outputs.paths_result).python.should_skip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python environment
uses: ./.github/actions/setup-python
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install poetry
poetry export --output requirements.txt --without-hashes --no-interaction --no-ansi --with dev
pip install -r requirements.txt
- name: Run mypy
run: |
mypy --ignore-missing-imports --install-types --non-interactive src/pixelator