Skip to content

Commit 3235e75

Browse files
committed
Fix pyright error and add hack for pre-commit/action
1 parent ff61326 commit 3235e75

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

.github/workflows/code-checks.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,58 @@
11
---
22
name: Code Checks
33

4-
on:
4+
on: # yamllint disable-line rule:truthy
55
pull_request:
6-
branches: [main]
76
push:
87
branches: [main]
98

109
jobs:
11-
code-checks:
10+
pre-commit:
1211
runs-on: ubuntu-latest
1312
steps:
1413
- uses: actions/checkout@v3
15-
- run: pipx install poetry
14+
- name: Setup Poetry
15+
run: |
16+
pipx install poetry
17+
poetry config virtualenvs.in-project true
1618
- uses: actions/setup-python@v4
1719
with:
18-
python-version: "3.11"
20+
python-version: '3.11'
1921
cache: 'poetry'
22+
- run: poetry install --only dev
23+
# Hack to make pre-commit/action to use virtual env pre-commit.
24+
# pre-commit/action installs pre-commit using following command:
25+
# `python -m pip install pre-commit`
26+
# But `python` doesn't run virtual env interpreter when PATH is default.
27+
# Override PATH to use virtual env interpreter.
28+
# This change force run the virtual env pre-commit.
29+
- name: Set Poetry virtual env path to PATH
30+
run: echo ${{ github.workspace }}/.venv/bin >> $GITHUB_PATH
2031
- uses: pre-commit/[email protected]
2132
- uses: pre-commit-ci/[email protected]
2233
if: always()
34+
35+
pyright:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v3
39+
- name: Setup Poetry
40+
run: |
41+
pipx install poetry
42+
poetry config virtualenvs.in-project true
43+
- uses: actions/setup-python@v4
44+
with:
45+
python-version: '3.11'
46+
cache: 'poetry'
2347
- name: Install dependencies for pyright
2448
run: |
2549
poetry install --only main,test
2650
poetry run pip install PyQt6
51+
- run: poetry run pip list
52+
# Pyright uses dependencies of the interpreter run with the `python`.
53+
# But `python` doesn't run virtual env interpreter when PATH is default.
54+
# Override PATH to use virtual env interpreter.
55+
# This change makes pyright use dependencies of virtual env interpreter.
56+
- name: Set Poetry virtual env path to PATH
57+
run: echo ${{ github.workspace }}/.venv/bin >> $GITHUB_PATH
2758
- uses: jakebailey/pyright-action@v1

0 commit comments

Comments
 (0)